Добавить bkp_uci.sh
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
ROUTER_HOST="${ROUTER_HOST}"
|
||||
ROUTER_USER="${ROUTER_USER}"
|
||||
ROUTER_PASS="${ROUTER_PASS}"
|
||||
|
||||
ROUTER_USER=root
|
||||
ROUTER_HOST=172.16.11.7
|
||||
ROUTER_PASS=556667777
|
||||
|
||||
|
||||
BACKUP_NAME="openwrt-backup-$(date +%F).tar.gz"
|
||||
|
||||
echo "[*] Creating backup on router..."
|
||||
|
||||
sshpass -p "$ROUTER_PASS" ssh -o StrictHostKeyChecking=no $ROUTER_USER@$ROUTER_HOST << 'EOF'
|
||||
# Create OpenWRT uci-defaults file for image builder
|
||||
target=$(sed -n 1p /etc/opkg/distfeeds.conf | cut -d'/' -f8)
|
||||
soc=$(sed -n 1p /etc/opkg/distfeeds.conf | cut -d'/' -f9)
|
||||
arch=$(sed -n 2p /etc/opkg/distfeeds.conf | cut -d'/' -f8)
|
||||
model=$(cat /tmp/sysinfo/model)
|
||||
profile=$(cat /tmp/sysinfo/board_name | sed 's/,/_/')
|
||||
#script="/tmp/99-custom"
|
||||
echo "#profile = $profile"
|
||||
echo "#target = $target"
|
||||
echo "#soc = $soc"
|
||||
echo "#arch = $arch"
|
||||
echo "#$model custom default settings"
|
||||
|
||||
echo #----------------------------------------------------
|
||||
echo #Generating cmd for install pkg
|
||||
echo #----------------------------------------------------
|
||||
|
||||
grep -A3 "Package:" /usr/lib/opkg/status | awk '
|
||||
/Package:/ { pkg=$2 }
|
||||
/Status:/ {
|
||||
if ($0 ~ /user installed/) {
|
||||
print "opkg install " pkg
|
||||
}
|
||||
}'
|
||||
|
||||
|
||||
|
||||
echo #----------------------------------------------------
|
||||
echo #Generating custom default file for $model
|
||||
echo #----------------------------------------------------
|
||||
echo "uci -q batch << EOI"
|
||||
for section in $(uci show 2>/dev/null | awk -F. '{print $1}' | sort -u); do
|
||||
uci show "$section" | awk -F. '{print "set "$0}'
|
||||
echo "commit $section"
|
||||
done
|
||||
echo "EOI"
|
||||
# >> "$script"
|
||||
#chmod 755 "$script"
|
||||
#echo "Created $script".
|
||||
#echo Now transfer the file to the 'files/etc/uci-defaults/' folder in your image builder directory.
|
||||
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user