Last active
May 11, 2020 18:20
-
-
Save BigNerd95/0b764e9bc950ace4b05526a2f4a260d0 to your computer and use it in GitHub Desktop.
Fast update scripts for LEDE/OpenWRT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
On PC
On Router