diff options
author | Dennis Eriksen <d@ennis.no> | 2021-03-30 06:50:06 +0200 |
---|---|---|
committer | Dennis Eriksen <d@ennis.no> | 2021-03-30 06:50:06 +0200 |
commit | f3fa1a955fbc5a3e6bc97bbacd4b27e908cd7701 (patch) | |
tree | 54d8858d0c824435daa046ed5b57f83fb83842fd | |
parent | Initial commit (diff) | |
download | htmpasswd-f3fa1a955fbc5a3e6bc97bbacd4b27e908cd7701.tar.gz |
more readme in comments, support -cron-suffix for cron
Diffstat (limited to '')
-rwxr-xr-x | htmpasswd | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -3,6 +3,19 @@ # made by Dennis Eriksen <dnns.no> in 2021 # # This script helps create temporary users for htpasswd-files +# +# README +# +# Alright. So, this script goes in your $PATH, and in one of your cron-folders. +# Personally I prefer /etc/cron.daily, but if you want more than daily +# precicion on retracting temporary access, you should probably use +# /etc/cron.hourly (for hourly precicion) or /etc/cron.d. +# +# This script uses the environmental variable $RUN_BY_CRON to recognize that it +# is being run by cron. I set this variable to true in /etc/crontab. You can +# also symlink this script to your cron-folder, and name the symlink with the +# suffix "-cron". +# # Exit on error. Append "|| true" if you expect an error. set -o errexit @@ -10,7 +23,8 @@ set -o errexit set -o errtrace # Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR set -o nounset -set -x +# set -x if the DEBUG-environmental is true +if ${DEBUG:-false}; then set -x; fi # Directory where htpasswd-files are stored HTDIR=/etc/nginx/htpasswd @@ -21,7 +35,7 @@ SPOOLDIR=/var/spool/htmpasswd # Temporary time, with minute precicion # Must be valid with `date` # Check by doing `date --date "$TIME"` -TIME="+60 minutes" +TIME="+1 day" USER_LENGTH=6 PASS_LENGTH=6 @@ -123,7 +137,7 @@ checkrw "${HTDIR}" checkrw "${SPOOLDIR}" # Run -if ${RUN_BY_CRON:-false}; then +if ${RUN_BY_CRON:-false} || [[ "${0}" =~ .*"-cron" ]]; then cronrun else main "$@" |