mirror of
https://github.com/troglobit/finit.git
synced 2026-11-18 19:30:56 +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);
|
void chld_handler(int);
|
||||||
|
|
||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
|
static char sdown[CMD_SIZE];
|
||||||
|
|
||||||
static void build_cmd(char *cmd, char *x, int len)
|
static void build_cmd(char *cmd, char *x, int len)
|
||||||
{
|
{
|
||||||
@@ -293,6 +293,11 @@ int main()
|
|||||||
build_cmd(hostname, x, HOSTNAME_SIZE);
|
build_cmd(hostname, x, HOSTNAME_SIZE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (MATCH_CMD(line, "shutdown ", x)) {
|
||||||
|
*sdown = 0;
|
||||||
|
build_cmd(sdown, x, CMD_SIZE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (MATCH_CMD(line, "module ", x)) {
|
if (MATCH_CMD(line, "module ", x)) {
|
||||||
strcpy(cmd, "/sbin/modprobe ");
|
strcpy(cmd, "/sbin/modprobe ");
|
||||||
build_cmd(cmd, x, CMD_SIZE);
|
build_cmd(cmd, x, CMD_SIZE);
|
||||||
@@ -574,6 +579,9 @@ int main()
|
|||||||
void shutdown(int sig)
|
void shutdown(int sig)
|
||||||
{
|
{
|
||||||
touch("/tmp/shutdown");
|
touch("/tmp/shutdown");
|
||||||
|
if (sdown) {
|
||||||
|
system(sdown);
|
||||||
|
}
|
||||||
|
|
||||||
kill(-1, SIGTERM);
|
kill(-1, SIGTERM);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user