contrib/tor/pre-install

43 lines
891 B
Plaintext
Raw Normal View History

#!/bin/sh
# Created by Danny Rawlins, <romster at shortcircuit dot net dot au>
2008-07-07 21:13:18 +02:00
GROUP=tor
USER=tor
USER_COMMENT="Tor Daemon"
USER_HOME=/var/empty
USER_SHELL=/bin/sh
2008-01-18 03:21:04 +01: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."
fi
2008-01-18 03:21:04 +01:00
else
echo "Group: $GROUP already exists! Skipping."
fi
fi
2008-01-18 03:21:04 +01: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 03:32:12 +01:00
/usr/bin/passwd -l $USER > /dev/null
2008-01-18 03:21:04 +01:00
if [ $? -eq 0 ]; then
2008-03-26 03:32:12 +01:00
echo "Locked: $USER account."
fi
else
2008-01-18 03:21:04 +01:00
echo "ERROR: unable to lock $USER account."
/usr/sbin/userdel $USER
fi
else
echo "User: $USER already exists! Skipping."
fi