Freifunk/Flashscript: Unterschied zwischen den Versionen

Aus Wiki CCC Göttingen
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 2: Zeile 2:
#!/bin/sh
#!/bin/sh


#FIRMWARE="gluon-ffhi-0.4-experimental-20150328-tp-link-tl-wr1043n-nd-v2.bin"
# FIRMWARE="gluon-ffhi-0.4-experimental-20150328-tp-link-tl-wr1043n-nd-v2.bin"
#FIRMWARE=gluon-ffhi-wr1043.bin
# FIRMWARE=gluon-ffhi-wr1043.bin
FIRMWARE=gluon-ffgoe-0.6.5-tp-link-tl-wr1043n-nd-v2.bin
FIRMWARE=gluon-ffgoe-0.6.5-tp-link-tl-wr1043n-nd-v2.bin


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


gluon()
configure_gluon()
{
{
curl -v 'http://192.168.1.1/cgi-bin/luci' \
  curl 'http://192.168.1.1/cgi-bin/luci' \
-H 'Origin: http://192.168.1.1' \
  -H 'Origin: http://192.168.1.1' \
-H 'Accept-Encoding: gzip, deflate' \
  -H 'Accept-Encoding: gzip, deflate' \
-H 'Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4' \
  -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 '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 '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 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' \
-H 'Cache-Control: max-age=0' \
  -H 'Cache-Control: max-age=0' \
-H 'Referer: http://192.168.1.1/cgi-bin/luci' \
  -H 'Referer: http://192.168.1.1/cgi-bin/luci' \
-H 'Connection: keep-alive' \
  -H 'Connection: keep-alive' \
--compressed \
  --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'
  --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
  sleep 1


#curl -v 'http://192.168.1.1/cgi-bin/luci/gluon-config-mode/reboot'
  curl -v 'http://192.168.1.1/cgi-bin/luci/gluon-config-mode/reboot' \
 
curl -v 'http://192.168.1.1/cgi-bin/luci/gluon-config-mode/reboot' \
-H 'Origin: http://192.168.1.1' \
-H 'Origin: http://192.168.1.1' \
-H 'Connection: keep-alive' \
-H 'Connection: keep-alive' \
Zeile 41: Zeile 53:
}
}


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


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


echo "Happy Flashing fuer '$NAME'"


echo Warte auf TP-Link GUI
echo Warten auf TP-Link  
wait_for_ping 192.168.0.1
wait_for_ping 192.168.0.1
sleep 2
sleep 5
 
echo Sende Firmware
echo Sende Firmware
flash
flash_firmware
sleep 2


echo Warte auf Gluon GUI
echo Warten auf Gluon  
wait_for_ping 192.168.1.1
wait_for_ping 192.168.1.1
sleep 2
sleep 5
 
echo Konfiguriere Gluon
echo Konfiguriere Gluon
gluon
configure_gluon
 
 
</source>
</source>

Version vom 10. Juni 2015, 09:17 Uhr

<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>