mirror of https://schlomp.space/tastytea/hashboot
more safety. check if files exists..
parent
4920769d5b
commit
ed2415cc34
24
hashboot
24
hashboot
|
@ -132,31 +132,26 @@ then
|
||||||
then
|
then
|
||||||
die 0
|
die 0
|
||||||
else
|
else
|
||||||
for file in $(diff ${DIGEST_FILE} ${DIGEST_FILE_TMP} | grep '<' | cut -d'*' -f2 | sed 's/\ /\\ /g' );
|
for file in $(diff ${DIGEST_FILE} ${DIGEST_FILE_TMP} | grep -v '^#' | grep '<' | cut -d'*' -f2 | sed 's/\ /\\ /g' );
|
||||||
do
|
do
|
||||||
#lösche_aus_tar
|
#lösche_aus_tar
|
||||||
echo tar --delete -z -v -f $BACKUP_FILE $file
|
tar --delete -v -f $BACKUP_FILE $file
|
||||||
done
|
done
|
||||||
for file in $(diff ${DIGEST_FILE} ${DIGEST_FILE_TMP} | grep '>' | cut -d'*' -f2 | sed 's/\ /\\ /g' );
|
for file in $(diff ${DIGEST_FILE} ${DIGEST_FILE_TMP} | grep -v '^#' | grep '>' | cut -d'*' -f2 | sed 's/\ /\\ /g' );
|
||||||
do
|
do
|
||||||
echo tar -r -z -v -f $BACKUP_FILE $file
|
tar -r -v -f $BACKUP_FILE $file
|
||||||
done
|
done
|
||||||
|
|
||||||
#mv -v ${DIGEST_FILE_TMP} ${DIGEST_FILE} || die 7
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
write_hashes $DIGEST_FILE
|
write_hashes $DIGEST_FILE
|
||||||
fi
|
tar -cpPf ${BACKUP_FILE} ${MBR_TMP} /boot ${DIGEST_FILE} || die 7 "Error writing ${BACKUP_FILE}"
|
||||||
#Backup of good files
|
|
||||||
tar -czpPf ${BACKUP_FILE} /boot ${DIGEST_FILE}
|
|
||||||
if [ $? == 0 ]
|
|
||||||
then
|
|
||||||
echo "Backup written to ${BACKUP_FILE}"
|
echo "Backup written to ${BACKUP_FILE}"
|
||||||
else
|
|
||||||
die 7 "Error writing ${BACKUP_FILE}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [ "${1}" == "check" ]
|
elif [ "${1}" == "check" ]
|
||||||
then
|
then
|
||||||
|
[ -f ${DIGEST_FILE} ]
|
||||||
|
then
|
||||||
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
|
||||||
|
@ -171,6 +166,9 @@ then
|
||||||
COUNTER=$((COUNTER + 2))
|
COUNTER=$((COUNTER + 2))
|
||||||
die $COUNTER
|
die $COUNTER
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
#error no digest file
|
||||||
|
fi
|
||||||
elif [ "${1}" == "recover" ]
|
elif [ "${1}" == "recover" ]
|
||||||
then
|
then
|
||||||
echo "Restoring files from backup... (type yes or no for each file)"
|
echo "Restoring files from backup... (type yes or no for each file)"
|
||||||
|
|
Loading…
Reference in New Issue