💋 Sync 2026-10-04 04:16:09

This commit is contained in:
github-actions[bot] committed 2026-10-04 04:16:09 +08:00
1 parent f6b2df73ec
commit f62992fd80
745 files changed
+212416 -1173

No files matched your search

@@ -0,0 +1,77 @@
#!/bin/sh
# Aggressive rebuild — matches source netwizard behaviour. Called only if user opts in.
MODE="$1"; LAN_IP="$2"; PPPOE_USER="$3"; PPPOE_PASS="$4"; WAN_IFACE="$5"
[ -z "$MODE" ] && MODE="dhcp"
[ -z "$LAN_IP" ] && LAN_IP="192.168.10.1"
BACKUP_DIR="/etc/config.bak.$(date +%s)"
mkdir -p "$BACKUP_DIR"
for f in network firewall dhcp wireless system wizard netwizard; do
[ -f /etc/config/$f ] && cp /etc/config/$f "$BACKUP_DIR/"
done
echo "Backup saved to $BACKUP_DIR"
if [ -z "$WAN_IFACE" ]; then
WAN_IFACE=$(uci -q get network.wan.device)
[ -z "$WAN_IFACE" ] && WAN_IFACE=$(ls /sys/class/net/ 2>/dev/null | grep -E '^(eth[01]|wan)' | head -n1)
[ -z "$WAN_IFACE" ] && WAN_IFACE="eth1"
fi
uci -q delete network.wan 2>/dev/null
uci -q delete network.wan6 2>/dev/null
uci -q delete network.lan6 2>/dev/null
WAN_IDX=$(uci show firewall | sed -n "s/^firewall\.@zone\[\([0-9]*\)\]\.name='wan'$/\1/p")
[ -n "$WAN_IDX" ] && uci -q delete firewall.@zone[$WAN_IDX] 2>/dev/null
if [ "$MODE" = "siderouter" ]; then
LAN_IDX=$(uci show firewall | sed -n "s/^firewall\.@zone\[\([0-9]*\)\]\.name='lan'$/\1/p")
[ -n "$LAN_IDX" ] && uci -q delete firewall.@zone[$LAN_IDX].masq 2>/dev/null
uci set network.lan=interface
uci set network.lan.proto='static'
uci set network.lan.ipaddr="$LAN_IP"
uci set network.lan.netmask='255.255.255.0'
else
uci set network.wan=interface
uci set network.wan.device="$WAN_IFACE"
if [ "$MODE" = "pppoe" ]; then
uci set network.wan.proto='pppoe'
[ -n "$PPPOE_USER" ] && uci set network.wan.username="$PPPOE_USER"
[ -n "$PPPOE_PASS" ] && uci set network.wan.password="$PPPOE_PASS"
else
uci set network.wan.proto='dhcp'
fi
uci set network.wan6=interface
uci set network.wan6.device="@wan"
uci set network.wan6.proto='dhcpv6'
uci add firewall zone >/dev/null
uci set firewall.@zone[-1].name='wan'
uci set firewall.@zone[-1].input='REJECT'
uci set firewall.@zone[-1].output='ACCEPT'
uci set firewall.@zone[-1].forward='REJECT'
uci set firewall.@zone[-1].masq='1'
uci set firewall.@zone[-1].mtu_fix='1'
uci add_list firewall.@zone[-1].network='wan'
uci add_list firewall.@zone[-1].network='wan6'
uci add firewall forwarding >/dev/null
uci set firewall.@forwarding[-1].src='lan'
uci set firewall.@forwarding[-1].dest='wan'
uci set network.lan.ipaddr="$LAN_IP"
uci set network.lan.netmask='255.255.255.0'
fi
uci -q commit network
uci -q commit firewall
uci -q commit dhcp
/etc/init.d/network restart >/dev/null 2>&1 &
sleep 2
/etc/init.d/firewall reload >/dev/null 2>&1 &
/etc/init.d/dnsmasq reload >/dev/null 2>&1 &
echo "Aggressive apply complete. Mode: $MODE, WAN: $WAN_IFACE, LAN: $LAN_IP"
echo "Backup: $BACKUP_DIR"
@@ -0,0 +1,45 @@
#!/bin/sh
# Regenerate nginx shortcut server blocks + dnsmasq domain entries from /etc/config/wizard shortcuts.
# Called after the user adds/removes a shortcut in the UI.
clean() {
local sec
for sec in $(uci -q show nginx 2>/dev/null | sed -n "s/^nginx\.\(_sc_[^=.]*\)=server$/\1/p"); do
uci -q delete nginx."$sec"
done
for sec in $(uci -q show dhcp 2>/dev/null | sed -n "s/^dhcp\.\(_sc_[^=.]*\)=domain$/\1/p"); do
uci -q delete dhcp."$sec"
done
}
process_one() {
local shortcut to_url lanaddr cfg="$1"
lanaddr="$(uci -q get network.lan.ipaddr | tr ' ' '\n' | head -n1)"
lanaddr="${lanaddr%%/*}"
[ -z "$lanaddr" ] && lanaddr="10.0.0.1"
config_get shortcut "$cfg" shortcut
config_get to_url "$cfg" to_url
[ -z "$shortcut" ] || [ -z "$to_url" ] && return 0
if [ -f /etc/nginx/uci.conf ]; then
uci -q set nginx._sc_$shortcut=server
uci -q set nginx._sc_$shortcut.server_name="$shortcut"
uci -q add_list nginx._sc_$shortcut.listen="80"
uci -q set nginx._sc_$shortcut.return="302 $to_url"
uci -q set dhcp._sc_$shortcut=domain
uci -q set dhcp._sc_$shortcut.name="$shortcut"
uci -q set dhcp._sc_$shortcut.ip="$lanaddr"
fi
}
clean
config_load wizard
config_foreach process_one shortcuts
uci -q commit nginx 2>/dev/null
uci -q commit dhcp 2>/dev/null
[ -x /etc/init.d/nginx ] && /etc/init.d/nginx reload >/dev/null 2>&1
[ -x /etc/init.d/dnsmasq ] && /etc/init.d/dnsmasq reload >/dev/null 2>&1
echo "Shortcuts applied."
@@ -0,0 +1,12 @@
#!/bin/sh
BACKUP_DIR="/etc/config.bak.$(date +%s)"
mkdir -p "$BACKUP_DIR"
COUNT=0
for f in network firewall dhcp wireless system wizard netwizard taskplan; do
if [ -f /etc/config/$f ]; then
cp /etc/config/$f "$BACKUP_DIR/"
COUNT=$((COUNT + 1))
fi
done
echo "Backed up $COUNT files to $BACKUP_DIR"
ls -1 "$BACKUP_DIR"
@@ -0,0 +1,2 @@
#!/bin/sh
ls -1d /etc/config.bak.* 2>/dev/null | sort -r
@@ -0,0 +1,23 @@
#!/bin/sh
DIR="$1"
[ -z "$DIR" ] && { echo "Usage: restore.sh <backup-dir>"; exit 1; }
[ ! -d "$DIR" ] && { echo "Directory not found: $DIR"; exit 1; }
SAFETY="/etc/config.bak.pre-restore.$(date +%s)"
mkdir -p "$SAFETY"
for f in "$DIR"/*; do
[ -f "$f" ] || continue
base=$(basename "$f")
[ -f "/etc/config/$base" ] && cp "/etc/config/$base" "$SAFETY/"
cp "$f" "/etc/config/$base"
done
for c in network firewall dhcp wireless wizard netwizard taskplan; do
uci -q commit $c 2>/dev/null
done
/etc/init.d/network reload >/dev/null 2>&1 &
/etc/init.d/firewall reload >/dev/null 2>&1 &
echo "Restored from $DIR"
echo "Previous state saved to $SAFETY"