Mini Shell
Direktori : /usr/local/bin/ |
|
Current File : //usr/local/bin/kreboot |
#!/bin/bash
###
### kexec wrapper for faster reboots.
###
kernel=""
for arg in "$@"; do
case "$arg" in
"latest" )
kernel="latest"
;;
"current" )
kernel="current"
;;
--help | -h)
echo "kreboot: Immediately sync then reinitialize the current or latest kernel using kexec instead of a hardware reboot"
echo "usage: kreboot [current|latest]"
echo "The purpose of this tool is to provide the option of faster recovery in reboots unrelated to hardware issues"
;;
* )
echo "usage: kreboot [current|latest]"
;;
esac
done
if [[ -z $kernel ]]; then
echo "Please select a kernel between \"current\" or \"latest\"."
else
echo "Loading $kernel kernel"
if [[ $kernel == "current" ]]; then
set -x
kexec -l /boot/vmlinuz-$(uname -r) --initrd=/boot/initramfs-$(uname -r).img --reuse-cmdline && sync && kexec -e
elif [[ $kernel == "latest" ]]; then
set -x
kexec -l $(find /boot/vmlinuz-* | sort -V | tail -1) --initrd=$(find /boot/initramfs-*.img -not -name "*kdump.img" | sort -V | tail -1) --reuse-cmdline && sync && kexec -e
fi
fi
Zerion Mini Shell 1.0