mirror of https://schlomp.space/tastytea/hashboot
minor updates
parent
ae9b123d5e
commit
e3cf7b1bd4
12
hashboot
12
hashboot
|
@ -20,10 +20,11 @@ LOG_FILE="/tmp/hashboot.log"
|
||||||
MBR_DEVICE=""
|
MBR_DEVICE=""
|
||||||
MBR_SIZE=0
|
MBR_SIZE=0
|
||||||
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=0
|
BOOT_MOUNTED=0
|
||||||
CONFIG_FILE="/etc/hashboot.cfg"
|
CONFIG_FILE="/etc/hashboot.cfg"
|
||||||
|
COUNTER=0
|
||||||
|
|
||||||
|
|
||||||
#Umount /boot if we mounted it, exit with given exit code
|
#Umount /boot if we mounted it, exit with given exit code
|
||||||
|
@ -65,7 +66,7 @@ fi
|
||||||
#Look for config file and set ${MBR_DEVICE}.
|
#Look for config file and set ${MBR_DEVICE}.
|
||||||
if [ -f ${CONFIG_FILE} ]
|
if [ -f ${CONFIG_FILE} ]
|
||||||
then
|
then
|
||||||
MBR_DEVICE=$(grep ^mbr_device ${CONFIG_FILE} | awk '{print $3}')
|
MBR_DEVICE=$(grep ^MBR_DEVICE ${CONFIG_FILE} | awk '{print $3}')
|
||||||
[ $? != 0 ] && die 9 "Error reading config file"
|
[ $? != 0 ] && die 9 "Error reading config file"
|
||||||
#If not found, create one and ask for ${MBR_DEVICE}
|
#If not found, create one and ask for ${MBR_DEVICE}
|
||||||
else
|
else
|
||||||
|
@ -73,13 +74,13 @@ else
|
||||||
read -r MBR_DEVICE
|
read -r MBR_DEVICE
|
||||||
[ -z "${MBR_DEVICE}" ] && MBR_DEVICE="/dev/sda"
|
[ -z "${MBR_DEVICE}" ] && MBR_DEVICE="/dev/sda"
|
||||||
echo "#Device with the MBR on it" > ${CONFIG_FILE}
|
echo "#Device with the MBR on it" > ${CONFIG_FILE}
|
||||||
echo "mbr_device = ${MBR_DEVICE}" >> ${CONFIG_FILE}
|
echo "MBR_DEVICE = ${MBR_DEVICE}" >> ${CONFIG_FILE}
|
||||||
|
|
||||||
echo -n "Where should backupfile be stored?"
|
echo -n "Where should backupfile be stored?"
|
||||||
read -r BACKUP_FILE
|
read -r BACKUP_FILE
|
||||||
[ -z "${BACKUP_FILE}" ] && BACKUP_FILE="/var/cache/boot-backup.tar.gz"
|
[ -z "${BACKUP_FILE}" ] && BACKUP_FILE="/var/cache/boot-backup.tar.gz"
|
||||||
echo "#Where the Backup files are stored" >> ${CONFIG_FILE}
|
echo "#Where the Backup files are stored" >> ${CONFIG_FILE}
|
||||||
echo "BACKUP_FILE = ${BACKUP_FILE}" >> ${CONFIG_FILE}
|
echo "BACKUP_FILE=${BACKUP_FILE}" >> ${CONFIG_FILE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find out where the first partition starts and set ${MBR_SIZE} in KiB
|
# Find out where the first partition starts and set ${MBR_SIZE} in KiB
|
||||||
|
@ -143,6 +144,8 @@ then
|
||||||
else
|
else
|
||||||
write_hashes $DIGEST_FILE
|
write_hashes $DIGEST_FILE
|
||||||
fi
|
fi
|
||||||
|
#readconfig
|
||||||
|
source ${CONFIG_FILE}
|
||||||
#Backup of good files
|
#Backup of good files
|
||||||
tar -czpPf ${BACKUP_FILE} ${MBR_TMP} /boot ${DIGEST_FILE}
|
tar -czpPf ${BACKUP_FILE} ${MBR_TMP} /boot ${DIGEST_FILE}
|
||||||
if [ $? == 0 ]
|
if [ $? == 0 ]
|
||||||
|
@ -153,7 +156,6 @@ then
|
||||||
fi
|
fi
|
||||||
elif [ "${1}" == "check" ]
|
elif [ "${1}" == "check" ]
|
||||||
then
|
then
|
||||||
COUNTER=0
|
|
||||||
HASHER=$(head -n1 ${DIGEST_FILE} | awk '{print $5}')
|
HASHER=$(head -n1 ${DIGEST_FILE} | awk '{print $5}')
|
||||||
|
|
||||||
dd if=${MBR_DEVICE} of=${MBR_TMP} bs=${MBR_SIZE}K count=1 status=noxfer || die 8
|
dd if=${MBR_DEVICE} of=${MBR_TMP} bs=${MBR_SIZE}K count=1 status=noxfer || die 8
|
||||||
|
|
Loading…
Reference in New Issue