29 lines
880 B
Bash
Executable File
29 lines
880 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -xeo pipefail
|
|
|
|
ssh-copy-id root@${OPENWRT_DEVICE}
|
|
|
|
TARGET_ARCH=$(ssh root@${OPENWRT_DEVICE} source /etc/os-release \&\& echo \${OPENWRT_BOARD:-\$LEDE_BOARD})
|
|
|
|
FIRMWARE_FILE=bin/${OPENWRT_VERSION}/${TARGET_ARCH}/${OPENWRT_PROFILE}/openwrt-*-squashfs-factory.img
|
|
FIRMWARE_FILE=${CUSTOM_FIRMWARE_FILE:-$FIRMWARE_FILE}
|
|
|
|
NOW=$(date +%Y-%m-%d)
|
|
BACKUP_FILENAME="backup_${OPENWRT_DEVICE}_${NOW}.tar.gz"
|
|
|
|
ssh root@${OPENWRT_DEVICE} \
|
|
rm -f "/tmp/${BACKUP_FILENAME}" \
|
|
\&\& sysupgrade -b "/tmp/${BACKUP_FILENAME}"
|
|
|
|
mkdir -p tmp/backups
|
|
|
|
scp "root@${OPENWRT_DEVICE}:/tmp/${BACKUP_FILENAME}" ./tmp/backups/
|
|
|
|
ssh root@${OPENWRT_DEVICE} \
|
|
mkdir -p /tmp/firmwares \
|
|
\&\& rm /tmp/firmwares/* \|\| exit 0;
|
|
|
|
scp $FIRMWARE_FILE root@${OPENWRT_DEVICE}:/tmp/firmwares/
|
|
|
|
ssh root@${OPENWRT_DEVICE} sysupgrade --force -p -v -n "/tmp/firmwares/$(basename $FIRMWARE_FILE)" |