Skip to content

Instantly share code, notes, and snippets.

@nicman23
Created April 21, 2018 06:34
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicman23/e10fa22d5f679dd77f9c4af34aefbbd0 to your computer and use it in GitHub Desktop.
Save nicman23/e10fa22d5f679dd77f9c4af34aefbbd0 to your computer and use it in GitHub Desktop.
Openwrt upgrade script
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
start_service() {
if [ -e /root/.upgrade ]
then exit
else touch /root/.upgrade
fi
after_upgrade
reboot
}
after_upgrade() {
opkg update
listold="$(cat /etc/pkgold.list)"
list="$(opkg list-installed | cut -f1 -d ' ')"
gsearch="\b$(echo $listold | sed -e 's/ /\\b\\\|\\b/g')\b"
for i in $list
do echo $i
done | grep -v "$gsearch" |
xargs opkg remove
for i in $listold $list
do echo $i
done | grep "$gsearch" |
sort |
uniq -u |
xargs opkg install
}
upgrade() {
opkg list-installed | cut -f1 -d ' ' > /etc/pkgold.list
cd /tmp
wget http://downloads.openwrt.org/snapshots/targets/ar71xx/generic/openwrt-ar71xx-generic-archer-c7-v4-squashfs-sysupgrade.bin
sysupgrade -c openwrt-ar71xx-generic-archer-c7-v4-squashfs-sysupgrade.bin
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment