Skip to content

Instantly share code, notes, and snippets.

@BigNerd95
Last active May 11, 2020 18:20
Show Gist options
  • Save BigNerd95/0b764e9bc950ace4b05526a2f4a260d0 to your computer and use it in GitHub Desktop.
Save BigNerd95/0b764e9bc950ace4b05526a2f4a260d0 to your computer and use it in GitHub Desktop.
Fast update scripts for LEDE/OpenWRT
#!/bin/sh
# run this script on ROUTER
ipaddr=$1
# recv checksum
check=$(nc $ipaddr 1235)
echo "Received checksum: $check"
# recv firmware
nc $ipaddr 1234 > /tmp/fw.bin
mycheck=$(md5sum /tmp/fw.bin | cut -d ' ' -f 1)
echo "Computed checksum: $mycheck"
if [ "$check" == "$mycheck" ]
then
echo "OKAY, I can upgrade"
sysupgrade /tmp/fw.bin
else
echo "ERROR, I cannot upgrade"
fi
#!/bin/sh
# run this script on PC
firmware=$1
check=$(md5sum "$firmware" 2>/dev/null)
if [ $? != 0 ]
then
echo "Please pass a valid file"
exit
fi
check=$(echo "$check" | cut -d ' ' -f 1)
echo "Sending $firmware"
echo "Checksum: $check"
# send checksum
echo "$check" | nc -l -p 1235 -q 0
# send firmware
nc -l -p 1234 -q 0 < "$firmware"
@BigNerd95
Copy link
Author

BigNerd95 commented Oct 20, 2017

Usage

On PC

$ ./send_fw.sh bin/targets/generic/lede-squashfs-sysupgrade.bin 

Sending lede-squashfs-sysupgrade.bin
Checksum: 2bb877c0516144fde2e3966e7980ec9f

On Router

$ ./recv_fw.sh 192.168.0.2

Received checksum: 2bb877c0516144fde2e3966e7980ec9f
Computed checksum: 2bb877c0516144fde2e3966e7980ec9f
OKAY, I can upgrade
Image metadata not found
Saving config files...
killall: watchdog: no process killed
Commencing upgrade. All shell sessions will be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment