Move echo's to debug setting + move template initiator
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
ec9366e51c
commit
425bd3961a
@ -14,6 +14,8 @@ weekmode=7
|
|||||||
#for daily cron:
|
#for daily cron:
|
||||||
#weekmode=0
|
#weekmode=0
|
||||||
|
|
||||||
|
debug=false
|
||||||
|
|
||||||
admins="system"
|
admins="system"
|
||||||
declare -r aged=21 # minimum days after expiration before admins are emailed, set to 0 for "always"
|
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
|
#secondsperday=1
|
||||||
|
|
||||||
today=$(($($dateprog $useUTC $epochseconds $dateformat)/$secondsperday))
|
today=$(($($dateprog $useUTC $epochseconds $dateformat)/$secondsperday))
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
echo "today: $today"
|
echo "today: $today"
|
||||||
|
fi
|
||||||
oIFS=$IFS
|
oIFS=$IFS
|
||||||
|
|
||||||
# ### END SETUP ###
|
# ### END SETUP ###
|
||||||
@ -93,44 +97,60 @@ users=$($awkprog -F: -v uidfield=$uidfield \
|
|||||||
for user in $users;
|
for user in $users;
|
||||||
do
|
do
|
||||||
|
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
echo "user: $user"
|
echo "user: $user"
|
||||||
|
fi
|
||||||
|
|
||||||
IFS=":"
|
IFS=":"
|
||||||
usershadow=$($grepprog ^$user $shadowfile)
|
usershadow=$($grepprog ^$user $shadowfile)
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
echo "usershadow 1: $usershadow"
|
echo "usershadow 1: $usershadow"
|
||||||
|
fi
|
||||||
|
|
||||||
# make an array out of it
|
# make an array out of it
|
||||||
usershadow=($usershadow)
|
usershadow=($usershadow)
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
echo "usershadow 2: $usershadow"
|
echo "usershadow 2: $usershadow"
|
||||||
|
fi
|
||||||
|
|
||||||
IFS=$oIFS
|
IFS=$oIFS
|
||||||
|
|
||||||
mustchange=${usershadow[$must]}
|
mustchange=${usershadow[$must]}
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
echo "mustchange: $mustchange"
|
echo "mustchange: $mustchange"
|
||||||
|
fi
|
||||||
|
|
||||||
disabledate=${usershadow[$disable]:-$doesntmust}
|
disabledate=${usershadow[$disable]:-$doesntmust}
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
echo "disabledate: $disabledate"
|
echo "disabledate: $disabledate"
|
||||||
|
fi
|
||||||
|
|
||||||
# skip users that aren't expiring or that are disabled
|
# skip users that aren't expiring or that are disabled
|
||||||
if [[ $mustchange -ge $doesntmust || $disabledate -le $today ]] ; then continue; fi;
|
if [[ $mustchange -ge $doesntmust || $disabledate -le $today ]] ; then continue; fi;
|
||||||
|
|
||||||
lastchange=${usershadow[$last]}
|
lastchange=${usershadow[$last]}
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
echo "lastchange: $lastchange"
|
echo "lastchange: $lastchange"
|
||||||
|
fi
|
||||||
|
|
||||||
warndays=${usershadow[$warn]:-$warndefault}
|
warndays=${usershadow[$warn]:-$warndefault}
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
echo "warndays: $warndays"
|
echo "warndays: $warndays"
|
||||||
|
fi
|
||||||
|
|
||||||
expdate=$(("$lastchange" + "$mustchange"))
|
expdate=$(("$lastchange" + "$mustchange"))
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
echo "expdate: $expdate"
|
echo "expdate: $expdate"
|
||||||
|
fi
|
||||||
|
|
||||||
threshhold=$(($today + $warndays + $weekmode))
|
threshhold=$(($today + $warndays + $weekmode))
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
echo "threshhold: $treshhold"
|
echo "threshhold: $treshhold"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $expdate -lt $threshhold ]];
|
if [[ $expdate -lt $threshhold ]];
|
||||||
|
|
||||||
gentemplate_userbody "$(($expdate - $today))"
|
|
||||||
|
|
||||||
then
|
then
|
||||||
|
gentemplate_userbody "$(($expdate - $today))"
|
||||||
if [[ $expdate -ge $today ]];
|
if [[ $expdate -ge $today ]];
|
||||||
then
|
then
|
||||||
subject=$(eval "echo \"$usersubjecttemplate\"")
|
subject=$(eval "echo \"$usersubjecttemplate\"")
|
||||||
@ -145,6 +165,5 @@ do
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
unset debug
|
||||||
|
Loading…
Reference in New Issue
Block a user