Created
July 3, 2026 00:50
-
-
Save monosoul/1bd487677eb0461c840e81de8f459797 to your computer and use it in GitHub Desktop.
Script for automated extroot restoration after upgrade on OpenWRT 25.12
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
| # Save as /etc/uci-defaults/90-extroot-restore | |
| # then put it into /etc/sysupgrade.conf | |
| UUID="$(uci -q get fstab.extroot.uuid)" | |
| DIR="$(uci -q get fstab.extroot.target)" | |
| DEV="$(block info | sed -n -e "/${UUID}/s/:.*$//p")" | |
| if [ -n "${UUID}" ] \ | |
| && [ -n "${DEV}" ] \ | |
| && [ ! -e /etc/extroot-restore ] \ | |
| && ! grep -q -e "^${DEV}[[:space:]]" /proc/mounts \ | |
| && lock -n /var/lock/extroot-restore | |
| then | |
| mkdir -p /mnt | |
| if touch /etc/extroot-restore \ | |
| && grep -q -e "[[:space:]]${DIR}[[:space:]]" /etc/mtab \ | |
| && mount "${DEV}" /mnt | |
| then | |
| BAK="$(mktemp -d -p /mnt -t bak.XXXXXX)" | |
| mv -f /mnt/etc /mnt/upper "${BAK}" 2>/dev/null | |
| cp -f -a "${DIR}"/. /mnt | |
| umount "${DEV}" | |
| fi | |
| lock -u /var/lock/extroot-restore | |
| reboot | |
| fi | |
| exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment