Index: scripts/setup.sh =================================================================== diff -u -rd4988df80c5d03fe46e42c9563043ae281247278 -r3f328e08487912536ea5f9633014d08fd2010dac --- scripts/setup.sh (.../setup.sh) (revision d4988df80c5d03fe46e42c9563043ae281247278) +++ scripts/setup.sh (.../setup.sh) (revision 3f328e08487912536ea5f9633014d08fd2010dac) @@ -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" @@ -83,7 +97,7 @@ timedatectl set-local-rtc $TDCTL_RTC_LOCL } -function set_datetime() { +function set_datetime() { echo "Setup the time/date" while true; do timedatectl set-time "$DATETIME" 1>/dev/null 2>/dev/null @@ -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,26 +146,37 @@ update-rc.d $INITD_AUTOSTART defaults } -function confirm_reboot() { - read -p "ready to reboot? [y,n]" -n 1 -r CONFIRM - if [ "$CONFIRM" == "y" ]; then - rm $0 - reboot +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" + enableDRT + applicationPOST + testApplicationShasum_setup + startCloudSync_setup + startApplication_setup fi - echo "" } function main() { - disable_autostart - format_sdcard - set_timezone - set_datetime "$1" "$2" - diable_b2qt_services - setup_denali - enable_autostart + 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