RAM_ROOT=/tmp/root
+export BACKUP_FILE=sysupgrade.tgz # file extracted by preinit
+
[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
libs() { ldd $* 2>/dev/null | sed -r 's/(.* => )?(.*) .*/\2/'; }
rmdir /tmp/new_root
return 1
fi
- mv "$1" "/tmp/new_root/sysupgrade.tgz"
+ mv "$1" "/tmp/new_root/$BACKUP_FILE"
umount /tmp/new_root
sync
rmdir /tmp/new_root
move_config() {
. /lib/functions.sh
+ . /lib/upgrade/common.sh
case "$(board_name)" in
wd,mybooklive)
if [ -b $BOOTPART ]; then
mkdir -p /boot
mount -t ext4 -o rw,noatime $BOOTPART /boot
- [ -f /boot/sysupgrade.tgz ] && mv -f /boot/sysupgrade.tgz /
+ [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
fi
;;
*)
#!/bin/sh
# Copyright (C) 2015 OpenWrt.org
+. /lib/upgrade/common.sh
+
BOOTPART=/dev/mmcblk0p1
move_config() {
insmod vfat
mkdir -p /boot
mount -t vfat -o rw,noatime $BOOTPART /boot
- [ -f /boot/sysupgrade.tgz ] && mv -f /boot/sysupgrade.tgz /
+ [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
fi
}
. /lib/imx6.sh
. /lib/functions.sh
+. /lib/upgrade/common.sh
move_config() {
local board=$(board_name)
apalis*)
if [ -b $(bootpart_from_uuid) ]; then
apalis_mount_boot
- [ -f /boot/sysupgrade.tgz ] && mv -f /boot/sysupgrade.tgz /
+ [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
umount /boot
fi
;;
mkdir /tmp/new_root
mount -t ext4 $loopdev /tmp/new_root && {
echo "Saving config to rootfs_data at position ${offset}."
- cp -v /tmp/sysupgrade.tgz /tmp/new_root/
+ cp -v "$CONF_TAR" /tmp/new_root/
umount /tmp/new_root
}
#!/bin/sh
# Copyright (C) 2015 OpenWrt.org
+. /lib/upgrade/common.sh
+
RECOVERY_PART=/dev/mmcblk0p1
move_config() {
insmod vfat
mkdir -p /recovery
mount -o rw,noatime $RECOVERY_PART /recovery
- [ -f /recovery/sysupgrade.tgz ] && mv -f /recovery/sysupgrade.tgz /
+ [ -f "/recovery/$BACKUP_FILE" ] && mv -f "/recovery/$BACKUP_FILE" /
umount /recovery
fi
}
esac
mkdir -p /boot
mount -o rw,noatime "/dev/$partdev" /boot
- [ -f /boot/sysupgrade.tgz ] && mv -f /boot/sysupgrade.tgz /
+ [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
umount /boot
fi
}
#
preinit_mount_syscfg() {
-
. /lib/functions.sh
+ . /lib/upgrade/common.sh
case $(board_name) in
linksys,caiman|linksys,cobra|linksys,mamba|linksys,rango|linksys,shelby|linksys,venom)
fi
mkdir /tmp/syscfg
mount -t ubifs ubi1:syscfg /tmp/syscfg
- [ -f /tmp/syscfg/sysupgrade.tgz ] && {
+ [ -f "/tmp/syscfg/$BACKUP_FILE" ] && {
echo "- config restore -"
cd /
- mv /tmp/syscfg/sysupgrade.tgz /tmp
- tar xzf /tmp/sysupgrade.tgz
- rm -f /tmp/sysupgrade.tgz
+ mv "/tmp/syscfg/$BACKUP_FILE" /tmp
+ tar xzf "/tmp/$BACKUP_FILE"
+ rm -f "/tmp/$BACKUP_FILE"
sync
}
;;
#
preinit_mount_udpu() {
-
. /lib/functions.sh
+ . /lib/upgrade/common.sh
case $(board_name) in
methode,udpu)
if [ -b "${mmcdev}p4" ]; then
mkdir /misc
mount -t f2fs ${mmcdev}p4 /misc
- [ -f "/misc/sysupgrade.tgz" ] && {
+ [ -f "/misc/$BACKUP_FILE" ] && {
echo "- Restoring configuration files -"
- tar xzf /misc/sysupgrade.tgz -C /
- rm -f /misc/sysupgrade.tgz
+ tar xzf "/misc/$BACKUP_FILE" -C /
+ rm -f "/misc/$BACKUP_FILE"
sync
}
[ -f "/misc/firmware/recovery.itb" ] && {
}
platform_copy_config_linksys() {
- cp -f /tmp/sysupgrade.tgz /tmp/syscfg/sysupgrade.tgz
+ cp -f "$CONF_TAR" /tmp/syscfg/
sync
}
platform_copy_config_uDPU() {
# Config is saved on the /misc partition and copied on the rootfs after the reboot
- if [ -f "/tmp/sysupgrade.tgz" ]; then
- cp -f /tmp/sysupgrade.tgz /misc
+ if [ -f "$CONF_TAR" ]; then
+ cp -f "$CONF_TAR" /misc
sync
fi
}
move_config() {
. /lib/functions.sh
+ . /lib/upgrade/common.sh
case "$(board_name)" in
erlite)
mount -t vfat /dev/sda1 /mnt
- [ -f /mnt/sysupgrade.tgz ] && mv -f /mnt/sysupgrade.tgz /
+ [ -f "/mnt/$BACKUP_FILE" ] && mv -f "/mnt/$BACKUP_FILE" /
umount /mnt
;;
esac
if export_bootdevice && export_partdevice partdev 1; then
if mount -t vfat -o rw,noatime "/dev/$partdev" /mnt; then
- if [ -f /mnt/sysupgrade.tgz ]; then
- mv -f /mnt/sysupgrade.tgz /
+ if [ -f "/mnt/$BACKUP_FILE" ]; then
+ mv -f "/mnt/$BACKUP_FILE" /
fi
umount /mnt
fi
if export_bootdevice && export_partdevice partdev 1; then
if mount -t vfat -o rw,noatime "/dev/$partdev" /mnt; then
- if [ -f /mnt/sysupgrade.tgz ]; then
- mv -f /mnt/sysupgrade.tgz /
+ if [ -f "/mnt/$BACKUP_FILE" ]; then
+ mv -f "/mnt/$BACKUP_FILE" /
fi
umount /mnt
fi
if export_bootdevice && export_partdevice partdev 1; then
mkdir -p /boot
if mount -o ro,noatime "/dev/$partdev" /boot; then
- if [ -f /boot/sysupgrade.tgz ]; then
+ if [ -f "/boot/$BACKUP_FILE" ]; then
mount /boot -o remount,rw,noatime
- mv -f /boot/sysupgrade.tgz /
+ mv -f "/boot/$BACKUP_FILE" /
fi
umount /boot
rm -fR /boot
if export_bootdevice && export_partdevice partdev 1; then
mkdir -p /boot
mount -t ext4 -o rw,noatime "/dev/$partdev" /boot
- if [ -f /boot/sysupgrade.tgz ]; then
- mv -f /boot/sysupgrade.tgz /
+ if [ -f "/boot/$BACKUP_FILE" ]; then
+ mv -f "/boot/$BACKUP_FILE" /
fi
mount --bind /boot/boot /boot
fi