little fixes, modified initscripts to reflect exit code changes

pull/1/head
tastytea 2015-09-29 15:55:28 +02:00
parent d59eaf7ef8
commit 7f3fa8630d
4 changed files with 60 additions and 65 deletions

3
TODO
View File

@ -1,2 +1,3 @@
* Deian package * Debian package
* Ubuntu package * Ubuntu package
* Read header of ${DIGEST_FILE}

View File

@ -72,7 +72,7 @@ then
#Write header #Write header
echo "#hashboot ${VERSION} - Algorithm: $(basename ${HASHER})" > ${DIGEST_FILE} echo "#hashboot ${VERSION} - Algorithm: $(basename ${HASHER})" > ${DIGEST_FILE}
#Write hashes of all regular files to ${DIGEST_FILE} #Write hashes of all regular files to ${DIGEST_FILE}
err=$(dd if=/dev/sda of=${MBR_TMP} bs=1M count=1 status=noxfer 2>&1) || die 8 >&2 err=$(dd if=/dev/sda of=${MBR_TMP} bs=2M count=1 status=noxfer 2>&1) || die 8
${HASHER} ${MBR_TMP} > ${MBR_FILE} ${HASHER} ${MBR_TMP} > ${MBR_FILE}
find /boot -type f -exec ${HASHER} --binary {} >> ${DIGEST_FILE} + find /boot -type f -exec ${HASHER} --binary {} >> ${DIGEST_FILE} +
if [ $? == 0 ] if [ $? == 0 ]
@ -83,7 +83,7 @@ then
die 7 die 7
fi fi
#Backup of good files #Backup of good files
tar -czpPf ${BACKUP_FILE} /boot ${MBR_TMP} ${MBR_FILE} tar -czpPf ${BACKUP_FILE} /boot ${MBR_TMP} ${MBR_FILE} ${DIGEST_FILE}
if [ $? == 0 ] if [ $? == 0 ]
then then
echo "Backup written to ${BACKUP_FILE}" echo "Backup written to ${BACKUP_FILE}"
@ -94,26 +94,22 @@ then
elif [ "${1}" == "check" ] elif [ "${1}" == "check" ]
then then
COUNTER=0 COUNTER=0
err=$(dd if=/dev/sda of=${MBR_TMP} bs=1M count=1 status=noxfer 2>&1) || die 8 >&2 err=$(dd if=/dev/sda of=${MBR_TMP} bs=2M count=1 status=noxfer 2>&1) || die 8
if $(${HASHER} --check --warn --quiet --strict ${MBR_FILE} > ${LOG_FILE}) if $(${HASHER} --check --warn --quiet --strict ${MBR_FILE} > ${LOG_FILE})
then then
echo "MBR ok" echo "MBR ok"
else else
echo " !! TIME TO PANIK: MBR WAS MODIFIED !!" echo " !! TIME TO PANIK: MBR WAS MODIFIED !!"
COUNTER=$((COUNTER + 1)) COUNTER=$((COUNTER + 1))
fi fi
if $(${HASHER} --check --warn --quiet --strict ${DIGEST_FILE} >> ${LOG_FILE}) if $(${HASHER} --check --warn --quiet --strict ${DIGEST_FILE} >> ${LOG_FILE})
then then
echo "/boot io" echo "/boot ok"
die 0 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))
die $COUNTER die $COUNTER
fi fi
elif [ "${1}" == "recover" ] elif [ "${1}" == "recover" ]
then then
@ -124,5 +120,3 @@ else
fi fi
die 0 die 0

View File

@ -15,7 +15,7 @@ start()
which hashboot.sh > /dev/null || return 1 which hashboot.sh > /dev/null || return 1
hashboot.sh check hashboot.sh check
if [ $? == 4 ] if [ $? -gt 0 ] && [ $? -le 3 ]
then then
echo -n "Recover files? [y/N] " echo -n "Recover files? [y/N] "
read -r yesno read -r yesno

View File

@ -19,7 +19,7 @@ case "$1" in
log_daemon_msg "Checking integrity of files in /boot" log_daemon_msg "Checking integrity of files in /boot"
hashboot.sh check hashboot.sh check
if [ $? == 4 ] if [ $? -gt 0 ] && [ $? -le 3 ]
then then
log_end_msg 4 log_end_msg 4