#!/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="251 250 72 74 233 224 225 222 230 234 232 226 239 235 238 223 227 237 229 231 236 228 242 249 247 241 245 248 221 243 220 246 240 244 " # adhoc: # LIST='251 74 224 222 230 234 232 226 238 223 236 228 242 248 220 246 240 244 ' # ap: # LIST='250 72 233 225 239 235 227 237 229 231 249 247 241 245 221 243 ' # special_git: '' # LIST='' # special_hardware: 'Ubiquiti Bullet M' # LIST='' ERROR= [ -n "$1" ] && LIST="$1" # we can see with "ls -l $TMPDIR/COPYTEST", if scp-ing a small file works #mkdir -p $TMPDIR/COPYTEST && echo "created dir $TMPDIR/COPYTEST"; for NODE in $LIST; do touch $TMPDIR/COPYTEST/$NODE; done I=0; for NODE in $LIST;do I=$(( $I + 1 )); done; ALL=$I; I=0 for NODE in $LIST ;do { eval "$( _ipsystem get $NODE )"; I=$(( $I + 1 )) # WIFIADR=192.168.\$NODE.1 # for I in $(seq 1 256); do ip a del 10.10.$I.130/25 dev $LANDEV; done # ip a a 10.10.${NODE}.130/25 dev $LANDEV; WIFIADR=$LANADR echo "trying node \"$NODE @${WIFIADR}\", which is $I/$ALL ($(( ($I * 100) / $ALL ))%)" # case "$( uci get wireless.@wifi-iface[0].ssid )" in *[0-9]) /sbin/uci set wireless.@wifi-iface[0].ssid='Network $NODE (maintenance)'; /sbin/uci commit wireless; /sbin/wifi ;; esac # ssh -i /etc/dropbear/dropbear_dss_host_key "${WIFIADR}" "pidof crond || /etc/init.d/*crond_fff+ start" || { # ERROR="$ERROR $NODE" # } # if _tool remote $WIFIADR command 1 YOURPASS 'echo >>$SCHEDULER_IMPORTANT "_firmware update_pmu"'; then # if scp -p -i /etc/dropbear/dropbear_dss_host_key $TMPDIR/fw ${WIFIADR}:/tmp ; then # ping -c 5 $WIFIADR; _tool remote $WIFIADR startshell if scp -p -i /etc/dropbear/dropbear_dss_host_key "script.sh" "${WIFIADR}:$TMPDIR/.autorun"; then : # watch_sysupgrade else ERROR="$ERROR $NODE" fi # else # ERROR="$ERROR $NODE" # fi } done && rm script.sh test -n "$ERROR" && echo "please enter sh ./tools.txt '$ERROR'"