Freifunk/Flashscript

Aus Wiki CCC Göttingen
Zur Navigation springen Zur Suche springen

<source lang=bash>

  1. !/bin/sh
  1. FIRMWARE="gluon-ffhi-0.4-experimental-20150328-tp-link-tl-wr1043n-nd-v2.bin"
  2. FIRMWARE=gluon-ffhi-wr1043.bin

FIRMWARE=gluon-ffgoe-0.6.5-tp-link-tl-wr1043n-nd-v2.bin

  1. NAME=ccc-geismar-land
  2. LAENGE=9.949756264686584
  3. BREITE=51.52233597559833
  4. CONTACT="freifunk@example.com"

BREITE=$1 LAENGE=$2 NAME=$3

configure_gluon() {

  curl 'http://192.168.1.1/cgi-bin/luci' \
  -H 'Origin: http://192.168.1.1' \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36' \
  -H 'Content-Type: multipart/form-data; boundary=----ffgoe-4711' \
  -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' \
  -H 'Cache-Control: max-age=0' \
  -H 'Referer: http://192.168.1.1/cgi-bin/luci' \
  -H 'Connection: keep-alive' \
  --compressed \
  --data-binary \

$'------ffgoe-4711\r\nContent-Disposition: form-data; name="cbi.submit"\r\n\r\n1\r\n'\ $'------ffgoe-4711\r\nContent-Disposition: form-data; name="cbid.wizard.1._hostname"\r\n\r\n'"$NAME"$'\r\n'\ $'------ffgoe-4711\r\nContent-Disposition: form-data; name="cbi.cbe.wizard.1._meshvpn"\r\n\r\n1\r\n'\ $'------ffgoe-4711\r\nContent-Disposition: form-data; name="cbid.wizard.1._meshvpn"\r\n\r\n1\r\n'\ $'------ffgoe-4711\r\nContent-Disposition: form-data; name="cbi.cbe.wizard.1._limit_enabled"\r\n\r\n1\r\n'\ $'------ffgoe-4711\r\nContent-Disposition: form-data; name="cbi.cbe.wizard.1._location"\r\n\r\n1\r\n'\ $'------ffgoe-4711\r\nContent-Disposition: form-data; name="cbid.wizard.1._location"\r\n\r\n1\r\n'\ $'------ffgoe-4711\r\nContent-Disposition: form-data; name="cbid.wizard.1._latitude"\r\n\r\n'"$BREITE"$'\r\n'\ $'------ffgoe-4711\r\nContent-Disposition: form-data; name="cbid.wizard.1._longitude"\r\n\r\n'"$LAENGE"$'\r\n'\ $'------ffgoe-4711\r\nContent-Disposition: form-data; name="cbid.wizard.1._contact"\r\n\r\n'"$CONTACT"$'\r\n'\ $'------ffgoe-4711--\r\n'

  sleep 1
  curl -v 'http://192.168.1.1/cgi-bin/luci/gluon-config-mode/reboot' \

-H 'Origin: http://192.168.1.1' \ -H 'Connection: keep-alive' \ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/600.6.3 (KHTML, like Gecko) Version/8.0.6 Safari/600.6.3' \ -H 'Accept-Language: en-us' \ -H 'Referer: http://192.168.1.1/cgi-bin/luci' \ -H 'Accept-Encoding: gzip, deflate'

}

flash_firmware() {

  curl \
  --user admin:admin \
  --user-agent 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0' \
  --referer 'http://192.168.0.1/userRpm/SoftwareUpgradeRpm.htm' \
  --form "Filename=@$FIRMWARE" -F 'Upgrade=Upgrade' \
  http://192.168.0.1/incoming/Firmware.htm
  sleep 5
  curl \
  --max-time 2 \
  --user admin:admin \
  --user-agent 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0' \
  --referer 'http://192.168.0.1/incoming/Firmware.htm' \
  http://192.168.0.1/userRpm/FirmwareUpdateTemp.htm

}

wait_for_ping () {

  ip=$1
  echo -n "ping $ip "
  while true; do
     echo -n "."
     ping -c 1 -W 5 $ip  | grep '1 packets received'
     if test "$?" = "0"; then
        echo
        echo Es pingt.
        return
     fi
     sleep 3
  done

}

echo "Happy Flashing fuer '$NAME'"

echo Warten auf TP-Link wait_for_ping 192.168.0.1 sleep 5

echo Sende Firmware flash_firmware

echo Warten auf Gluon wait_for_ping 192.168.1.1 sleep 5

echo Konfiguriere Gluon configure_gluon


</source>