mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 14:02:52 +07:00
initctl: Add support for touch <CONF>, mark .conf for reload
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -524,6 +524,7 @@ static int usage(int rc)
|
||||
" list List all .conf in /etc/finit.d/\n"
|
||||
" enable <CONF> Enable .conf in /etc/finit.d/available/\n"
|
||||
" disable <CONF> Disable .conf in /etc/finit.d/[enabled/]\n"
|
||||
" touch <CONF> Mark .conf in /etc/finit.d/ for reload\n"
|
||||
" reload Reload *.conf in /etc/finit.d/ (activates changes)\n"
|
||||
// " reload <JOB|NAME>[:ID] Reload (SIGHUP) service by job# or name\n"
|
||||
"\n"
|
||||
@@ -566,6 +567,7 @@ int main(int argc, char *argv[])
|
||||
{ "list", serv_list },
|
||||
{ "enable", serv_enable },
|
||||
{ "disable", serv_disable },
|
||||
{ "touch", serv_touch },
|
||||
{ "reload", do_reload },
|
||||
|
||||
{ "cond", do_cond },
|
||||
|
||||
+25
@@ -24,6 +24,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <err.h>
|
||||
#include <fcntl.h> /* Definition of AT_* constants */
|
||||
#include <glob.h>
|
||||
#include <stdio.h>
|
||||
#include <lite/lite.h>
|
||||
@@ -168,6 +169,30 @@ int serv_disable(char *arg)
|
||||
return remove(link) != 0;
|
||||
}
|
||||
|
||||
int serv_touch(char *arg)
|
||||
{
|
||||
char corr[40];
|
||||
|
||||
if (!strstr(arg, ".conf")) {
|
||||
snprintf(corr, sizeof(corr), "%s.conf", arg);
|
||||
arg = corr;
|
||||
}
|
||||
|
||||
pushd(FINIT_RCSD);
|
||||
if (!fexist(arg)) {
|
||||
popd();
|
||||
if (!strstr(arg, "finit.conf"))
|
||||
errx(1, "Service %s is not enabled", arg);
|
||||
arg = FINIT_CONF;
|
||||
}
|
||||
|
||||
/* libite:touch() follows symlinks */
|
||||
if (utimensat(AT_FDCWD, arg, NULL, AT_SYMLINK_NOFOLLOW))
|
||||
err(1, "Failed marking %s for reload", arg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
int serv_list (char *arg);
|
||||
int serv_enable (char *arg);
|
||||
int serv_disable (char *arg);
|
||||
int serv_touch (char *arg);
|
||||
|
||||
#endif /* FINIT_SERV_H_ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user