Index: scripts/start.sh =================================================================== diff -u -rb1c2f458dc6c49c923938f51a2a1a8f4ca130f2f -r9292d4e761297501dac5166de69c7d16c03bfb0a --- scripts/start.sh (.../start.sh) (revision b1c2f458dc6c49c923938f51a2a1a8f4ca130f2f) +++ scripts/start.sh (.../start.sh) (revision 9292d4e761297501dac5166de69c7d16c03bfb0a) @@ -22,14 +22,50 @@ DEMO_SETUP=0 DEMO_SWITCH="-D" -if [ "$2" == $DEMO_SWITCH ]; then - DEMO_SETUP=1 -fi +SERVER_IP="" +SERVER_PORT="3000" +SERVER_SWITCH="-S" +SERVER_CONFIG_LINE=".*\"url_mft\".*" +SERVER_CONFIG_BGN=" \"url_mft\": \"http:\/\/" +SERVER_CONFIG_END=":$SERVER_PORT\"," +SERVER_CONFIG_FILE="./cloudsync/cloudsync/config/config.json" + +GLOBALS_CONFIG_MDFY="CloudSync_DRT_SERVER_IP=" +GLOBALS_CONFIG_LINE="CloudSync_DRT_SERVER_IP=.*" +GLOBALS_FILE="./globals.sh" + + +# command line parameters detection +for arg in "$@"; do + case $arg in + "$DEMO_SWITCH") + DEMO_SETUP=1 + echo "Setup started for demo mode" + ;; + "$SERVER_SWITCH"*) + SERVER_IP="${arg:2}" + getServerIP + #If the server IP is not given or is invalid will be asked to enter and the defualt Diality prefered will be suggested. + #If the server IP is valid and accepted then change the CloudSync conf file + sed "s/$SERVER_CONFIG_LINE/$SERVER_CONFIG_BGN$SERVER_IP$SERVER_CONFIG_END/" $SERVER_CONFIG_FILE + #and modify the globals.sh + sed "s/$GLOBALS_CONFIG_LINE/$GLOBALS_CONFIG_MDFY$SERVER_IP/" $GLOBALS_FILE + echo "DRT Server IP: $SERVER_IP" + ;; + esac +done + function displayHelp() { if [ "$1" = "-h" -o "$1" = "--help" ]; then echo -e "-h \t This help" - echo "usage start.sh [ [xxx] or [xxx.xxx.xxx.xxx] ]" + echo "usage start.sh [ [xxx.xxx.xxx.xxx] ] -D -S[[xxx.xxx.xxx.xxx]]" + echo "device IP : M ust always be the first parameter" + echo "-D : Indicating the system is going to be setup in Demo mode." + echo " The Demo application folder need to be copied to the update folder." + echo "-S : Shall include the server IP in complete IP format [xxx.xxx.xxx.xxx]" + echo " There should be no space between -S and the server IP address" + echo " For example : -S192.168.1.5" exit 0 fi } @@ -182,6 +218,24 @@ done } +function getServerIP() { + while true; do + validIP "$SERVER_IP" + if [ $? -eq 0 ]; then + break + else + read -p "Please enter the server Ip address: " -e -i "$CloudSync_DRT_SERVER_IP" -r SERVER_IP + validIP "$SERVER_IP" + if [ $? -eq 0 ]; then + break + else + echo "The entered IP address is not valid [$SERVER_IP]" + exitConfirm $? + fi + fi + done +} + function setupBootupScripts() { echo_dash_comment echo_dash_message "Installing bootup scripts" | tee -a $LOG_OUT_FILE