#!/bin/sh . /tmp/loader cat >script.sh <>\$SCHEDULER_IMPORTANT "_firmware check_forced_upgrade" # else # rm $TMPDIR/fw # fi # } # _firmware update_pmu testing # uci set wireless.@wifi-iface[0].ssid="Hotel Berlin \$( uci get system.@profile[0].nodenumber )"; uci commit wireless # sed -i "s/'etx_ff'/'etx_ffeth'/" /etc/config/olsrd; echo 0 >/var/run/kalua/STATS_OLSR_RESTARTS # echo 'autorun' >/var/run/kalua/CRON_OVERLOAD # while :; do test \$(date +%M) = 44 && break; sleep 1; done; uci set wireless.radio0.channel=11; wifi; sleep 60 # rm /var/run/kalua/CRON_OVERLOAD # uci set olsrd.@meta[0].hnaslave=1; uci commit olsrd # uci set olsrd.@olsrd[0].LinkQualityAlgorithm=etx_ffeth # uci set olsrd.@Interface[0].Mode=ether; uci set olsrd.@Interface[1].Mode=mesh; uci commit olsrd # uname -a | grep -Fq " 3.14.29 " || { # echo >\$SCHEDULER_IMPORTANT "_firmware check_forced_upgrade" # _firmware update_pmu testing # _watch monitoring # } # . $TMPDIR/loader; [ "\$( _system uptime min )" -gt 120 ] && reboot # touch "$TMPDIR/START_SYSUPGRADE" # rm "/etc/tarball_last_applied_hash" # scheduler -a ". $TMPDIR/loader; _firmware update_pmu testing" # scheduler -a "cron.upgrade_packages" # scheduler -a "cron.monitoring send_alive_message" # starts scp-ing a small file to originator/HNA, just for checking ssh-thrusting works # NN="\$( nvram get fff_node_number )";nvram get wan_hostname >$TMPDIR/NN;. $TMPDIR/loader; sleep "\$( _math random_integer 3 30 )"; scp -i /etc/dropbear/dropbear_dss_host_key $TMPDIR/NN $WIFIADR:$TMPDIR/COPYTEST/\$NN;rm $TMPDIR/NN EOF chmod +x script.sh && grep -v ^# script.sh | sed -e 's/^[ ]*//g' -e 's/^[ ]*//g' -e '/^$/d' echo "really upload this file? press ENTER to go or CTRL+C to cancel";read KEY ping_failed_10times() { local i n=0 for i in 0 1 2 3 4 5 6 7 8 9; do if ping -qc 1 "$1" >/dev/null; then sleep 1; else n=$(( $n +1 )); fi; done test $n -eq 10 } uptime_in_seconds() { cut -d. -f1 /proc/uptime } uptime_diff() { echo $(( $(uptime_in_seconds) - $1 )) } watch_sysupgrade() { # fixme - node can reboot before sysupgrading starts, so detect reboot local state t2 t1=$( uptime_in_seconds ) while true; do { case "$state" in sysupgrade_started) if ping_failed_10times $WIFIADR; then echo "waiting for appearing of node $WIFIADR" else echo "node $WIFIADR appeared: sysupgrade successful in $(uptime_diff $t1)s - $(date)" break fi ;; *) if ping_failed_10times $WIFIADR; then state="sysupgrade_started"; t2=$( uptime_in_seconds ) echo "node $WIFIADR disappeared, sysupgrade started: $(date)" else echo "waiting since $(uptime_diff $t1)s for disappearing of node $WIFIADR (ping ok)" fi ;; esac } done } # all nodes: LIST="180 171 175 200 183 201 173 170 171 169 175 172 200 191 183 174 201 182 173 199 170 163 169 160 172 178 191 154 174 161 182 199 163 160 178 154 161 155 158