2015-03-16 20:38:36 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# grub2-sign
|
|
|
|
# Signs everything important in /boot. Depends on grub2-verify.
|
2018-01-12 21:46:55 +01:00
|
|
|
# Author: Bandie
|
2015-03-16 20:38:36 +01:00
|
|
|
# Licence: GNU-GPLv3
|
|
|
|
|
2018-01-12 21:46:55 +01:00
|
|
|
function sign(){
|
|
|
|
for f in `find /boot -type f`
|
|
|
|
do
|
|
|
|
if gpg --detach-sign $f
|
|
|
|
then
|
|
|
|
echo $f signed.
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
2015-03-17 07:23:23 +01:00
|
|
|
|
2018-01-12 21:46:55 +01:00
|
|
|
|
|
|
|
# Running grub2-verify first to prevent bad people and double signing
|
2015-12-30 15:32:46 -06:00
|
|
|
echo "Running grub2-verify to check if everything is unsigned..." >&2
|
2015-03-16 20:38:36 +01:00
|
|
|
grub2-verify
|
2015-12-30 15:32:46 -06:00
|
|
|
if (( $? < 2 )); then
|
|
|
|
echo "Run grub2-unsign first." >&2
|
2015-03-16 20:38:36 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-03-17 07:23:23 +01:00
|
|
|
|
2018-01-12 21:46:55 +01:00
|
|
|
if ! sign
|
|
|
|
then
|
|
|
|
sign
|
|
|
|
else
|
|
|
|
echo -e "\nDone!"
|
2015-12-30 15:32:46 -06:00
|
|
|
fi
|
2015-03-17 07:54:03 +01:00
|
|
|
|