Sindbad~EG File Manager

Current Path : /opt/dedrads/
Upload File :
Current File : //opt/dedrads/unsusprunner.sh

#!/bin/bash
# Shared RADS Tools, written by Erik Soroka (eriks@imhadmin.net, ext 834)
# this script gets executed by crontab to unsuspend temporary suspended accounts from RADS tool

NOW=$(date +%s)

# Pull a list of users to unsuspend
for CURRENTUSER in $(/bin/ls -A /opt/dedrads/suspended); do
	if [ -z "$CURRENTUSER" ]; then
		echo
		echo "* ERROR: Could not find any accounts pending unsuspension, exiting."
		echo
		exit 1
	else

		UNSUSPTIME=$(cat "/opt/dedrads/suspended/$CURRENTUSER" |awk '{print $1}')
		SUSPDURATION=$(cat "/opt/dedrads/suspended/$CURRENTUSER" |awk '{print $2}')
		if [[ "$NOW" != "nontemp" ]] && [[ "$NOW" -ge "$UNSUSPTIME" ]];then
			TOUNSUSPEND="$TOUNSUSPEND $CURRENTUSER"
		fi
	fi
done
unset CURRENTUSER

if [ ! -z "$TOUNSUSPEND" ]; then

	for CURRENTUSER in $TOUNSUSPEND
	do
		if [ -z "$UNSUSPTIME" ]; then
			echo
			echo "* ERROR: Could not determine length of suspension, exiting."
			echo
			echo "[$(date)] ERROR: could not determine length of suspension for $CURRENTUSER" >> /var/log/suspension.log
			rm -f "/opt/dedrads/suspended/$CURRENTUSER"
			exit 0

		elif [ "$UNSUSPTIME" == "nontemp" ]; then
			echo
			echo "* This is not a temporary suspension, leaving suspended and exiting."
			echo
			rm -f "/opt/dedrads/suspended/$CURRENTUSER"

		# If suspension time is greater than now, go ahead and unsuspend
		elif [ "$NOW" -ge "$UNSUSPTIME" ];then
			rm -f "/opt/dedrads/suspended/$CURRENTUSER"
			/scripts/unsuspendacct "$CURRENTUSER"
			echo "[$(date)] $SUSPDURATION suspension for $CURRENTUSER elapsed, account has been [UNSUSPENDED]" >> /var/log/suspension.log
			echo "[$(date)] $SUSPDURATION suspension for $CURRENTUSER elapsed, account has been [UNSUSPENDED]"
			logger -t "SUSPEND" "$SUSPDURATION suspension for $CURRENTUSER elapsed, account has been [UNSUSPENDED]"
		fi

	done
fi
## EOF ##

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists