-
Notifications
You must be signed in to change notification settings - Fork 0
/
mupsetup.sh
52 lines (44 loc) · 1.29 KB
/
mupsetup.sh
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
#!/bin/bash
ask() {
while true; do
read -p "$1 [Y/n] " REPLY </dev/tty
if [ -z "$REPLY" ]; then
REPLY=Y
fi
case "$REPLY" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}
if ! [ $(id -u) = 0 ]; then
echo "Please run as root"
exit
fi
echo "This script is made to work on debian-like distributions"
username="Creator4983"
password="KevinFlynn"
echo "What is the username of the meteor user, likely to be you appname?"
read username
echo "What is the password of the meteor user?"
read password
if ask "Is /etc/sudoers your sudoers file?"; then
sudoers="/etc/sudoers"
else
echo "Where is located your sudoers file?"
read sudoers
fi
useradd $username
echo $username:$password | chpasswd
adduser $username sudo
if grep -q "%sudo ALL=(ALL) NOPASSWD:ALL" $sudoers; then
echo "The script worked correctly, you can now use the new user in your mup.json"
exit
fi
echo "# meteorup-server-script\n%sudo ALL=(ALL) NOPASSWD:ALL" >> $sudoers
service sudo restart
if grep -q "%sudo ALL=(ALL) NOPASSWD:ALL" $sudoers; then
echo "The script worked correctly, you can now use the new user in your mup.json"
exit
fi
echo "The script could not modify the sudoers file check with visudo for %sudo ALL=(ALL) NOPASSWD:ALL"