diff options
author | Georg Pfuetzenreuter | 2022-05-26 20:05:21 +0200 |
---|---|---|
committer | Georg Pfuetzenreuter | 2022-05-26 20:05:21 +0200 |
commit | 425bd3961a68723eb126693ee65510b5df1ea785 (patch) | |
tree | c19cb419697b80d85c8a8a06a06aee61496043df | |
parent | ec9366e51c358b98d6ccd1dbd484077a7ae0c340 (diff) | |
download | system-425bd3961a68723eb126693ee65510b5df1ea785.tar.gz system-425bd3961a68723eb126693ee65510b5df1ea785.tar.bz2 system-425bd3961a68723eb126693ee65510b5df1ea785.zip |
Move echo's to debug setting + move template initiator
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
-rwxr-xr-x | scripts/bash/notifypwexp.sh | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/scripts/bash/notifypwexp.sh b/scripts/bash/notifypwexp.sh index 7f7d11b..3fc2e0b 100755 --- a/scripts/bash/notifypwexp.sh +++ b/scripts/bash/notifypwexp.sh @@ -14,6 +14,8 @@ weekmode=7 #for daily cron: #weekmode=0 +debug=false + admins="system" declare -r aged=21 # minimum days after expiration before admins are emailed, set to 0 for "always" @@ -58,7 +60,9 @@ secondsperday=86400 # set this to 1 for no division #secondsperday=1 today=$(($($dateprog $useUTC $epochseconds $dateformat)/$secondsperday)) -echo "today: $today" +if [ "$debug" = true ]; then + echo "today: $today" +fi oIFS=$IFS # ### END SETUP ### @@ -93,44 +97,60 @@ users=$($awkprog -F: -v uidfield=$uidfield \ for user in $users; do - echo "user: $user" + if [ "$debug" = true ]; then + echo "user: $user" + fi IFS=":" usershadow=$($grepprog ^$user $shadowfile) - echo "usershadow 1: $usershadow" + if [ "$debug" = true ]; then + echo "usershadow 1: $usershadow" + fi # make an array out of it usershadow=($usershadow) - echo "usershadow 2: $usershadow" + if [ "$debug" = true ]; then + echo "usershadow 2: $usershadow" + fi IFS=$oIFS mustchange=${usershadow[$must]} - echo "mustchange: $mustchange" + if [ "$debug" = true ]; then + echo "mustchange: $mustchange" + fi disabledate=${usershadow[$disable]:-$doesntmust} - echo "disabledate: $disabledate" + if [ "$debug" = true ]; then + echo "disabledate: $disabledate" + fi # skip users that aren't expiring or that are disabled if [[ $mustchange -ge $doesntmust || $disabledate -le $today ]] ; then continue; fi; lastchange=${usershadow[$last]} - echo "lastchange: $lastchange" + if [ "$debug" = true ]; then + echo "lastchange: $lastchange" + fi warndays=${usershadow[$warn]:-$warndefault} - echo "warndays: $warndays" + if [ "$debug" = true ]; then + echo "warndays: $warndays" + fi expdate=$(("$lastchange" + "$mustchange")) - echo "expdate: $expdate" + if [ "$debug" = true ]; then + echo "expdate: $expdate" + fi threshhold=$(($today + $warndays + $weekmode)) - echo "threshhold: $treshhold" + if [ "$debug" = true ]; then + echo "threshhold: $treshhold" + fi if [[ $expdate -lt $threshhold ]]; - - gentemplate_userbody "$(($expdate - $today))" - then + gentemplate_userbody "$(($expdate - $today))" if [[ $expdate -ge $today ]]; then subject=$(eval "echo \"$usersubjecttemplate\"") @@ -145,6 +165,5 @@ do fi fi fi - - done +unset debug |