mirror of https://schlomp.space/tastytea/hashboot
moved recover()
parent
9cc5962b62
commit
d9fb20952c
22
hashboot.sh
22
hashboot.sh
|
@ -13,7 +13,7 @@ MBR_FILE="/var/lib/mbr.digest"
|
||||||
MBR_TMP="/tmp/mbr"
|
MBR_TMP="/tmp/mbr"
|
||||||
BACKUP_FILE="/var/cache/boot-backup.tar.gz"
|
BACKUP_FILE="/var/cache/boot-backup.tar.gz"
|
||||||
HASHER=""
|
HASHER=""
|
||||||
BOOT_MOUNTED=""
|
BOOT_MOUNTED=0
|
||||||
|
|
||||||
#Umount /boot if we mounted it, exit with given exit code
|
#Umount /boot if we mounted it, exit with given exit code
|
||||||
function die
|
function die
|
||||||
|
@ -26,17 +26,6 @@ function die
|
||||||
exit ${1}
|
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 we're not root: exit
|
||||||
if [ ${UID} -ne 0 ]
|
if [ ${UID} -ne 0 ]
|
||||||
|
@ -113,7 +102,14 @@ then
|
||||||
fi
|
fi
|
||||||
elif [ "${1}" == "recover" ]
|
elif [ "${1}" == "recover" ]
|
||||||
then
|
then
|
||||||
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
|
||||||
else
|
else
|
||||||
echo "Usage: ${0} index|check|recover" >&2
|
echo "Usage: ${0} index|check|recover" >&2
|
||||||
die 6
|
die 6
|
||||||
|
|
Loading…
Reference in New Issue