Changed to be not interactive while checking to work with systemd

pull/1/head
tastytea 2015-06-06 01:58:48 +02:00
parent 7054d09a2a
commit a7996b9bae
4 changed files with 48 additions and 24 deletions

View File

@ -1,3 +1,5 @@
* 2015-06-05 tastytea <tastytea@tastytea.de>
Changed to be not interactive while checking to work with systemd
* 2015-06-05 tastytea <tastytea@tastytea.de>
Version 0.4
Error handling

View File

@ -22,6 +22,18 @@ function die
exit ${1}
}
function recover
{
echo "Restoring files from backup... (type yes or no for each file)"
#For each failed file: ask if it should be recovered from backup
for file in $(cut -d: -f1 ${LOG_FILE})
do
tar -xzpPvwf ${BACKUP_FILE} ${file}
[ $? != 0 ] && echo "Error restoring ${file} from backup, continuing"
done
}
#If we're not root: exit
if [ ${UID} -ne 0 ]
then
@ -75,8 +87,6 @@ then
echo "Error writing ${BACKUP_FILE}" >&2
die 5
fi
die 0
elif [ "${1}" == "check" ]
then
if $(${HASHER} --check --warn --quiet --strict ${DIGEST_FILE} > ${LOG_FILE})
@ -84,24 +94,14 @@ then
die 0
else
echo " !! TIME TO PANIK: AT LEAST 1 FILE WAS MODIFIED !!"
echo "Restoring files from backup... (type yes or no for each file)"
#For each failed file: ask if it should be recovered from backup
for file in $(cut -d: -f1 ${LOG_FILE})
do
tar -xzpPvwf ${BACKUP_FILE} ${file}
[ $? != 0 ] && echo "Error restoring ${file} from backup, continuing"
done
echo -n "Type reboot to reboot now, otherwise you get a shell: "
read -r reboot
if [ ${reboot} == "reboot" ]
then
reboot
fi
die 4
fi
elif [ "${1}" == "recover" ]
then
recover
else
echo "Usage: ${0} index|check" >&2
echo "Usage: ${0} index|check|recover" >&2
die 1
fi
fi
die 0

View File

@ -18,11 +18,23 @@ case "$1" in
start)
log_daemon_msg "Checking integrity of files in /boot"
if ! hashboot.sh check
hashboot.sh check
if [ $? == 4 ]
then
log_end_msg 1
log_end_msg 4
echo -n "Recover files? [y/N] "
read -r yesno
if [ ${yesno} == "y" ]
then
hashboot.sh recover
fi
sh
exit 1
exit 4
elif [ $? != 0 ]
log_end_msg $?
exit $?
fi
log_end_msg 0

View File

@ -14,10 +14,20 @@ start()
# See if hashboot.sh is accessible
which hashboot.sh > /dev/null || return 1
if ! hashboot.sh check
hashboot.sh check
if [ $? == 4 ]
then
echo -n "Recover files? [y/N] "
read -r yesno
if [ ${yesno} == "y" ]
then
hashboot.sh recover
fi
sh
return 2
return 4
elif [ $? != 0 ]
return $?
fi
eend 0