Merge pull request #4571 from antonlacon/le10-reset-cleanup

factory-reset: cleanup
This commit is contained in:
Christian Hewitt 2021-03-10 06:38:03 +04:00 committed by GitHub
commit f217a3d706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 28 deletions

View File

@ -26,6 +26,8 @@ post_makeinstall_target() {
cp ${PKG_DIR}/scripts/* ${INSTALL}/usr/lib/libreelec cp ${PKG_DIR}/scripts/* ${INSTALL}/usr/lib/libreelec
sed -e "s/@DISTRONAME@/${DISTRONAME}/g" \ sed -e "s/@DISTRONAME@/${DISTRONAME}/g" \
-i ${INSTALL}/usr/lib/libreelec/backup-restore -i ${INSTALL}/usr/lib/libreelec/backup-restore
sed -e "s/@DISTRONAME@/${DISTRONAME}/g" \
-i ${INSTALL}/usr/lib/libreelec/factory-reset
ADDON_INSTALL_DIR=${INSTALL}/usr/share/kodi/addons/service.libreelec.settings ADDON_INSTALL_DIR=${INSTALL}/usr/share/kodi/addons/service.libreelec.settings
python_compile ${ADDON_INSTALL_DIR}/resources/lib/ python_compile ${ADDON_INSTALL_DIR}/resources/lib/

View File

@ -2,17 +2,15 @@
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv) # Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2020-present Team LibreELEC (https://libreelec.tv)
. /usr/lib/libreelec/functions . /usr/lib/libreelec/functions
# Get NAME, which is DISTRONAME, ie. LibreELEC
. /etc/os-release
hidecursor hidecursor
label= label=""
target= target=""
uuid= uuid=""
get_target() { get_target() {
for arg in $(cat /proc/cmdline); do for arg in $(cat /proc/cmdline); do
@ -22,11 +20,11 @@ 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"
@ -38,43 +36,45 @@ get_target() {
} }
show_reset_msg() { show_reset_msg() {
echo "RESET IN PROGRESS" echo -e "RESET IN PROGRESS\n"
echo "" echo -e "Please do not reboot or turn off your @DISTRONAME@ device!\n"
echo "Please do not reboot or turn off your ${NAME} device!"
echo ""
} }
if [ -f /storage/.cache/reset_oe ] ; then if [ -f /storage/.cache/reset_hard ]; then
# hard reset # hard reset
rm -f /storage/.cache/reset_oe rm -f /storage/.cache/reset_hard
get_target get_target
if [ ! -z $target ] ; then if [ -n "${target}" ]; then
show_reset_msg show_reset_msg
StartProgress spinner "Performing hard reset... " StartProgress spinner "Performing hard reset... "
umount /storage if [ -b "${target}" -a $(blkid -o value -s TYPE "${target}") = "ext4" ]; then
mke2fs -t ext4 -m 0 $target &>/dev/null umount /storage/
if [ ! -z $label ] ; then mke2fs -t ext4 -m 0 "${target}" &>/dev/null
tune2fs -U random -L $label $target &>/dev/null if [ -n "${label}" ]; then
tune2fs -U random -L "${label}" "${target}" &>/dev/null
fi fi
if [ ! -z $uuid ] ; then if [ -n "${uuid}" ]; then
tune2fs -U $uuid $target &>/dev/null tune2fs -U "${uuid}" "${target}" &>/dev/null
fi fi
StopProgress "done!" else
find /storage/ -mindepth 1 -delete
fi
StopProgress "done!"
echo echo
StartProgress countdown "Rebooting in 5s... " 5 "NOW" StartProgress countdown "Rebooting in 5s... " 5 "NOW"
fi fi
elif [ -f /storage/.cache/reset_xbmc ] ; then elif [ -f /storage/.cache/reset_soft ]; then
# soft reset # soft reset
rm -f /storage/.cache/reset_xbmc rm -f /storage/.cache/reset_soft
get_target get_target
if [ ! -z $target ] ; then if [ -n "${target}" ]; then
show_reset_msg show_reset_msg
StartProgress spinner "Performing soft reset... " StartProgress spinner "Performing soft reset... "
rm -rf /storage/.??* &>/dev/null find /storage/.cache/ /storage/.config/ /storage/.kodi/ -mindepth 1 -delete
StopProgress "done!" StopProgress "done!"
echo echo
StartProgress countdown "Rebooting in 5s... " 5 "NOW" StartProgress countdown "Rebooting in 5s... " 5 "NOW"

View File

@ -36,7 +36,7 @@ done
if [ -f /storage/.please_resize_me ]; then if [ -f /storage/.please_resize_me ]; then
TARGET="fs-resize.target" TARGET="fs-resize.target"
elif [ -f /storage/.cache/reset_oe -o -f /storage/.cache/reset_xbmc ]; then elif [ -f /storage/.cache/reset_hard -o -f /storage/.cache/reset_soft ]; then
TARGET="factory-reset.target" TARGET="factory-reset.target"
elif [ -f "$BACKUP_FILE" ]; then elif [ -f "$BACKUP_FILE" ]; then
TARGET="backup-restore.target" TARGET="backup-restore.target"