Index: scripts/start.sh =================================================================== diff -u -redb906c1eac24e192f69ccd9cedc1da51a66e380 -r63c6fe7fab869eebdad66b970b3b3ab8e4c5e046 --- scripts/start.sh (.../start.sh) (revision edb906c1eac24e192f69ccd9cedc1da51a66e380) +++ scripts/start.sh (.../start.sh) (revision 63c6fe7fab869eebdad66b970b3b3ab8e4c5e046) @@ -41,6 +41,7 @@ SERVER_DRT_WS_PRODUCT="production" SERVER_DRT_WS_STAGING="staging" SERVER_DRT_WS_QUALITY="quality" +SERVER_DRT_WS_QUALITY2="quality2" GLOBALS_CONFIG_MDFY="CloudSync_DRT_SERVER_IP=" GLOBALS_CONFIG_LINE="CloudSync_DRT_SERVER_IP=.*" @@ -69,45 +70,46 @@ function setupPreparation() { getDeviceIP + echo "Device IP Address : $DST_IP" + if (( $DEMO_SETUP )); then echo "Device operation Mode : Demo Mode" else echo "Device operation Mode : Normal Operation" fi - echo "Device IP Address : $DST_IP" # if it is the update only we don't need the configuration if (( $MANUFACTURING_SETUP )); then echo "Device setup Mode : Manufacturing Setup" + + getServerIP + echo "DRT Server IP Address : $SERVER_IP" + + getServerWS + echo "DRT Server Environment: $SERVER_WS" else echo "Device setup Mode : Update Only" - return + SERVER_WS=$SERVER_DRT_WS_PRODUCT fi - - getServerIP - echo "DRT Server IP Address : $SERVER_IP" - - getServerWS - echo "DRT Server Environment: $SERVER_WS" - - # create the conf file - local config_env_json="$SERVER_CONFIG_FILE" - local config_json="$SERVER_CONFIG_FILE" - - - # creat the config.json file - cp "$SERVER_CONFIG_JSON_WS""_""$SERVER_WS"".""$SERVER_CONFIG_EXT" $SERVER_CONFIG_JSON - if [[ ! -e $SERVER_CONFIG_JSON ]]; then - echo "The file $SERVER_CONFIG_JSON cannot be created" + + # create the config.json file + local config_env_json="$SERVER_CONFIG_JSON_WS""_""$SERVER_WS"".""$SERVER_CONFIG_EXT" + local config_json="$SERVER_CONFIG_JSON" + echo "CloudSync config base : "$config_env_json + cp $config_env_json $config_json # copy the config for the selected environment to config.json + if [[ ! -e $config_json ]]; then + echo "The file $config_json cannot be created" exit 0 fi - - # setting up the DRT Server IP address - #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 -i "s/$SERVER_CONFIG_LINE/$SERVER_CONFIG_BGN$SERVER_IP$SERVER_CONFIG_END/" $SERVER_CONFIG_JSON - #and modify the globals.sh - sed -i "s/$GLOBALS_CONFIG_LINE/$GLOBALS_CONFIG_MDFY$SERVER_IP/" $GLOBALS_FILE + + if (( $MANUFACTURING_SETUP )); then + # setting up the DRT Server IP address + #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 -i "s/$SERVER_CONFIG_LINE/$SERVER_CONFIG_BGN$SERVER_IP$SERVER_CONFIG_END/" $config_json + #and modify the globals.sh + sed -i "s/$GLOBALS_CONFIG_LINE/$GLOBALS_CONFIG_MDFY$SERVER_IP/" $GLOBALS_FILE + fi } function displayHelp() { @@ -120,9 +122,10 @@ echo " Demo mode mode can be used to use the device as a demo unit." echo " In this mode Application will not work with the actual hardware and will work in simulation mode." echo " The Demo application folder need to be copied to the update folder manually." - echo "-U : Update mode" - echo " Update mode can only be used when the device is already registered," - echo " Therefore the -S and -W will be ignored." + echo "-E : Manufacturing setup mode" + echo " The Manufacturing setup will wipe device configuration, setup, registration," + echo " and nees a fresh configuration, and device registration on the cloud," + echo " therefore the -S and -W is mandatory." echo "-S : The DRT Server IP address" echo " Need to be entered fully in a valid IP format [xxx.xxx.xxx.xxx]" echo " There should be no space between -S and the server IP address" @@ -132,6 +135,7 @@ echo " - production" echo " - staging" echo " - quality" + echo " - quality2" echo " For example : -Wproduction" exit 0 fi @@ -168,14 +172,14 @@ ssh-keygen -N "" -f $SRC_FILE_SSHKEY 1>>$LOG_OUT_FILE 2>>$LOG_ERR_FILE return $? else - echo "Found ssh key " $SRC_FILE_SSHKEY_PUB + echo "Found ssh key :" $SRC_FILE_SSHKEY_PUB fi return 0 } function sshKeyCopy() { - echo "Registering the ssh key on the device $DST_IP" echo "Please wait ..." + echo "Registering the ssh key on the device $DST_IP" ssh-copy-id $SSH_PARAM -f -i $SRC_FILE_SSHKEY_PUB $DST_USER@$DST_IP 1>>$LOG_OUT_FILE 2>>$LOG_ERR_FILE if [ ! $? -eq 0 ]; then echo "Connection to host $DST_IP failed." | tee -a $LOG_OUT_FILE @@ -236,7 +240,7 @@ } function manufacturingModePrompt() { - if (( $MANUFACTURING_SETUP )); then continue; else return; fi + if (( $MANUFACTURING_SETUP )); then :; else return; fi echo_star_comment echo_star_message "Do you want to run in the Manufacturing Mode?" @@ -247,8 +251,8 @@ sshRun "echo $SETUP_ENABLE_MANUFACTURING_MODE > $SETUP_CONF_FILE" echo_star_message "Set the setup in manufacturing mode" else - sshRun "echo '' > $SETUP_CONF_FILE" - echo_star_message "Continuing the setup in normal mode" + echo_star_message "Abort the Manufacturing setup by user" + exit 0 fi } @@ -276,7 +280,7 @@ if [ $? -eq 0 ]; then break else - read -p "Please enter the server Ip address: " -e -i "" -r SERVER_IP + read -p "Please enter the server Ip address : " -e -i "" -r SERVER_IP validIP "$SERVER_IP" if [ $? -eq 0 ]; then break @@ -290,16 +294,15 @@ function validWS() { if [[ -z $SERVER_WS ]]; then return 1; fi - case $SERVER_WS in "$SERVER_DRT_WS_PRODUCT");; "$SERVER_DRT_WS_STAGING");; "$SERVER_DRT_WS_QUALITY");; + "$SERVER_DRT_WS_QUALITY2");; *) echo "The entered server environment is not valid [$SERVER_WS]" return 1 esac - return 0 } @@ -309,7 +312,7 @@ if [ $? -eq 0 ]; then break else - read -p "Please enter the server Ip address: " -e -i "" -r SERVER_WS + read -p "Please enter the server environment: " -e -i "" -r SERVER_WS validWS "$SERVER_WS" if [ $? -eq 0 ]; then break @@ -412,13 +415,13 @@ manufacturingModePrompt wipe_device + setupDemoMode setupBootupScripts setupSettingsScripts setupConfigurations setupCloudSync setupFonts setupApplication - setupDemoMode } # running the main function