system: make configuration restore less selective on backup file names

Restoring system settings expects a filename of 14 characters followed
by .tar ($DATESTAMP.tar from the backup file the addon creates).

Change to glob onto whatever *.tar file gets put into /storage/.restore/
at the busybox init and system restore level. The addon still creates
and expects the $DATESTAMP.tar file, so users will need to use this
feature by ssh or other method.

Signed-off-by: Ian Leonard <antonlacon@gmail.com>
This commit is contained in:
Ian Leonard 2020-06-26 20:55:40 +00:00
parent 1aa1ac31b1
commit a72e31a1a2
3 changed files with 21 additions and 28 deletions

View File

@ -14,14 +14,16 @@ PKG_LONGDESC="LibreELEC-settings: is a settings dialog for LibreELEC"
PKG_MAKE_OPTS_TARGET="DISTRONAME=$DISTRONAME ROOT_PASSWORD=$ROOT_PASSWORD"
if [ "$DISPLAYSERVER" = "x11" ]; then
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET setxkbmap"
PKG_DEPENDS_TARGET+=" setxkbmap"
else
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET bkeymaps"
PKG_DEPENDS_TARGET+=" bkeymaps"
fi
post_makeinstall_target() {
mkdir -p $INSTALL/usr/lib/libreelec
cp $PKG_DIR/scripts/* $INSTALL/usr/lib/libreelec
sed -e "s/@DISTRONAME@/$DISTRONAME/g" \
-i $INSTALL/usr/lib/libreelec/backup-restore
ADDON_INSTALL_DIR=$INSTALL/usr/share/kodi/addons/service.libreelec.settings

View File

@ -2,39 +2,33 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2020-present Team LibreELEC (https://libreelec.tv)
. /usr/lib/libreelec/functions
# Get NAME, which is DISTRONAME, ie. LibreELEC
. /etc/os-release
hidecursor
BACKUP_FILE=`ls -1 /storage/.restore/??????????????.tar 2>/dev/null | tail -1`
BACKUP_FILE=$(find /storage/.restore/ -name "*.tar" -print -quit 2>/dev/null)
if [ -f "$BACKUP_FILE" ] ; then
echo "RESTORE IN PROGRESS"
echo ""
echo "Please do not reboot or turn off your ${NAME} device!"
echo ""
if [ -f "${BACKUP_FILE}" ]; then
echo -e "RESTORE IN PROGRESS\n"
echo -e "Please do not reboot or turn off your @DISTRONAME@ device!\n"
StartProgress spinner "Checking backup file... "
tar tf $BACKUP_FILE &>/dev/null
ret=$?
tar tf "${BACKUP_FILE}" &>/dev/null
if [ $ret -eq 0 ] ; then
if [ $? -eq 0 ]; then
StopProgress "OK"
echo
echo "This may take some time to complete, please be patient."
echo
echo -e "\nThis may take some time to complete, please be patient.\n"
StartProgress spinner "Restoring... "
rm -rf /storage/.kodi &>/dev/null
rm -rf /storage/.cache &>/dev/null
rm -rf /storage/.config &>/dev/null
tar xf $BACKUP_FILE -C / &>/dev/null
rm -f $BACKUP_FILE &>/dev/null
rm -rf /storage/.kodi \
/storage/.cache \
/storage/.config &>/dev/null
tar xf "${BACKUP_FILE}" -C / &>/dev/null
rm -f "${BACKUP_FILE}" &>/dev/null
sync
StopProgress "done!"
@ -43,12 +37,10 @@ if [ -f "$BACKUP_FILE" ] ; then
else
StopProgress "FAILED"
echo
echo "Backup file is not valid, or corrupt."
echo -e "\nBackup file is not valid, or corrupt.\n"
echo
StartProgress spinner "Removing file to allow normal restart... "
rm -f $BACKUP_FILE &>/dev/null
rm -f "${BACKUP_FILE}" &>/dev/null
sync
StopProgress "done"
@ -57,5 +49,4 @@ if [ -f "$BACKUP_FILE" ] ; then
fi
fi
sync
reboot -f

View File

@ -1134,7 +1134,7 @@ if [ "$STORAGE_NETBOOT" = "yes" ]; then
echo "" > /sysroot/dev/.storage_netboot
fi
BACKUP_FILE=$(ls -1 /sysroot/storage/.restore/??????????????.tar 2>/dev/null | head -n 1)
BACKUP_FILE=$(ls -1 /sysroot/storage/.restore/*.tar 2>/dev/null | head -n 1)
if [ -f /sysroot/storage/.please_resize_me ]; then
INIT_UNIT="--unit=fs-resize.target"