bash-stuff/update-grub-root-password.sh

14 lines
557 B
Bash
Executable File

#/bin/bash
echo "[i] Please enter your password TWICE pressing ENTER (RETURN) after EACH entry.";
echo "[i] There is no visible output.";
gphash=$(grub-mkpasswd-pbkdf2 -c 10000 | awk '/grub.pbkdf/{print$NF}' | sed -e 's:\.:\\\.:g');
if [ -z $gphash ] || ! [ -f /etc/grub.d/00_header ]; then
echo "[-] Could not update GRUB Password.";
exit 1;
fi;
echo "[+] Updating GRUB Password...";
sudo sed -i "s/.*password_pbkdf2 root grub\.pbkdf2.*/password_pbkdf2 root $gphash/" /etc/grub.d/00_header;
echo "[+] Updated GRUB Password!";
sudo grub-update;
exit 0;