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
}
# 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

View File

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

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
INIT_ARGS="--unit=fs-resize.target"
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
exec /bin/busybox switch_root /sysroot /usr/lib/systemd/systemd $INIT_ARGS