diff options
Diffstat (limited to 'package/alix-switch')
-rw-r--r-- | package/alix-switch/files/alix-switch | 8 | ||||
-rw-r--r-- | package/alix-switch/files/alix-switch.postinst | 2 | ||||
-rw-r--r-- | package/alix-switch/src/alix-switchd.c | 11 |
3 files changed, 11 insertions, 10 deletions
diff --git a/package/alix-switch/files/alix-switch b/package/alix-switch/files/alix-switch index ad439a221..b61a6a48f 100644 --- a/package/alix-switch/files/alix-switch +++ b/package/alix-switch/files/alix-switch @@ -1,9 +1,13 @@ #!/bin/sh # launched by alix-switchd in case of button event - +# f.e. boot rescue system once case "$1" in on) echo "alix-switch: on" + mount /dev/sda1 /boot/grub + grub-reboot 1 + umount /boot/grub + reboot ;; off) echo "alix-switch: off" @@ -12,4 +16,4 @@ case "$1" in echo "Usage: $0 {on|off}" ;; esac -exit 0 +exit $? diff --git a/package/alix-switch/files/alix-switch.postinst b/package/alix-switch/files/alix-switch.postinst index 6e0e60f12..28146bf44 100644 --- a/package/alix-switch/files/alix-switch.postinst +++ b/package/alix-switch/files/alix-switch.postinst @@ -1,3 +1,3 @@ #!/bin/sh . $IPKG_INSTROOT/etc/functions.sh -add_rcconf alix_switchd alix_switchd NO +add_rcconf alix_switch alix_switch YES diff --git a/package/alix-switch/src/alix-switchd.c b/package/alix-switch/src/alix-switchd.c index d98748fa1..78b52f19c 100644 --- a/package/alix-switch/src/alix-switchd.c +++ b/package/alix-switch/src/alix-switchd.c @@ -44,18 +44,15 @@ static sighandler_t handle_signal (int sig_nr, sighandler_t signalhandler) { static void start_daemon (void) { int i; - pid_t pid; - - if (setsid() > 0) - exit(EXIT_FAILURE); + pid_t pid, sid; handle_signal(SIGHUP, SIG_IGN); - if ((pid = fork ()) != 0) exit(EXIT_FAILURE); - - chdir("/"); umask(0); + if ((sid = setsid()) < 0) + exit(EXIT_FAILURE); + chdir("/"); for (i = sysconf(_SC_OPEN_MAX); i > 0; i--) close(i); } |