Skip to content

Instantly share code, notes, and snippets.

@Nama
Last active June 11, 2016 12:35
Show Gist options
  • Save Nama/bb96b57359c59bd075e7cd1aabf9a7a1 to your computer and use it in GitHub Desktop.
Save Nama/bb96b57359c59bd075e7cd1aabf9a7a1 to your computer and use it in GitHub Desktop.
Script for Arch Linux. Hibernate can't continue if a new kernel is installed. So this script instead suggests to shutdown. Put in /etc/profile.d/ and run via command "hibernate". Should work with LTS and GRSEC kernels, too.
#!/bin/bash
KERNEL="/boot/vmlinuz-linux"
hibernate() {
grep $(uname -r) $KERNEL* > /dev/null
if [[ $? == 0 ]]; then
echo "Newest kernel is running, hibernating..."
systemctl hibernate
else
echo "New kernel is installed, can't continue after hibernate..."
read -n1 -s -p "Press any key to shutdown... or CTRL + C to cancel"
shutdown -h now
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment