mirror of
https://github.com/troglobit/finit.git
synced 2026-10-16 10:39:35 +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
+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
|
||||
|
||||
Reference in new issue
Block a user