backup: fix up messages

This commit is contained in:
MilhouseVH 2016-09-28 03:32:04 +01:00
parent 521a42cce4
commit b87a315c46
2 changed files with 92 additions and 35 deletions

View File

@ -17,29 +17,59 @@
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>. # along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################ ################################################################################
. /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=`ls -1 /storage/.restore/??????????????.tar 2>/dev/null | tail -1`
if [ -f "$BACKUP_FILE" ] ; then if [ -f "$BACKUP_FILE" ] ; then
echo -en "please wait.. checking backup file: " echo "RESTORE IN PROGRESS"
echo ""
echo "Please do not reboot or turn off your ${NAME} device!"
echo ""
StartProgress spinner "Checking backup file... "
tar tf $BACKUP_FILE &>/dev/null tar tf $BACKUP_FILE &>/dev/null
ret=$? ret=$?
if [ $ret -eq 0 ] ; then if [ $ret -eq 0 ] ; then
echo OK StopProgress "OK"
echo -en "restoring.. this may take long time to complete, please wait.. "
echo
echo "This may take some time to complete, please be patient."
echo
StartProgress spinner "Restoring... "
rm -rf /storage/.kodi &>/dev/null rm -rf /storage/.kodi &>/dev/null
rm -rf /storage/.cache &>/dev/null rm -rf /storage/.cache &>/dev/null
rm -rf /storage/.config &>/dev/null rm -rf /storage/.config &>/dev/null
tar xf $BACKUP_FILE -C / &>/dev/null tar xf $BACKUP_FILE -C / &>/dev/null
rm -f $BACKUP_FILE &>/dev/null rm -f $BACKUP_FILE &>/dev/null
echo done sync
echo "rebooting in 5s..." StopProgress "done!"
sleep 5
echo
StartProgress countdown "Rebooting in 5s... " 5 "NOW"
else else
echo FAILED StopProgress "FAILED"
echo
echo "Backup file is not valid, or corrupt."
echo
StartProgress spinner "Removing file to allow normal restart... "
rm -f $BACKUP_FILE &>/dev/null rm -f $BACKUP_FILE &>/dev/null
echo "rebooting in 30s..." sync
sleep 30 StopProgress "done"
echo
StartProgress countdown "Rebooting in 30s... " 30 "NOW"
fi fi
fi fi
sync sync
reboot -f reboot -f

View File

@ -17,6 +17,17 @@
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>. # along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################ ################################################################################
. /usr/lib/libreelec/functions
# Get NAME, which is DISTRONAME, ie. LibreELEC
. /etc/os-release
hidecursor
label=
target=
uuid=
get_target() { get_target() {
for arg in $(cat /proc/cmdline); do for arg in $(cat /proc/cmdline); do
case $arg in case $arg in
@ -25,14 +36,14 @@ get_target() {
case $disk in case $disk in
LABEL=*) LABEL=*)
label="${disk#*=}" label="${disk#*=}"
target=`blkid -L $label` target="$(blkid -L $label)"
;; ;;
UUID=*) UUID=*)
uuid="${disk#*=}" uuid="${disk#*=}"
target=`blkid -U $uuid` target="$(blkid -U $uuid)"
;; ;;
/*) /*)
target=$disk target="$disk"
;; ;;
esac esac
;; ;;
@ -40,33 +51,49 @@ get_target() {
done done
} }
show_reset_msg() {
echo "RESET IN PROGRESS"
echo ""
echo "Please do not reboot or turn off your ${NAME} device!"
echo ""
}
if [ -f /storage/.cache/reset_oe ] ; then if [ -f /storage/.cache/reset_oe ] ; then
# hard reset # hard reset
rm -f /storage/.cache/reset_oe rm -f /storage/.cache/reset_oe
get_target get_target
if [ ! -z $target ] ; then if [ ! -z $target ] ; then
echo "hard resetting..." show_reset_msg
StartProgress spinner "Performing hard reset... "
umount /storage umount /storage
mke2fs -t ext4 -m 0 $target 2>&1 >/dev/null mke2fs -t ext4 -m 0 $target &>/dev/null
if [ ! -z $label ] ; then if [ ! -z $label ] ; then
tune2fs -U random -L $label $target tune2fs -U random -L $label $target &>/dev/null
fi fi
if [ ! -z $uuid ] ; then if [ ! -z $uuid ] ; then
tune2fs -U $uuid $target tune2fs -U $uuid $target &>/dev/null
fi fi
echo "done" StopProgress "done!"
sleep 5
echo
StartProgress countdown "Rebooting in 5s... " 5 "NOW"
fi fi
elif [ -f /storage/.cache/reset_xbmc ] ; then elif [ -f /storage/.cache/reset_xbmc ] ; then
# soft reset # soft reset
rm -f /storage/.cache/reset_xbmc rm -f /storage/.cache/reset_xbmc
get_target get_target
if [ ! -z $target ] ; then if [ ! -z $target ] ; then
echo "soft resetting..." show_reset_msg
rm -rf /storage/.??* 2>&1 >/dev/null
echo "done" StartProgress spinner "Performing soft reset... "
sleep 5 rm -rf /storage/.??* &>/dev/null
StopProgress "done!"
echo
StartProgress countdown "Rebooting in 5s... " 5 "NOW"
fi fi
fi fi
sync sync
reboot -f reboot -f