mirror of
https://github.com/troglobit/finit.git
synced 2026-11-03 13:28:27 +00:00
initctl: let touch command handle both rcsd and available dirs
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
689e6cd52a
commit
e9ed90cb34
1 file changed
+13
-14
+13
-14
@@ -213,27 +213,26 @@ int serv_disable(char *arg)
|
|||||||
|
|
||||||
int serv_touch(char *arg)
|
int serv_touch(char *arg)
|
||||||
{
|
{
|
||||||
char corr[40];
|
char path[256];
|
||||||
|
char *fn;
|
||||||
|
|
||||||
if (!arg || !arg[0])
|
if (!arg || !arg[0]) {
|
||||||
return serv_list(NULL);
|
warnx("missing argument to touch, may be one of:");
|
||||||
|
return serv_list("enabled");
|
||||||
if (!strstr(arg, ".conf")) {
|
|
||||||
snprintf(corr, sizeof(corr), "%s.conf", arg);
|
|
||||||
arg = corr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pushd(FINIT_RCSD);
|
fn = conf(path, sizeof(path), arg, 0);
|
||||||
if (!fexist(arg)) {
|
if (!fexist(fn)) {
|
||||||
popd();
|
|
||||||
if (!strstr(arg, "finit.conf"))
|
if (!strstr(arg, "finit.conf"))
|
||||||
errx(1, "Service %s is not enabled", arg);
|
errx(1, "%s not available.", arg);
|
||||||
arg = FINIT_CONF;
|
|
||||||
|
strlcpy(path, FINIT_CONF, sizeof(path));
|
||||||
|
fn = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libite:touch() follows symlinks */
|
/* libite:touch() follows symlinks */
|
||||||
if (utimensat(AT_FDCWD, arg, NULL, AT_SYMLINK_NOFOLLOW))
|
if (utimensat(AT_FDCWD, fn, NULL, AT_SYMLINK_NOFOLLOW))
|
||||||
err(1, "Failed marking %s for reload", arg);
|
err(1, "failed marking %s for reload", fn);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user