Skip to content

Commit

Permalink
fix: check if overlayfs is available before rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
MakiseKurisu committed Jul 24, 2024
1 parent c6dda9f commit 4b11c16
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion openwrt/config_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ _unregister_script() {

_rollback() {
rm -rf /overlay/upper.dead

if ! grep -q overlayfs /proc/mounts
then
echo "no overlayfs found but rollback is still requested. manual recovery needed" >&2
trap '' EXIT
exit 1
fi

mv /overlay/upper /overlay/upper.dead
# this should never fail, unless something *else* is also mucking
# with overlayfs state.
Expand Down Expand Up @@ -40,7 +48,10 @@ _prepare_apply() {
exit 1
fi

if ! rm -rf /overlay/upper.prev/ \
if ! grep -q overlayfs /proc/mounts
then
log "no overlayfs found. rollback will not be possible"
elif ! rm -rf /overlay/upper.prev/ \
|| ! cp -al /overlay/upper/ /overlay/upper.prev/ \
|| ! rm -rf /overlay/upper.prev/etc/ \
|| ! cp -a /overlay/upper/etc/ /overlay/upper.prev/
Expand Down

0 comments on commit 4b11c16

Please sign in to comment.