From f3837fd9c687ec40de7aab3a56ce75cc39aa2961 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Thu, 27 Nov 2003 13:18:47 +0000 Subject: allow to halt machine --- mdk-stage1/init.c | 13 ++++++++++--- move/Makefile | 4 +++- move/make_live | 2 +- move/tree/halt | 5 +++++ move/tree/halt_reboot | 5 ----- move/tree/reboot | 5 +++++ 6 files changed, 24 insertions(+), 10 deletions(-) create mode 100755 move/tree/halt delete mode 100755 move/tree/halt_reboot create mode 100755 move/tree/reboot diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c index ac9154dcd..44fc9a3e9 100644 --- a/mdk-stage1/init.c +++ b/mdk-stage1/init.c @@ -336,13 +336,17 @@ void unmount_filesystems(void) } } +int reboot_magic = 0x01234567; + int in_reboot(void) { int fd; if ((fd = open("/var/run/rebootctl", O_RDONLY, 0)) > 0) { - char buf[1]; + char buf[100]; int i = read(fd, buf, sizeof(buf)); close(fd); + if (strstr(buf, "halt")) + reboot_magic = 0x4321FEDC; return i > 0; } return 0; @@ -475,9 +479,12 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) sync(); sync(); if (!abnormal_termination) { - printf("automatic reboot in 10 seconds\n"); + if (reboot_magic == 0x01234567) + printf("automatic reboot in 10 seconds\n"); + else + printf("automatic poweroff in 10 seconds\n"); sleep(10); - reboot(0xfee1dead, 672274793, 0x01234567); + reboot(0xfee1dead, 672274793, reboot_magic); } else { printf("you may safely reboot or halt your system\n"); while (1); diff --git a/move/Makefile b/move/Makefile index 8f9b82583..ee8571ec6 100644 --- a/move/Makefile +++ b/move/Makefile @@ -7,7 +7,7 @@ ISO = /BIG/mdkmove.iso DATA_FILES = devices symlinks directories-to-create etcfiles all-etcfiles keyfiles \ BOOT-800-MOVE.jpg BOOT-1024-MOVE.jpg BOOT-1280-MOVE.jpg BOOT-1600-MOVE.jpg -PROGRAM_FILES = etc-monitorer.pl tree/startkde_move tree/wait4x tree/halt_reboot +PROGRAM_FILES = etc-monitorer.pl tree/startkde_move tree/wait4x LANG_FILES = $(shell perl -ne 'print $$1 if /ALLOWED_LANGS = qw\((.*)\)/' move.pm) STAGE1 = ../mdk-stage1 @@ -49,6 +49,8 @@ install: build sudo cp -f *.pm $(DEST_STAGE2) sudo cp -f $(addprefix $(INSTALL)/, $(INSTALL_FILES)) $(DEST_STAGE2) sudo cp -f $(PROGRAM_FILES) $(DEST_LIVETREE)/usr/bin + sudo rm -f $(DEST_LIVETREE)/usr/bin/{halt,reboot} #- symlinks to consolehelper + sudo cp -f tree/{halt,reboot} $(DEST_LIVETREE)/usr/bin sudo cp -f tree/X_move $(DEST_LIVETREE)/usr/X11R6/bin sudo rm -rf $(DEST_LIVETREE)/usr/share/langs diff --git a/move/make_live b/move/make_live index 1a9642b21..7422f7c39 100755 --- a/move/make_live +++ b/move/make_live @@ -137,4 +137,4 @@ substInFile { } "$::prefix/etc/rc.d/init.d/$_" foreach qw(xfs dm devfsd syslog); #- we're not using sysv init, we need to replace these -output("$::prefix/sbin/$_", "#!/bin/sh\nhalt_reboot"), chmod(0755, "$::prefix/sbin/$_") foreach qw(halt reboot); +unlink "$::prefix/sbin/$_" foreach qw(halt reboot); diff --git a/move/tree/halt b/move/tree/halt new file mode 100755 index 000000000..c8431ac03 --- /dev/null +++ b/move/tree/halt @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "halt" > /var/run/rebootctl +sudo killall -USR1 startkde_move +sudo killall X diff --git a/move/tree/halt_reboot b/move/tree/halt_reboot deleted file mode 100755 index b4b1d4ede..000000000 --- a/move/tree/halt_reboot +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -echo "reboot" > /var/run/rebootctl -sudo killall -USR1 startkde_move -sudo killall X diff --git a/move/tree/reboot b/move/tree/reboot new file mode 100755 index 000000000..b4b1d4ede --- /dev/null +++ b/move/tree/reboot @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "reboot" > /var/run/rebootctl +sudo killall -USR1 startkde_move +sudo killall X -- cgit v1.2.1