Index: scripts/crypt_setup.sh =================================================================== diff -u -r1da89b0452b8ef9448847618e75c118f3f58bd0c -rf45f4093470d79f74c79f5a162bff598215b5dda --- scripts/crypt_setup.sh (.../crypt_setup.sh) (revision 1da89b0452b8ef9448847618e75c118f3f58bd0c) +++ scripts/crypt_setup.sh (.../crypt_setup.sh) (revision f45f4093470d79f74c79f5a162bff598215b5dda) @@ -15,7 +15,6 @@ # ############################################################################ - ERR_CRYPTSETUP_UNKNOWN=100 ERR_CRYPTSETUP_USAGE=101 @@ -30,14 +29,33 @@ ERR_CRYPTSETUP_CREATE_MKFS=124 ERR_CRYPTSETUP_CREATE_MOUNT=125 -ERR_CRYPTSETUP_MOUNT_OPEN=131 -ERR_CRYPTSETUP_MOUNT_MOUNT=132 +ERR_CRYPTSETUP_MOUNT_TYPE=131 +ERR_CRYPTSETUP_MOUNT_OPEN=132 +ERR_CRYPTSETUP_MOUNT_MOUNT=133 +ERR_CRYPTSETUP_MOUNT_MOUNT=134 LOC_DEV="/dev/mmcblk0p7" LOC_DIR="configurations" LOC_MAP="/dev/mapper/"$LOC_DIR LOC_VAR="/var/"$LOC_DIR +DEV_TYP="crypto_LUKS" +DEV_MNT="/dev/mapper/configurations on /var/configurations type ext4 (rw,relatime)" + +function isEncrypted () { + if [ "$( blkid | grep "$LOC_DEV" | grep "TYPE=$DEV_TYP" )" != "" ]; then + echo "not an encrypted partition" + exit $ERR_CRYPTSETUP_MOUNT_TYPE + fi +} + +function isMounted() { + if [ "$( mount | grep "$DEV_MNT" )" != "" ]; then + echo "partition already mounted" + exit $ERR_CRYPTSETUP_MOUNT_MOUNT + fi +} + function checkPassword() { if [ "$PASSWORD" == "" ]; then echo "setup command missing password argument" @@ -76,6 +94,8 @@ function mount_luks_partition() { + isEncrypted # if encrypted will continue else will exit with error + isMounted # if not mounted will continue else will exit with error checkOutput "cryptsetup luksOpen $LOC_DEV $LOC_DIR" $ERR_CRYPTSETUP_MOUNT_OPEN $PASSWORD checkOutput "mount -t ext4 $LOC_MAP $LOC_VAR" $ERR_CRYPTSETUP_MOUNT_MOUNT } Index: scripts/globals.sh =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rf45f4093470d79f74c79f5a162bff598215b5dda --- scripts/globals.sh (.../globals.sh) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ scripts/globals.sh (.../globals.sh) (revision f45f4093470d79f74c79f5a162bff598215b5dda) @@ -102,6 +102,9 @@ DENALI_BIN=denali LAUNCH_SCR=run.sh +SETUP_CONF_FILE="setup.conf" +SETUP_ENABLE_MANUFACTURING_MODE="ManufacturingMode 1" + function confirm() { read -p "$1? [y,n]" -n 1 -r CONTINUE if [ "$CONTINUE" == "y" ]; then @@ -113,7 +116,7 @@ fi } -string_trim() { +function string_trim() { local var="$*" # remove leading whitespace characters var="${var#"${var%%[![:space:]]*}"}" Index: scripts/run.sh =================================================================== diff -u -r389f028cb9d4d320eae393de7c4408a58a619356 -rf45f4093470d79f74c79f5a162bff598215b5dda --- scripts/run.sh (.../run.sh) (revision 389f028cb9d4d320eae393de7c4408a58a619356) +++ scripts/run.sh (.../run.sh) (revision f45f4093470d79f74c79f5a162bff598215b5dda) @@ -19,8 +19,8 @@ time_start=$(date +%s) echo nameserver 8.8.8.8 > /etc/resolv.conf -echo nameserver 192.168.10.20 >> /etc/resolv.conf -echo nameserver 192.168.10.21 >> /etc/resolv.conf +echo nameserver 192.168.10.20 >> /etc/resolv.conf # these need to be removed when/if the IoT WiFi doens't need them +echo nameserver 192.168.10.21 >> /etc/resolv.conf # these need to be removed when/if the IoT WiFi doens't need them systemctl start systemd-resolved.service @@ -54,11 +54,10 @@ #setting up ethernet----------------------- Ethernet post_log_dash " Ethernet " ieth=eth0 -udhcpc --timeout=5 --retries=1 -n -i $ieth +udhcpc --timeout=5 --retries=2 -n -i $ieth post_log "$(ip addr show $ieth)" # -details -statistics - #setting up can interface ----------------- CANBus post_log_dash " CANBus " #current settings can be retrieved by the command below @@ -123,8 +122,8 @@ post_log "$(dmesg | grep -i wlan:)" # start the wpa_supplicant service - systemctl start wpa_supplicant@$iwlan.service post_log "start wpa_supplicant service" + systemctl start wpa_supplicant@$iwlan.service if [ $? -eq 0 ]; then post_log_pass "$POSTMSG_WIFI$POSTMSG_POSTFIX_PASSED [service]" # try to connect to WiFi @@ -191,7 +190,7 @@ # ----------------------------------------- Cloud post_log_dash " CloudSystem " post_log "$(ip addr show $iwlan)" # -details -statistics -post_log "$(ping device-api.diality.qa.kebormed.com -I $iwlan -c 3 -4)" +post_log "$(ping www.diality.com -I $iwlan -c 3 -4)" post_log_dash " CloudSync " if [ -d $HOME/$CLOUDSYNC_FOLDER ]; then @@ -224,13 +223,7 @@ DENALI_VERSION="$($HOME/$DENALI_BIN -v)" if [ -n "$DENALI_VERSION" ]; then post_log_pass "$($HOME/$DENALI_BIN -v)" # log UI Software version - # Note: - # The denali application needs to run with -E for the first time during manufacturing. - # Ther need to be an indication in the application itself to go to the manufacturing mode (-E). - # otherwise on each update it want to set to -E mode - # a good indication would be the Service Password, and it will be implemented soon. - # The -E has been removed for now from run.sh to prevent the situation mentioned above. - $HOME/$DENALI_BIN -Kauk -R # -E & # -K & + $HOME/$DENALI_BIN else post_log_fail "Unknown Applicaion Version" fi Index: scripts/setup.sh =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rf45f4093470d79f74c79f5a162bff598215b5dda --- scripts/setup.sh (.../setup.sh) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ scripts/setup.sh (.../setup.sh) (revision f45f4093470d79f74c79f5a162bff598215b5dda) @@ -127,6 +127,12 @@ update-rc.d $INITD_AUTOSTART defaults } +function manufacturingMode() { + if [ "$(grep $SETUP_ENABLE_MANUFACTURING_MODE $SETUP_CONF_FILE)" != "" ]; then + $HOME/$DENALI_BIN -E # don't use '&', we have to wait until user is done with UI + fi +} + function confirm_reboot() { read -p "ready to reboot? [y,n]" -n 1 -r CONFIRM if [ "$CONFIRM" == "y" ]; then @@ -144,6 +150,7 @@ diable_b2qt_services setup_denali enable_autostart + manufacturingMode } main "$1" "$2" Index: scripts/start.sh =================================================================== diff -u -r0e122c98700951af539d9f47c5578e26d640fcc7 -rf45f4093470d79f74c79f5a162bff598215b5dda --- scripts/start.sh (.../start.sh) (revision 0e122c98700951af539d9f47c5578e26d640fcc7) +++ scripts/start.sh (.../start.sh) (revision f45f4093470d79f74c79f5a162bff598215b5dda) @@ -136,6 +136,19 @@ exitConfirm $ERR_KILLPROMPT } +function manufacturingModePrompt() { + echo_star_comment + echo_star_message "Do you want to run in the Manufacturing Mode?" + echo_star_comment + read -p "Continue? [y,n]" -n 1 -r CONTINUE + if [ "$CONTINUE" == "y" ]; then + sshRun "echo "$SETUP_ENABLE_MANUFACTURING_MODE" > $SETUP_CONF_FILE" + echo_star_message "Set the setup in manufacturing mode" + else + echo_star_message "Continueing the setup in normal mode" + fi +} + function getDeviceIP() { while true; do validIP "$DST_IP" @@ -217,7 +230,7 @@ } function wipe_device() { - sshRun "rm -frd $(ls -A -I '.ssh')" + sshRun "rm -frd $(ls -A -I '.ssh' -I $SETUP_CONF_FILE)" } function main() { @@ -231,6 +244,7 @@ sshKeyCopy killPrompt + manufacturingModePrompt wipe_device setupBootupScripts