Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed env_creation for linux .. started macosx stub

  • Loading branch information...
commit b3b9bd755d02744db38ff969a7f403f203c3e1ee 1 parent 86afbc6
@eldios eldios authored
Showing with 79 additions and 13 deletions.
  1. +79 −13 env_creation.sh
View
92 env_creation.sh
@@ -1,22 +1,88 @@
# CHOOSE THE HOME_DIR FOR THE NODESTER USER
-NODESTER_HOME_DIR="/var/nodester"
+NODESTER_HOME_DIR="/root/nodester"
NODESTER_USER="nodester"
NODESTER_USER_PASS="YourUb3rSecretPassword!"
NODESTER_GROUP="nodester"
-
-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
-
-mkdir -p $HOME_DIR/.ssh
-# PASTE YOUR SSH KEY IN THE VAR HERE BELOW
+# PASTE YOUR USER SSH KEY IN THE VAR BELOW
YOUR_PUB_KEY=""
-echo $YOUR_PUB_KEY > $HOME_DIR/.ssh/authorized_keys
-chmod -R 700 $HOME_DIR/.ssh
-# ENABLING SUDO FOR THE NODESTER USER
-echo "# nodester related rules
+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
+ \" >> /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
Please sign in to comment.
Something went wrong with that request. Please try again.