mirror of
https://github.com/troglobit/finit.git
synced 2026-10-15 10:29:35 +00:00
Add hook to call shutdown script
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
1 parent
6afbcbdd6e
commit
f92438d42a
1 file changed
+9
-1
+9
-1
@@ -127,7 +127,7 @@ void signal_handler(int);
|
||||
void chld_handler(int);
|
||||
|
||||
static int debug = 0;
|
||||
|
||||
static char sdown[CMD_SIZE];
|
||||
|
||||
static void build_cmd(char *cmd, char *x, int len)
|
||||
{
|
||||
@@ -293,6 +293,11 @@ int main()
|
||||
build_cmd(hostname, x, HOSTNAME_SIZE);
|
||||
continue;
|
||||
}
|
||||
if (MATCH_CMD(line, "shutdown ", x)) {
|
||||
*sdown = 0;
|
||||
build_cmd(sdown, x, CMD_SIZE);
|
||||
continue;
|
||||
}
|
||||
if (MATCH_CMD(line, "module ", x)) {
|
||||
strcpy(cmd, "/sbin/modprobe ");
|
||||
build_cmd(cmd, x, CMD_SIZE);
|
||||
@@ -574,6 +579,9 @@ int main()
|
||||
void shutdown(int sig)
|
||||
{
|
||||
touch("/tmp/shutdown");
|
||||
if (sdown) {
|
||||
system(sdown);
|
||||
}
|
||||
|
||||
kill(-1, SIGTERM);
|
||||
|
||||
|
||||
Reference in new issue
Block a user