factory-reset: move as systemd target

This commit is contained in:
Stefan Saraev 2015-01-19 11:50:35 +02:00 committed by Stephan Raue
parent 5668f98de0
commit a5b35e1b44
4 changed files with 25 additions and 18 deletions

View File

@ -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 rm -f /storage/.cache/reset_xbmc
if [ -f /storage/.cache/reset_xbmc ] ; then
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

View File

@ -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

View File

@ -0,0 +1,5 @@
[Unit]
Description=Factory reset target
Requires=factory-reset.service
After=factory-reset.service
AllowIsolate=yes

View File

@ -670,6 +670,10 @@
if [ -f /sysroot/storage/.please_resize_me ] ; then if [ -f /sysroot/storage/.please_resize_me ] ; then
INIT_ARGS="--unit=fs-resize.target" INIT_ARGS="--unit=fs-resize.target"
fi fi
if [ -f /sysroot/storage/.cache/reset_oe -o -f /sysroot/storage/.cache/reset_xbmc ] ; then
INIT_ARGS="--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