mirror of https://schlomp.space/tastytea/hashboot
even more MBR stuff :-)
parent
6ebbd9ee69
commit
85b5f869c6
24
hashboot.sh
24
hashboot.sh
|
@ -61,7 +61,7 @@ then
|
||||||
#Write header
|
#Write header
|
||||||
echo "#hashboot ${VERSION} - Algorithm: $(basename ${HASHER})" > ${DIGEST_FILE}
|
echo "#hashboot ${VERSION} - Algorithm: $(basename ${HASHER})" > ${DIGEST_FILE}
|
||||||
#Write MBR of MBR_DEVICE to ${DIGEST_FILE}
|
#Write MBR of MBR_DEVICE to ${DIGEST_FILE}
|
||||||
dd if=/dev/sda of=${MBR_TMP} bs=1M count=1 status=noxfer || die 8
|
dd if=${MBR_DEVICE} of=${MBR_TMP} bs=1M count=1 status=noxfer || die 8
|
||||||
#Write hashes of all regular files to ${DIGEST_FILE}
|
#Write hashes of all regular files to ${DIGEST_FILE}
|
||||||
${HASHER} ${MBR_TMP} > ${DIGEST_FILE}
|
${HASHER} ${MBR_TMP} > ${DIGEST_FILE}
|
||||||
find /boot -type f -exec ${HASHER} --binary {} >> ${DIGEST_FILE} +
|
find /boot -type f -exec ${HASHER} --binary {} >> ${DIGEST_FILE} +
|
||||||
|
@ -84,7 +84,7 @@ then
|
||||||
elif [ "${1}" == "check" ]
|
elif [ "${1}" == "check" ]
|
||||||
then
|
then
|
||||||
COUNTER=0
|
COUNTER=0
|
||||||
dd if=/dev/sda of=${MBR_TMP} bs=1M count=1 status=noxfer || die 8
|
dd if=${MBR_DEVICE} of=${MBR_TMP} bs=1M count=1 status=noxfer || die 8
|
||||||
if $(grep ${MBR_TMP} ${DIGEST_FILE} | ${HASHER} --check --warn --quiet --strict > ${LOG_FILE})
|
if $(grep ${MBR_TMP} ${DIGEST_FILE} | ${HASHER} --check --warn --quiet --strict > ${LOG_FILE})
|
||||||
then
|
then
|
||||||
echo "MBR ok"
|
echo "MBR ok"
|
||||||
|
@ -95,7 +95,6 @@ then
|
||||||
if $(grep -v ${MBR_TMP} ${DIGEST_FILE} | ${HASHER} --check --warn --quiet --strict >> ${LOG_FILE})
|
if $(grep -v ${MBR_TMP} ${DIGEST_FILE} | ${HASHER} --check --warn --quiet --strict >> ${LOG_FILE})
|
||||||
then
|
then
|
||||||
echo "/boot ok"
|
echo "/boot ok"
|
||||||
die 0
|
|
||||||
else
|
else
|
||||||
echo " !! TIME TO PANIK: AT LEAST 1 FILE WAS MODIFIED !!"
|
echo " !! TIME TO PANIK: AT LEAST 1 FILE WAS MODIFIED !!"
|
||||||
COUNTER=$((COUNTER + 2))
|
COUNTER=$((COUNTER + 2))
|
||||||
|
@ -109,21 +108,12 @@ then
|
||||||
for file in $(cut -d: -f1 ${LOG_FILE})
|
for file in $(cut -d: -f1 ${LOG_FILE})
|
||||||
do
|
do
|
||||||
tar -xzpPvwf ${BACKUP_FILE} ${file}
|
tar -xzpPvwf ${BACKUP_FILE} ${file}
|
||||||
[ $? != 0 ] && echo "Error restoring ${file} from backup, continuing"
|
[ $? != 0 ] && echo "Error restoring ${file} from backup, continuing" >&2
|
||||||
# If the MBR is to be recovered, ask if it really should be copied to /dev/sda.
|
#If the MBR is to be recovered, copy to ${MBR_DEVICE}
|
||||||
# Should be no problem to do it automatically, but it is untested and would
|
if [ "${file}" == ${MBR_TMP} ]
|
||||||
# be really bad if there is an error.
|
|
||||||
if [ "$file" == ${MBR_TMP} ]
|
|
||||||
then
|
then
|
||||||
echo "Backup of MBR copied to ${MBR_TMP}, copy it to /dev/sda? (DANGEROUS) [y/N] "
|
cp ${MBR_TMP} ${MBR_DEVICE}
|
||||||
read -r yesno
|
[ $? != 0 ] && echo "Error restoring MBR from backup, continuing" >&2
|
||||||
if [ "${yesno}" == "y" ]
|
|
||||||
then
|
|
||||||
cp ${MBR_TMP} /dev/sda
|
|
||||||
else
|
|
||||||
echo "MBR not recovered, you can copy it manually with:"
|
|
||||||
echo "cp ${MBR_TMP} /dev/sda"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue