Files

27 lines
671 B
Bash

#!/usr/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root"
exit 1
fi
if [ -r /etc/sa-train.conf ]; then
while read -r name value; do
if [[ -n "$name" && ! "$name" =~ ^\s*# ]]; then
typeset "$name=$value"
fi
done < /etc/sa-train.conf
fi
spammed_group=${spammed_group:-sa-train}
SPAMMED_USERS=$(groupmems -l -g "$spammed_group" 2> /dev/null)
if [ -z "$SPAMMED_USERS" ]; then
echo "No users have been added to the \"$spammed_group\" group. Canceling execution."
exit 2
fi
for USERNAME in $SPAMMED_USERS; do
sudo --login --non-interactive --user=$USERNAME /usr/bin/sa-train-user.sh
done