backup-restore: move as systemd target

This commit is contained in:
Stefan Saraev 2015-01-19 11:43:04 +02:00 committed by Stephan Raue
parent d90305e027
commit 4173481b4b
4 changed files with 21 additions and 14 deletions

View File

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

View File

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

View File

@ -0,0 +1,5 @@
[Unit]
Description=Restoring Backup target
Requires=backup-restore.service
After=backup-restore.service
AllowIsolate=yes

View File

@ -674,6 +674,12 @@
if [ -f /sysroot/storage/.cache/reset_oe -o -f /sysroot/storage/.cache/reset_xbmc ] ; then
INIT_UNIT="--unit=factory-reset.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
# switch to new sysroot and start real init
exec /bin/busybox switch_root /sysroot /usr/lib/systemd/systemd $INIT_ARGS $INIT_UNIT