blob: e91ffdb312eaa662f49c295e70c8f44e7f26391c (
plain)
1 #!/bin/sh
2
3 # Created by Danny Rawlins, monster dot romster at gmail dot com
4
5 GROUP=nut
6 USER=nut
7 USER_COMMENT="Network UPS Tools"
8 USER_HOME=/var/empty
9 USER_SHELL=/bin/sh
10
11 if [ ! $(id -u) = 0 ]; then
12 echo "ERROR: you need to be root to run this!"
13 exit 1
14 fi
15
16 if [ $GROUP ]; then
17 if ! getent group $GROUP > /dev/null; then
18 /usr/sbin/groupadd $GROUP
19 if [ $? -eq 0 ]; then
20 echo "Group: $GROUP added."
21 fi
22 else
23 echo "Group: $GROUP already exists! Skipping."
24 fi
25 fi
26
27 if ! getent passwd $USER > /dev/null; then
28 /usr/sbin/useradd -g $GROUP -c "$USER_COMMENT" -d $USER_HOME -s $USER_SHELL $USER
29 if [ $? -eq 0 ]; then
30 echo "User: $USER added."
31 /usr/bin/passwd -l $USER > /dev/null
32 if [ $? -eq 0 ]; then
33 echo "Locked: $USER account."
34 fi
35 else
36 echo "ERROR: unable to lock $USER account."
37 /usr/sbin/userdel $USER
38 fi
39 else
40 echo "User: $USER already exists! Skipping."
41 fi
|