Move echo's to debug setting + move template initiator

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
Georg Pfuetzenreuter 2022-05-26 20:05:21 +02:00
parent ec9366e51c
commit 425bd3961a
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57
1 changed files with 34 additions and 15 deletions

View File

@ -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