mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 21:56:42 +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`
|
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: "
|
echo -en "please wait.. checking backup file: "
|
||||||
tar tf $BACKUP_FILE &>/dev/null
|
tar tf $BACKUP_FILE &>/dev/null
|
||||||
ret=$?
|
ret=$?
|
||||||
@ -32,13 +32,14 @@ if [ -e "$BACKUP_FILE" ] ; then
|
|||||||
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
|
echo done
|
||||||
echo "all good. normal startup in 5s..."
|
echo "rebooting in 5s..."
|
||||||
sleep 5
|
sleep 5
|
||||||
else
|
else
|
||||||
echo FAILED
|
echo FAILED
|
||||||
echo "normal startup in 30s..."
|
|
||||||
rm -f $BACKUP_FILE &>/dev/null
|
rm -f $BACKUP_FILE &>/dev/null
|
||||||
|
echo "rebooting in 30s..."
|
||||||
sleep 30
|
sleep 30
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
sync
|
||||||
|
reboot
|
||||||
|
@ -40,8 +40,9 @@ get_target() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# hard reset
|
|
||||||
if [ -f /storage/.cache/reset_oe ] ; then
|
if [ -f /storage/.cache/reset_oe ] ; then
|
||||||
|
# hard reset
|
||||||
|
rm -f /storage/.cache/reset_oe
|
||||||
get_target
|
get_target
|
||||||
if [ ! -z $target ] ; then
|
if [ ! -z $target ] ; then
|
||||||
echo "hard resetting..."
|
echo "hard resetting..."
|
||||||
@ -53,15 +54,19 @@ if [ -f /storage/.cache/reset_oe ] ; then
|
|||||||
if [ ! -z $uuid ] ; then
|
if [ ! -z $uuid ] ; then
|
||||||
tune2fs -U $uuid $target
|
tune2fs -U $uuid $target
|
||||||
fi
|
fi
|
||||||
reboot
|
echo "done"
|
||||||
|
sleep 5
|
||||||
fi
|
fi
|
||||||
fi
|
elif [ -f /storage/.cache/reset_xbmc ] ; then
|
||||||
|
|
||||||
# soft reset
|
# soft reset
|
||||||
if [ -f /storage/.cache/reset_xbmc ] ; then
|
rm -f /storage/.cache/reset_xbmc
|
||||||
get_target
|
get_target
|
||||||
if [ ! -z $target ] ; then
|
if [ ! -z $target ] ; then
|
||||||
echo "soft resetting..."
|
echo "soft resetting..."
|
||||||
rm -rf /storage/.??* 2>&1 >/dev/null
|
rm -rf /storage/.??* 2>&1 >/dev/null
|
||||||
|
echo "done"
|
||||||
|
sleep 5
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
sync
|
||||||
|
reboot
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Restoring Backup
|
Description=Restoring Backup
|
||||||
DefaultDependencies=false
|
DefaultDependencies=no
|
||||||
After=show-version.service
|
|
||||||
Before=local-fs-pre.target shutdown.target
|
|
||||||
Conflicts=shutdown.target
|
|
||||||
ConditionPathExistsGlob=|/storage/.restore/*.tar
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=idle
|
||||||
ExecStart=/usr/lib/openelec/backup-restore
|
ExecStart=/usr/lib/openelec/backup-restore
|
||||||
StandardOutput=tty
|
StandardInput=tty-force
|
||||||
|
StandardOutput=inherit
|
||||||
[Install]
|
StandardError=inherit
|
||||||
WantedBy=local-fs-pre.target
|
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Restoring Backup target
|
||||||
|
Requires=backup-restore.service
|
||||||
|
After=backup-restore.service
|
||||||
|
AllowIsolate=yes
|
@ -1,17 +1,10 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Factory reset
|
Description=Factory reset
|
||||||
DefaultDependencies=false
|
DefaultDependencies=no
|
||||||
After=show-version.service
|
|
||||||
Before=local-fs-pre.target shutdown.target
|
|
||||||
Conflicts=shutdown.target
|
|
||||||
|
|
||||||
ConditionPathExists=|/storage/.cache/reset_oe
|
|
||||||
ConditionPathExists=|/storage/.cache/reset_xbmc
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=idle
|
||||||
ExecStart=/usr/lib/openelec/factory-reset
|
ExecStart=/usr/lib/openelec/factory-reset
|
||||||
StandardOutput=tty
|
StandardInput=tty-force
|
||||||
|
StandardOutput=inherit
|
||||||
[Install]
|
StandardError=inherit
|
||||||
WantedBy=local-fs-pre.target
|
|
||||||
|
@ -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
|
esac
|
||||||
|
|
||||||
|
rm -f /storage/.please_resize_me
|
||||||
|
sync
|
||||||
|
|
||||||
# just in case
|
# just in case
|
||||||
if [ ! -z "$DISK" -a ! -z "$PART" ] ; then
|
if [ ! -z "$DISK" -a ! -z "$PART" ] ; then
|
||||||
# get storage partition start
|
# get storage partition start
|
||||||
@ -38,8 +41,6 @@ if [ -e /storage/.please_resize_me ] ; then
|
|||||||
|
|
||||||
# failed to get partition start offset ?
|
# failed to get partition start offset ?
|
||||||
if [ ! -z "$PART_START" ] ; then
|
if [ ! -z "$PART_START" ] ; then
|
||||||
rm -f /storage/.please_resize_me
|
|
||||||
sync
|
|
||||||
umount $PART
|
umount $PART
|
||||||
# TODO: clean up debug
|
# TODO: clean up debug
|
||||||
echo "resizing /storage..."
|
echo "resizing /storage..."
|
||||||
@ -54,7 +55,7 @@ if [ -e /storage/.please_resize_me ] ; then
|
|||||||
resize2fs $PART &>/dev/null
|
resize2fs $PART &>/dev/null
|
||||||
echo "...done. rebooting in 15s"
|
echo "...done. rebooting in 15s"
|
||||||
sleep 15
|
sleep 15
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
reboot
|
reboot
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
@ -108,10 +108,10 @@
|
|||||||
wol_wait="${arg#*=}"
|
wol_wait="${arg#*=}"
|
||||||
;;
|
;;
|
||||||
textmode)
|
textmode)
|
||||||
INIT_ARGS="$INIT_ARGS --unit=textmode.target"
|
INIT_UNIT="--unit=textmode.target"
|
||||||
;;
|
;;
|
||||||
installer)
|
installer)
|
||||||
INIT_ARGS="$INIT_ARGS --unit=installer.target"
|
INIT_UNIT="--unit=installer.target"
|
||||||
;;
|
;;
|
||||||
debugging)
|
debugging)
|
||||||
DEBUG=yes
|
DEBUG=yes
|
||||||
@ -662,7 +662,20 @@
|
|||||||
if [ "$STORAGE_NETBOOT" = "yes" ] ; then
|
if [ "$STORAGE_NETBOOT" = "yes" ] ; then
|
||||||
echo "" > /sysroot/dev/.storage_netboot
|
echo "" > /sysroot/dev/.storage_netboot
|
||||||
fi
|
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
|
# 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"
|
error "switch_root" "Error in initramfs. Could not switch to new root"
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=FS Resize
|
Description=FS Resize
|
||||||
DefaultDependencies=false
|
DefaultDependencies=no
|
||||||
After=show-version.service
|
|
||||||
Before=local-fs-pre.target shutdown.target
|
|
||||||
Conflicts=shutdown.target
|
|
||||||
|
|
||||||
ConditionPathExists=|/storage/.please_resize_me
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=idle
|
||||||
ExecStart=/usr/lib/openelec/fs-resize
|
ExecStart=/usr/lib/openelec/fs-resize
|
||||||
StandardOutput=tty
|
StandardInput=tty-force
|
||||||
|
StandardOutput=inherit
|
||||||
[Install]
|
StandardError=inherit
|
||||||
WantedBy=local-fs-pre.target
|
|
||||||
|
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