mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-11 19:37:51 +08:00
🎉 Sync 2026-11-08 01:01:38
This commit is contained in:
1 parent
f7911ea0fb
commit
3d26c9667a
57 files changed
+4016
-1243
No files matched your search
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# easymesh-vlan-arm — arm the auto-rollback watchdog after applying VLAN changes
|
||||
|
||||
DELAY="${1:-90}"
|
||||
|
||||
# Respect the UI toggle
|
||||
if [ "$(uci -q get easymesh.config.vlan_safe_apply)" != "1" ]; then
|
||||
logger -t easymesh-vlan "safe apply disabled — not arming"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Snapshot the working config
|
||||
/usr/bin/easymesh-vlan-backup || exit 1
|
||||
|
||||
# Kill any previous watchdog
|
||||
if [ -f /tmp/easymesh-vlan-rollback.pid ]; then
|
||||
kill "$(cat /tmp/easymesh-vlan-rollback.pid)" 2>/dev/null
|
||||
fi
|
||||
|
||||
touch /tmp/easymesh-vlan-rollback.pending
|
||||
|
||||
(
|
||||
sleep "$DELAY"
|
||||
if [ -f /tmp/easymesh-vlan-rollback.pending ]; then
|
||||
logger -t easymesh-vlan "auto-rollback triggered after ${DELAY}s"
|
||||
/usr/bin/easymesh-vlan-restore
|
||||
rm -f /tmp/easymesh-vlan-rollback.pending
|
||||
else
|
||||
logger -t easymesh-vlan "auto-rollback cancelled"
|
||||
fi
|
||||
) &
|
||||
|
||||
echo $! > /tmp/easymesh-vlan-rollback.pid
|
||||
logger -t easymesh-vlan "armed auto-rollback (${DELAY}s)"
|
||||
exit 0
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# easymesh-vlan-backup — snapshot /etc/config/network before VLAN changes
|
||||
|
||||
BKDIR=/etc/easymesh
|
||||
BKFILE="$BKDIR/network.bak"
|
||||
|
||||
mkdir -p "$BKDIR"
|
||||
|
||||
if [ ! -f /etc/config/network ]; then
|
||||
logger -t easymesh-vlan "no /etc/config/network found, skipping backup"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp /etc/config/network "$BKFILE"
|
||||
date +%s > "$BKFILE.timestamp"
|
||||
|
||||
logger -t easymesh-vlan "backed up network config to $BKFILE"
|
||||
exit 0
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# easymesh-vlan-confirm — cancel the pending auto-rollback
|
||||
|
||||
if [ -f /tmp/easymesh-vlan-rollback.pid ]; then
|
||||
kill "$(cat /tmp/easymesh-vlan-rollback.pid)" 2>/dev/null
|
||||
fi
|
||||
|
||||
rm -f /tmp/easymesh-vlan-rollback.pending /tmp/easymesh-vlan-rollback.pid
|
||||
logger -t easymesh-vlan "auto-rollback cancelled by user"
|
||||
exit 0
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# easymesh-vlan-restore — restore network config from the last backup
|
||||
|
||||
BKFILE=/etc/easymesh/network.bak
|
||||
|
||||
if [ ! -f "$BKFILE" ]; then
|
||||
logger -t easymesh-vlan "no backup at $BKFILE — nothing to restore"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp "$BKFILE" /etc/config/network
|
||||
logger -t easymesh-vlan "restored network from $BKFILE, reloading"
|
||||
|
||||
# Reload network in the background so the current shell/SSH isn't killed
|
||||
( /etc/init.d/network reload ) &
|
||||
exit 0
|
||||
Reference in new issue
Block a user