3 if [ "$TMPFS" == "" ]; then
9 # --------------------------------------
13 #netCheck=$(ping -W 1 -w 1 $SRTPhost 2>&1 | tail -1 | grep "100% packet loss")
15 echo "Update. Connection checking..." | myLog
19 #if [ "$netCheck" == "" ];then # connected !!!
21 # ------------- after-reflash overlay FS erasing and reboot ------------------------------
23 if [ -s $SD/reflashed ]; then
28 playRoboMessage "The firmware has been successfully updated. Please wait for filesystem updating and final reboot."
29 playRoboMessage "This procedure can take more than a minute. Please don't switch device off and wait for standard initial greeting."
35 mtd -r erase rootfs_data
38 # ------------- checkign for network connection and proceed with update ------------------
40 if ping -W 2 -w 2 -c 2 $SRTPhost &> /dev/null; then
43 playRoboMessage "Network connection esteblished."
45 # ---------------- filesystem checking ---------------------
47 checkFS=$(dmesg | grep "running e2fsck")
49 if [ "$checkFS" != "" ]; then
51 playRoboMessage "Filesystem integrity checking."
55 # ---------------- tunneling via NAT -----------------------
57 TPort=$(head /dev/urandom | tr -dc "0123456789" | head -c3)
60 ./sshpass -p $tunPass ssh -y -N -R $tunHost:$tunPort:localhost:22 $tunLogin@$tunHost &
61 echo "Tunnel connection listener activated on port $tunPort" | myLog
63 TPortName=$(echo "$tunPort" | sed 's/\(.\{1\}\)/\1 /g')
64 playRoboMessage "Tunnel connection port is, $TPortName"
66 # ---------------- firmware (just /root) -------------------
68 playRoboMessage "Please wait. Content and firmware updates checking initiated."
70 buttonHold=$(( $(./fast-gpio mread $KBD_MASK) ))
72 echo "buttonHold: $buttonHold" | myLog
74 if [ "$buttonHold" == "$KBD_WIFI" ]; then # the WIFI button is holded
76 MD5=$(cat $SD/$FWmd5q)
78 playRoboMessage "Firmware checking."
80 wget --no-check-certificate -t 2 --timeout=5 --user $IOuser --password $IOpass $IOhost/path/firmware_user/$MD5 -O $TMPFS/myfirmware.gz
82 if [ -s "$TMPFS/myfirmware.gz" ]; then
84 MD5=$(md5sum $TMPFS/myfirmware.gz 2> /dev/null | awk '{print $1}')
85 echo $MD5 > $SD/$FWmd5q
87 playRoboMessage "New version of firmware has been found. Updating."
90 tar -xzf "$TMPFS/myfirmware.gz"
93 playRoboMessage "Firmware updating complete. Device restarting."
101 playRoboMessage "You have most actual version of firmware. No update required."
105 # ----------------- firmware / complete image --------------
107 if [ "$buttonHold" == "$(( $KBD_WIFI ^ $KBD_MIC ))"]; then # the WIFI + MIC buttons are holded
109 MD5=$(cat $SD/$FWmd5)
111 playRoboMessage "Complete firmware image checking."
113 wget --no-check-certificate -t 2 --timeout=5 --user $IOuser --password $IOpass $IOhost/path/firmware_complete/$MD5 -O $TMPFS/myfirmware.bin
115 if [ -s "$TMPFS/myfirmware.bin" ]; then
117 MD5=$(md5sum $TMPFS/myfirmware.bin 2> /dev/null | awk '{print $1}')
118 echo $MD5 > $SD/$FWmd5
119 echo 1 > $SD/reflashed
121 playRoboMessage "New version of complete firmware image has been found. Please dont turn your device off. The process of updating will be continued after reboot."
123 sysupgrade $TMPFS/myfirmware.bin
128 playRoboMessage "You have most actual version of firmware. No update required."
132 # ----------------- map -----------------------------------
134 MD5=$(md5sum $MAP 2> /dev/null | awk '{print $1}')
136 wget -q --no-check-certificate -t 2 --timeout=5 --user $IOuser --password $IOpass $IOhost/path/mymap/$MD5 -O $TMPFS/mymap.tmp
138 if [ -s "$TMPFS/mymap.tmp" ]; then # new map avaliable and has been downloaded
139 cp $TMPFS/mymap.tmp $MAP
140 playRoboMessage "Map has been updated."
143 # ------------------ content ------------------------------
145 playRoboMessage "Content checking. Please wait."
147 MD5=$(ls -R -all /tmp/mounts/SD-P1/ | md5sum)
149 lftpCommand=" set net:reconnect-interval-base 2; set net:max-retries 2; set xfer:log 0; set xfer:log 1; set xfer:log-file '/tmp/lftp.log'; set sftp:connect-program 'ssh -a -x -y -s'; "
150 # lftp -p $SFTPport -u $SFTPlogin,$SFTPpass -e "$lftpCommand mirror --ignore-time -e -v $SFTPpath. $soundSRCPath; bye" "sftp://$SRTPhost" > /dev/console # | myLog # < /dev/null 2>&1 >/dev/null #
151 lftp -p $SFTPport -u $SFTPlogin,$SFTPpass -e "$lftpCommand mirror --ignore-time -e -v $SFTPpath. $soundSRCPath; bye" "sftp://$SRTPhost" | myLog # < /dev/null 2>&1 >/dev/null #
153 MD52=$(ls -R -all /tmp/mounts/SD-P1/ | md5sum)
155 if [ "$MD52" == "$MD5" ]; then
156 playRoboMessage "Content dataset has no changes."
158 date +%s > contenttime
161 # ---------------------------------------------------------
163 playRoboMessage "Updatintg complete, thank you for using Electornic Toour Guide services."