Index: scripts/setup.sh =================================================================== diff -u -rb9654575709e02aecc01a01d246d7af578679387 -r1e9d99fa2087d302e69c616b5a2420e010abe164 --- scripts/setup.sh (.../setup.sh) (revision b9654575709e02aecc01a01d246d7af578679387) +++ scripts/setup.sh (.../setup.sh) (revision 1e9d99fa2087d302e69c616b5a2420e010abe164) @@ -31,9 +31,7 @@ echo_dash_comment confirm "Continue" if [ $? -eq $FALSE ]; then - # Since the UI will still work without the SD-Card, but won't log, - #exit $ERR_SD_CARD # Do not exit the setup for now, - return $FALSE # And let the user to format and insert the sd-card later. + exit $ERR_SD_CARD fi else break @@ -55,8 +53,24 @@ fi fi - echo "Unmount the SD-Card if is in use" - umount "$SDCARD_PRT" + while true; do + echo "Unmount the SD-Card if is in use" + umount "$SDCARD_PRT" + if [ ! "$( mount | grep $SDCARD_PRT)" == "" ]; then # is still mounted + if [ $? -eq $FALSE ]; then # if SD-Card cannot the unmounted then stop the format. + echo "The SD-Card $SDCARD_DEV cannot be unmounted, therefore cannot be formatted" + confirm "Do you want to retry?" + if [ $? -eq $FALSE ]; then + return $FALSE # do not continue with format + fi + else + break + fi + else + break + fi + done + echo "Removing current partitions" sfdisk --delete $SDCARD_DEV 1>/dev/null 2>/dev/null echo "Create new partition" @@ -101,6 +115,11 @@ systemctl disable connman systemctl disable qtlauncher systemctl disable ebikedata + + echo "Stop the boot2Qt setvices" + killall qtlauncher + killall datacollector + killall appcontroller } function setup_denali() { @@ -117,8 +136,8 @@ } function disable_autostart() { - # in case the device is alread setup, disable the autostart of the application until the setup script enables it. - rm -f $INITD_LOCATION$INITD_AUTOSTART + # in case the device is alread setup, disable the autostart of the application until the setup script enables it. + rm -f $INITD_LOCATION$INITD_AUTOSTART } function enable_autostart() { @@ -127,43 +146,37 @@ update-rc.d $INITD_AUTOSTART defaults } +function enableDRT() { + # trying to temporarily add the DRT server input open for the device registration + iptables -A INPUT -p tcp -s $CloudSync_DRT_SERVER_IP --dport $CloudSync_DRT_SERVER_PORT -j ACCEPT + # enables the ping from the DRT server to the device [ useful for testing ] + iptables -A INPUT -p icmp --icmp-type echo-request -s $CloudSync_DRT_SERVER_IP -j ACCEPT +} + function manufacturingMode() { if [ "$(grep $SETUP_ENABLE_MANUFACTURING_MODE $SETUP_CONF_FILE)" != "" ]; then # -E for Maunufacturing mode # -a for disabling the non-minimizable Alarms - APPLICATION_PARAMS="-E -a" # don't use '&', we have to wait until user is done with UI + APPLICATION_PARAMS="-E -a" + enableDRT applicationPOST + testApplicationShasum_setup + startCloudSync_setup + startApplication_setup fi } -function confirm_reboot() { - read -p "ready to reboot? [y,n]" -n 1 -r CONFIRM - if [ "$CONFIRM" == "y" ]; then - rm $0 - reboot - fi - echo "" -} - -function cleanup() { - rm $SETUP_CONF_FILE - rm $(basename $0) - rm -frd $HOME/.ssh -} - function main() { - disable_autostart - format_sdcard - set_timezone - set_datetime "$1" "$2" - diable_b2qt_services - setup_denali - enable_autostart - manufacturingMode - cleanup + disable_autostart + format_sdcard + set_timezone + set_datetime "$1" "$2" + diable_b2qt_services + setup_denali + enable_autostart + manufacturingMode } main "$1" "$2" -confirm_reboot exit 0