-
Notifications
You must be signed in to change notification settings - Fork 1
/
rsuser
executable file
·69 lines (64 loc) · 2.19 KB
/
rsuser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#License:
#"Remote Syslog" is a free application what can be used to view syslog messages.
#Copyright (C) 2021 Tom Slenter
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#For more information contact the author:
#Name author: Tom Slenter
#E-mail: info@remotesyslog.com
#Banner
function banner() {
echo ""
echo "##################################################"
echo "#Remote Syslog X/C #"
echo "#More information: https://www.remotesyslog.com #"
echo "#Remote Syslog user management #"
echo "#Version: RSX 0.1 #"
echo "#Donations: https://github.com/tslenter/RSX-RSC #"
echo "##################################################"
echo ""
}
banner
#Check if user is root
if ! [ $(id -u) = 0 ]; then
clear
banner
echo "This installation must be run as root!"
echo ""
exit 1
fi
#User management
if [ "$1" != '' ] && [ "$2" == 'add' ]; then
echo "Adding user: $1"
if [ "$3" == 'web-only' ]; then
useradd -s /bin/false -m -d /home/$1 $1
else
useradd -s /bin/bash -m -d /home/$1 $1
fi
passwd $1
elif [ "$1" != '' ] && [ "$2" == 'rm' ]; then
echo "Removing user: $1"
userdel $1
while true; do
read -p "Do you wish to remove the home directory, answer: y or n? " yn
case $yn in
[Yy]* ) rm -r /home/$1; break;;
[Nn]* ) exit;;
* ) echo "Please answer y or n.";;
esac
done
else
echo "Please use the command as: rsuser <username> <rm or add> <web-only>"
fi