Created
January 11, 2020 12:43
-
-
Save Leo-PL/69dccbeffc02b1eb19cfba80efdc113c to your computer and use it in GitHub Desktop.
OpenWrt package autoinstallation script after upgrade
This file contains hidden or 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 | |
# Hotplug trigger script. Put this in /etc/hotplug.d/iface, and ensure this file is backed up over upgrade. | |
[ "$ACTION" = ifup ] || exit 0 | |
[ "$INTERFACE" = wan ] || exit 0 | |
logger -t package_autoinstall "Checking for package autoinstallation due to $ACTION of $INTERFACE ($DEVICE)" | |
cd /root | |
./package_autoinstall.sh |
This file contains hidden or 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
A simple script to reinstall defined packages after OpenWrt release upgrade. | |
After copying the scripts, make sure they are stored in the configuration backup, together with ${PACKAGE_LIST}. |
This file contains hidden or 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 | |
# Main script. Put this in your preferred, backed up location. I simply chose /root. | |
OPENWRT_RELEASE=$(grep DESCRIPTION /etc/openwrt_release | cut -d \' -f 2) | |
LAST_RELEASE=$(cat /root/saved_release) | |
PACKAGE_LIST=$(cat /root/default_packages) | |
if [ "${OPENWRT_RELEASE}" != "${LAST_RELEASE}" ] | |
then | |
logger -t package_autoinstall: "Releases differ. Attempting package installation." | |
opkg update && opkg install ${PACKAGE_LIST} | |
if [ $? ] | |
then | |
logger -t package_autoinstall "Installation succeeded. Updating release and restarting network." | |
echo ${OPENWRT_RELEASE} > /root/saved_release | |
rm -rf /tmp/opkg-lists | |
/etc/init.d/network restart | |
fi | |
else | |
logger -t package_autoinstall "Release matches. Skipping installation." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment