--- Begin Message ---
- To: submit@bugs.debian.org
- Subject: sysrqd: facility to also orderly shut down a remote computer
- From: Onno Kortmann <onno@gmx.net>
- Date: Tue, 12 Feb 2008 23:09:05 +0100
- Message-id: <200802122309.05266.onno@gmx.net>
Package: sysrqd
Version: sysrqd9-2
Severity: wishlist
Tags: patch
Hi,
the appended patch includes an additional, very simple interface to
the 'shutdown'
command in sysrqd. It allows to shut down or reboot a remote machine by
executing a command like
sysrq> -<shutdown-option><minutes>
where <shutdown-option> is one of the shutdown options '-r', '-h' etc. and
minutes is a mandatory one digit number defining the timeout in minutes.
For example "-h6" causes a shutdown and halt in 6 minutes.
The reason to have such a facility in sysrqd is
1. that sometimes an orderly shutdown (with proper stopping of network
connections)
is possible after a remount-ro (u)
2. this daemon seems to be the best place (except maybe a remote ssh key
for root?!) to have some kind of remote shutdown command for a
small set of computers which are all booted and shut down at the same
time.
Greetings,
Onno
-- System Information:
Debian Release: 4.0
APT prefers stable
APT policy: (900, 'stable'), (450, 'testing'), (225, 'unstable')
Architecture: amd64 (x86_64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.22-2-amd64
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
diff --git a/sysrqd.c b/sysrqd.c
index af19f20..00cecf5 100644
--- a/sysrqd.c
+++ b/sysrqd.c
@@ -101,9 +101,27 @@ read_cmd (int sock_client, int fd_sysrq)
if(buf == '\n')
write_prompt (sock_client);
- if((buf >= 48 && buf <= 57) ||
+ if((buf >= 48 && buf <= 57) || /* letter: commands to sysrq */
(buf >= 97 && buf <= 122 ))
write(fd_sysrq, &buf, 1);
+ else if (buf=='-') { /* '-' for shutdown/reboot */
+ char act;
+ read(sock_client, &act, 1);
+ if (act!='h' && act!='r' && act!='H' &&
+ act!='P' && act!='c')
+ continue;
+
+ if (act!='c') {
+ /* read delay argument (in minutes) */
+ read(sock_client, &buf, 1);
+ if (buf<'0' || buf>'9')
+ continue;
+ } else buf=' ';
+
+ char cmd[50];
+ snprintf(cmd, 50, SHUTDOWN_CMD, act, buf);
+ system(cmd);
+ }
}
while(read (sock_client, &buf, 1) && buf != 'q');
}
diff --git a/sysrqd.h b/sysrqd.h
index c6fe770..4d52dbf 100644
--- a/sysrqd.h
+++ b/sysrqd.h
@@ -7,5 +7,6 @@
#define AUTH_FILE "/etc/sysrqd.secret"
#define BINDIP_FILE "/etc/sysrqd.bind"
#define PID_FILE "/var/run/sysrqd.pid"
+#define SHUTDOWN_CMD "/bin/bash -c \"/sbin/shutdown -%c %c&\""
#define SYSRQD_PRIO -19
#define SYSRQD_LISTEN_PORT 4094
--- End Message ---
--- Begin Message ---
- To: 465520-close@bugs.debian.org
- Subject: Re: Bug#465520: sysrqd: facility to also orderly shut down a remote computer
- From: Chris Hofstaedtler <zeha@debian.org>
- Date: Thu, 23 Jan 2025 18:44:08 +0100
- Message-id: <Z5J_6DPmF-eBn0OX@per.namespace.at>
- In-reply-to: <20080225142946.GL5800@abydos.adm.naquadah.org>
- References: <200802122309.05266.onno@gmx.net> <20080225142946.GL5800@abydos.adm.naquadah.org>
On Mon, Feb 25, 2008 at 03:29:46PM +0100, Julien Danjou wrote:
> I don't feel like I will integrate this upstream because it's not the
> goal of sysrqd to do a such thing IMHO.
Looks like this will never happen, and then we don't need to keep
this bug open for nothing.
--- End Message ---