mirror of
https://github.com/troglobit/finit.git
synced 2026-11-28 20:58:24 +00:00
initctl: Add support for touch <CONF>, mark .conf for reload
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
2f9b97b3a7
commit
bb3d9c8670
3 files changed
+28
No files matched your search
@@ -524,6 +524,7 @@ static int usage(int rc)
|
|||||||
" list List all .conf in /etc/finit.d/\n"
|
" list List all .conf in /etc/finit.d/\n"
|
||||||
" enable <CONF> Enable .conf in /etc/finit.d/available/\n"
|
" enable <CONF> Enable .conf in /etc/finit.d/available/\n"
|
||||||
" disable <CONF> Disable .conf in /etc/finit.d/[enabled/]\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 Reload *.conf in /etc/finit.d/ (activates changes)\n"
|
||||||
// " reload <JOB|NAME>[:ID] Reload (SIGHUP) service by job# or name\n"
|
// " reload <JOB|NAME>[:ID] Reload (SIGHUP) service by job# or name\n"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -566,6 +567,7 @@ int main(int argc, char *argv[])
|
|||||||
{ "list", serv_list },
|
{ "list", serv_list },
|
||||||
{ "enable", serv_enable },
|
{ "enable", serv_enable },
|
||||||
{ "disable", serv_disable },
|
{ "disable", serv_disable },
|
||||||
|
{ "touch", serv_touch },
|
||||||
{ "reload", do_reload },
|
{ "reload", do_reload },
|
||||||
|
|
||||||
{ "cond", do_cond },
|
{ "cond", do_cond },
|
||||||
|
|||||||
+25
@@ -24,6 +24,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <fcntl.h> /* Definition of AT_* constants */
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <lite/lite.h>
|
#include <lite/lite.h>
|
||||||
@@ -168,6 +169,30 @@ int serv_disable(char *arg)
|
|||||||
return remove(link) != 0;
|
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:
|
* Local Variables:
|
||||||
* indent-tabs-mode: t
|
* indent-tabs-mode: t
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
int serv_list (char *arg);
|
int serv_list (char *arg);
|
||||||
int serv_enable (char *arg);
|
int serv_enable (char *arg);
|
||||||
int serv_disable (char *arg);
|
int serv_disable (char *arg);
|
||||||
|
int serv_touch (char *arg);
|
||||||
|
|
||||||
#endif /* FINIT_SERV_H_ */
|
#endif /* FINIT_SERV_H_ */
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user