Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PREFIX?=/usr/local
DESTDIR?=
INSTALL?=install

SCRIPTS = "kreboot"

.PHONY: all
all:
@echo "Nothing to build, it is all bash :)"
@echo "Try make install"

.PHONY: install
install:
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin/
$(INSTALL) -m 755 $(SCRIPTS) $(DESTDIR)$(PREFIX)/bin

.PHONY: uninstall
uninstall:
./uninstall $(DESTDIR)$(PREFIX)/bin/ $(SCRIPTS)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is "./uninstall"? Do you forget to add it?

22 changes: 21 additions & 1 deletion kreboot
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ set -u

# defaults
wait=10
detach_wait=3

usage() {
cat << EOF
Usage: kreboot [option ...] [kernel|boot-index]
Options are:
--wait, -w N wait N seconds before reboot (default $wait)
--nowait don't wait, reboot immediately
--detach Schedule reboot and return. Suitable to remote reboot.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mix of spaces and tabs

--help, -h show this help message

Example:
Expand Down Expand Up @@ -48,6 +50,19 @@ while test $# -gt 0; do
--nowait)
wait=0
;;
--detach)
detach=yes
;;
--detach_wait)
if [ "$#" -lt 2 ]; then
uerr "Option $1 requires an argument"
fi
detach_wait=$2
if ! printf "%f" $detach_wait > /dev/null 2>&1; then
uerr "Option $1 argument not a number"
fi
shift
;;
-h|--help)
usage 0
;;
Expand Down Expand Up @@ -85,4 +100,9 @@ if [ "$wait" -ne 0 ]; then
sleep $wait
fi
kexec -l "$kernel" --initrd="$initrd" --command-line="root=$root $args"
systemctl kexec

if [ -z "detach" ]; then
systemctl kexec
else
setsid bash -c "sleep $detach_wait; systemctl kexec" &>/dev/null < /dev/null &
fi