-
Notifications
You must be signed in to change notification settings - Fork 17
/
env_creation.sh
executable file
·88 lines (84 loc) · 3.43 KB
/
env_creation.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# CHOOSE THE HOME_DIR FOR THE NODESTER USER
NODESTER_HOME_DIR="/root/nodester"
NODESTER_USER="nodester"
NODESTER_USER_PASS="YourUb3rSecretPassword!"
NODESTER_GROUP="nodester"
# PASTE YOUR USER SSH KEY IN THE VAR BELOW
YOUR_PUB_KEY=""
whoami=`whoami`
system=`uname -s`
case $whoami in
root)
echo "You're root! *pew pew*"
case $system in
'Darwin')
groupadd $NODESTER_GROUP && \
useradd -d $NODESTER_HOME_DIR -c "nodester user" -g $NODESTER_GROUP -m -r -N -s /bin/bash $NODESTER_USER && \
(sleep 1s; echo $NODESTER_USER_PASS ; sleep 1s ; echo $NODESTER_USER_PASS) | passwd $NODESTER_USER && \
break || \
( echo "error making group/user!" ; exit 1 )
;;
'Linux')
sh -c " groupadd $NODESTER_GROUP && \
useradd -d $NODESTER_HOME_DIR -c \"nodester user\" -g $NODESTER_GROUP -m -r -N -s /bin/bash $NODESTER_USER && \
( ( sleep 1s; echo $NODESTER_USER_PASS ; sleep 1s ; echo $NODESTER_USER_PASS ) | passwd $NODESTER_USER ) && \
break " || \
( echo "error making group/user!" ; exit 1 )
;;
'*')
echo "Your OS is not supported yet.. please contact the dev staff" && exit 1
;;
esac
sh -c " mkdir -p $NODESTER_HOME_DIR/.ssh &&
echo $YOUR_PUB_KEY > $NODESTER_HOME_DIR/.ssh/authorized_keys &&
chmod -R 700 $NODESTER_HOME_DIR/.ssh &&
echo \"# nodester related rules
$NODESTER_USER ALL = NOPASSWD: $NODESTER_HOME_DIR/nodester/proxy/start_proxy.sh *
$NODESTER_USER ALL = NOPASSWD: $NODESTER_HOME_DIR/nodester/proxy/stop.sh
$NODESTER_USER ALL = NOPASSWD: $NODESTER_HOME_DIR/nodester/scripts/launch_app.sh *
\" >> /etc/sudoers && break " ||\
( echo "error make FS skeleton!" ; exit 1 )
;;
*)
echo "You ain't root! *:(*"
case $system in
'Darwin')
####
#dscl / -create /Users/toddharris
#dscl / -create /Users/toddharris UserShell /bin/bash
#dscl / -create /Users/toddharris RealName "Dr. Todd Harris"
#dscl / -create /Users/toddharris UniqueID 503
#dscl / -create /Users/toddharris PrimaryGroupID 1000
#dscl / -create /Users/toddharris NFSHomeDirectory /Local/Users/toddharris
#dscl / -passwd /Users/toddharris PASSWORD
#
#sudo /System/Library/ServerSetup/serversetup -createUser fullname shortname password
###########
groupadd $NODESTER_GROUP && \
useradd -d $NODESTER_HOME_DIR -c "nodester user" -g $NODESTER_GROUP -m -r -N -s /bin/bash $NODESTER_USER && \
(sleep 1s; echo $NODESTER_USER_PASS ; sleep 1s ; echo $NODESTER_USER_PASS) | passwd $NODESTER_USER && \
break || \
( echo "error creating user/group!" ; exit 1 )
;;
'Linux')
sudo sh -c "groupadd $NODESTER_GROUP &&
useradd -d $NODESTER_HOME_DIR -c 'nodester user' -g $NODESTER_GROUP -m -r -N -s /bin/bash $NODESTER_USER &&
( ( sleep 1s; echo $NODESTER_USER_PASS ; sleep 1s ; echo $NODESTER_USER_PASS ) | passwd $NODESTER_USER ) && break " ||\
( echo "*HERE* Error while creating user/group!" ; exit 1 )
;;
'*')
( echo "Your OS is not supported yet.. please contact the dev staff" ; exit 1 )
;;
esac
sudo sh -c "mkdir -p $NODESTER_HOME_DIR/.ssh &&
echo $YOUR_PUB_KEY > $NODESTER_HOME_DIR/.ssh/authorized_keys &&
chmod -R 700 $NODESTER_HOME_DIR/.ssh &&
echo \"# nodester related rules
$NODESTER_USER ALL = NOPASSWD: $NODESTER_HOME_DIR/proxy/start_proxy.sh *
$NODESTER_USER ALL = NOPASSWD: $NODESTER_HOME_DIR/proxy/stop.sh
$NODESTER_USER ALL = NOPASSWD: $NODESTER_HOME_DIR/scripts/launch_app.sh *
\" >> /etc/sudoers && break" ||\
( echo "error make FS skeleton!" ; exit 1 )
;;
esac
exit 0