2015-03-16 19:38:36 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# grub2-sign
|
|
|
|
# Signs everything important in /boot. Depends on grub2-verify.
|
2018-01-12 20:46:55 +00:00
|
|
|
# Author: Bandie
|
2015-03-16 19:38:36 +00:00
|
|
|
# Licence: GNU-GPLv3
|
|
|
|
|
2018-01-12 20:46:55 +00: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 06:23:23 +00:00
|
|
|
|
2018-01-12 20:46:55 +00:00
|
|
|
|
|
|
|
# Running grub2-verify first to prevent bad people and double signing
|
2015-12-30 21:32:46 +00:00
|
|
|
echo "Running grub2-verify to check if everything is unsigned..." >&2
|
2015-03-16 19:38:36 +00:00
|
|
|
grub2-verify
|
2015-12-30 21:32:46 +00:00
|
|
|
if (( $? < 2 )); then
|
|
|
|
echo "Run grub2-unsign first." >&2
|
2015-03-16 19:38:36 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-03-17 06:23:23 +00:00
|
|
|
|
2018-01-12 20:46:55 +00:00
|
|
|
if ! sign
|
|
|
|
then
|
|
|
|
sign
|
|
|
|
else
|
|
|
|
echo -e "\nDone!"
|
2015-12-30 21:32:46 +00:00
|
|
|
fi
|
2015-03-17 06:54:03 +00:00
|
|
|
|