Skip to content

Instantly share code, notes, and snippets.

@Leo-PL
Created January 11, 2020 12:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Leo-PL/69dccbeffc02b1eb19cfba80efdc113c to your computer and use it in GitHub Desktop.
Save Leo-PL/69dccbeffc02b1eb19cfba80efdc113c to your computer and use it in GitHub Desktop.
OpenWrt package autoinstallation script after upgrade
#!/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
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}.
#!/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