2006-11-21 22:03:23 +11:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Created by Danny Rawlins, <romster at shortcircuit dot net dot au>
|
|
|
|
|
2008-07-08 05:13:18 +10:00
|
|
|
GROUP=tor
|
|
|
|
USER=tor
|
2006-11-21 22:03:23 +11:00
|
|
|
USER_COMMENT="Tor Daemon"
|
|
|
|
USER_HOME=/var/empty
|
|
|
|
USER_SHELL=/bin/sh
|
|
|
|
|
2008-01-18 13:21:04 +11:00
|
|
|
if [ ! $(id -u) = 0 ]; then
|
|
|
|
echo "ERROR: you need to be root to run this!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $GROUP ]; then
|
|
|
|
if ! getent group $GROUP > /dev/null; then
|
|
|
|
/usr/sbin/groupadd $GROUP
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Group: $GROUP added."
|
2006-11-21 22:03:23 +11:00
|
|
|
fi
|
2008-01-18 13:21:04 +11:00
|
|
|
else
|
|
|
|
echo "Group: $GROUP already exists! Skipping."
|
|
|
|
fi
|
2006-11-21 22:03:23 +11:00
|
|
|
fi
|
|
|
|
|
2008-01-18 13:21:04 +11:00
|
|
|
if ! getent passwd $USER > /dev/null; then
|
|
|
|
/usr/sbin/useradd -g $GROUP -c "$USER_COMMENT" -d $USER_HOME -s $USER_SHELL $USER
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "User: $USER added."
|
2008-03-26 13:32:12 +11:00
|
|
|
/usr/bin/passwd -l $USER > /dev/null
|
2008-01-18 13:21:04 +11:00
|
|
|
if [ $? -eq 0 ]; then
|
2008-03-26 13:32:12 +11:00
|
|
|
echo "Locked: $USER account."
|
2006-11-21 22:03:23 +11:00
|
|
|
fi
|
|
|
|
else
|
2008-01-18 13:21:04 +11:00
|
|
|
echo "ERROR: unable to lock $USER account."
|
|
|
|
/usr/sbin/userdel $USER
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "User: $USER already exists! Skipping."
|
2006-11-21 22:03:23 +11:00
|
|
|
fi
|
|
|
|
|