mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 13:46:49 +00:00
Merge pull request #3814 from stefansaraev/fs-resize
fs-resize: move as systemd target
This commit is contained in:
commit
69fc3cebe0
@ -19,7 +19,7 @@
|
||||
|
||||
BACKUP_FILE=`ls -1 /storage/.restore/??????????????.tar 2>/dev/null | tail -1`
|
||||
|
||||
if [ -e "$BACKUP_FILE" ] ; then
|
||||
if [ -f "$BACKUP_FILE" ] ; then
|
||||
echo -en "please wait.. checking backup file: "
|
||||
tar tf $BACKUP_FILE &>/dev/null
|
||||
ret=$?
|
||||
@ -32,13 +32,14 @@ if [ -e "$BACKUP_FILE" ] ; then
|
||||
tar xf $BACKUP_FILE -C / &>/dev/null
|
||||
rm -f $BACKUP_FILE &>/dev/null
|
||||
echo done
|
||||
echo "all good. normal startup in 5s..."
|
||||
echo "rebooting in 5s..."
|
||||
sleep 5
|
||||
else
|
||||
echo FAILED
|
||||
echo "normal startup in 30s..."
|
||||
rm -f $BACKUP_FILE &>/dev/null
|
||||
echo "rebooting in 30s..."
|
||||
sleep 30
|
||||
fi
|
||||
fi
|
||||
|
||||
sync
|
||||
reboot
|
||||
|
@ -40,8 +40,9 @@ get_target() {
|
||||
done
|
||||
}
|
||||
|
||||
# hard reset
|
||||
if [ -f /storage/.cache/reset_oe ] ; then
|
||||
# hard reset
|
||||
rm -f /storage/.cache/reset_oe
|
||||
get_target
|
||||
if [ ! -z $target ] ; then
|
||||
echo "hard resetting..."
|
||||
@ -53,15 +54,19 @@ if [ -f /storage/.cache/reset_oe ] ; then
|
||||
if [ ! -z $uuid ] ; then
|
||||
tune2fs -U $uuid $target
|
||||
fi
|
||||
reboot
|
||||
echo "done"
|
||||
sleep 5
|
||||
fi
|
||||
fi
|
||||
|
||||
# soft reset
|
||||
if [ -f /storage/.cache/reset_xbmc ] ; then
|
||||
elif [ -f /storage/.cache/reset_xbmc ] ; then
|
||||
# soft reset
|
||||
rm -f /storage/.cache/reset_xbmc
|
||||
get_target
|
||||
if [ ! -z $target ] ; then
|
||||
echo "soft resetting..."
|
||||
rm -rf /storage/.??* 2>&1 >/dev/null
|
||||
echo "done"
|
||||
sleep 5
|
||||
fi
|
||||
fi
|
||||
sync
|
||||
reboot
|
||||
|
@ -1,15 +1,10 @@
|
||||
[Unit]
|
||||
Description=Restoring Backup
|
||||
DefaultDependencies=false
|
||||
After=show-version.service
|
||||
Before=local-fs-pre.target shutdown.target
|
||||
Conflicts=shutdown.target
|
||||
ConditionPathExistsGlob=|/storage/.restore/*.tar
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Type=idle
|
||||
ExecStart=/usr/lib/openelec/backup-restore
|
||||
StandardOutput=tty
|
||||
|
||||
[Install]
|
||||
WantedBy=local-fs-pre.target
|
||||
StandardInput=tty-force
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
|
@ -0,0 +1,5 @@
|
||||
[Unit]
|
||||
Description=Restoring Backup target
|
||||
Requires=backup-restore.service
|
||||
After=backup-restore.service
|
||||
AllowIsolate=yes
|
@ -1,17 +1,10 @@
|
||||
[Unit]
|
||||
Description=Factory reset
|
||||
DefaultDependencies=false
|
||||
After=show-version.service
|
||||
Before=local-fs-pre.target shutdown.target
|
||||
Conflicts=shutdown.target
|
||||
|
||||
ConditionPathExists=|/storage/.cache/reset_oe
|
||||
ConditionPathExists=|/storage/.cache/reset_xbmc
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Type=idle
|
||||
ExecStart=/usr/lib/openelec/factory-reset
|
||||
StandardOutput=tty
|
||||
|
||||
[Install]
|
||||
WantedBy=local-fs-pre.target
|
||||
StandardInput=tty-force
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
|
@ -0,0 +1,5 @@
|
||||
[Unit]
|
||||
Description=Factory reset target
|
||||
Requires=factory-reset.service
|
||||
After=factory-reset.service
|
||||
AllowIsolate=yes
|
@ -31,6 +31,9 @@ if [ -e /storage/.please_resize_me ] ; then
|
||||
;;
|
||||
esac
|
||||
|
||||
rm -f /storage/.please_resize_me
|
||||
sync
|
||||
|
||||
# just in case
|
||||
if [ ! -z "$DISK" -a ! -z "$PART" ] ; then
|
||||
# get storage partition start
|
||||
@ -38,8 +41,6 @@ if [ -e /storage/.please_resize_me ] ; then
|
||||
|
||||
# failed to get partition start offset ?
|
||||
if [ ! -z "$PART_START" ] ; then
|
||||
rm -f /storage/.please_resize_me
|
||||
sync
|
||||
umount $PART
|
||||
# TODO: clean up debug
|
||||
echo "resizing /storage..."
|
||||
@ -54,7 +55,7 @@ if [ -e /storage/.please_resize_me ] ; then
|
||||
resize2fs $PART &>/dev/null
|
||||
echo "...done. rebooting in 15s"
|
||||
sleep 15
|
||||
reboot
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
reboot
|
||||
|
@ -108,10 +108,10 @@
|
||||
wol_wait="${arg#*=}"
|
||||
;;
|
||||
textmode)
|
||||
INIT_ARGS="$INIT_ARGS --unit=textmode.target"
|
||||
INIT_UNIT="--unit=textmode.target"
|
||||
;;
|
||||
installer)
|
||||
INIT_ARGS="$INIT_ARGS --unit=installer.target"
|
||||
INIT_UNIT="--unit=installer.target"
|
||||
;;
|
||||
debugging)
|
||||
DEBUG=yes
|
||||
@ -662,7 +662,20 @@
|
||||
if [ "$STORAGE_NETBOOT" = "yes" ] ; then
|
||||
echo "" > /sysroot/dev/.storage_netboot
|
||||
fi
|
||||
|
||||
if [ -f /sysroot/storage/.please_resize_me ] ; then
|
||||
INIT_ARGS="--unit=fs-resize.target"
|
||||
fi
|
||||
|
||||
BACKUP_FILE=`ls -1 /sysroot/storage/.restore/??????????????.tar 2>/dev/null | head -n 1`
|
||||
if [ -f "$BACKUP_FILE" ] ; then
|
||||
INIT_UNIT="--unit=backup-restore.target"
|
||||
fi
|
||||
|
||||
if [ -f /sysroot/storage/.cache/reset_oe -o -f /sysroot/storage/.cache/reset_xbmc ] ; then
|
||||
INIT_UNIT="--unit=factory-reset.target"
|
||||
fi
|
||||
# switch to new sysroot and start real init
|
||||
exec /bin/busybox switch_root /sysroot /usr/lib/systemd/systemd $INIT_ARGS
|
||||
exec /bin/busybox switch_root /sysroot /usr/lib/systemd/systemd $INIT_ARGS $INIT_UNIT
|
||||
|
||||
error "switch_root" "Error in initramfs. Could not switch to new root"
|
||||
|
@ -1,16 +1,10 @@
|
||||
[Unit]
|
||||
Description=FS Resize
|
||||
DefaultDependencies=false
|
||||
After=show-version.service
|
||||
Before=local-fs-pre.target shutdown.target
|
||||
Conflicts=shutdown.target
|
||||
|
||||
ConditionPathExists=|/storage/.please_resize_me
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Type=idle
|
||||
ExecStart=/usr/lib/openelec/fs-resize
|
||||
StandardOutput=tty
|
||||
|
||||
[Install]
|
||||
WantedBy=local-fs-pre.target
|
||||
StandardInput=tty-force
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
|
5
packages/sysutils/busybox/system.d/fs-resize.target
Normal file
5
packages/sysutils/busybox/system.d/fs-resize.target
Normal file
@ -0,0 +1,5 @@
|
||||
[Unit]
|
||||
Description=FS Resize target
|
||||
Requires=fs-resize.service
|
||||
After=fs-resize.service
|
||||
AllowIsolate=yes
|
Loading…
x
Reference in New Issue
Block a user