mirror of
https://github.com/troglobit/finit.git
synced 2026-10-20 11:19:35 +00:00
initctl: add show command to cat foo.conf, default finit.conf
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
9a24dfd98d
commit
d1efc60c84
3 files changed
+27
-1
No files matched your search
+19
@@ -138,6 +138,11 @@ static char *conf(char *path, size_t len, char *name, int creat)
|
||||
{
|
||||
char corr[40];
|
||||
|
||||
if (!name || !name[0]) {
|
||||
strlcpy(path, FINIT_CONF, len);
|
||||
return path;
|
||||
}
|
||||
|
||||
if (!strstr(name, ".conf")) {
|
||||
snprintf(corr, sizeof(corr), "%s.conf", name);
|
||||
name = corr;
|
||||
@@ -250,6 +255,20 @@ int serv_touch(char *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int serv_show(char *arg)
|
||||
{
|
||||
char path[256];
|
||||
char *fn;
|
||||
|
||||
fn = conf(path, sizeof(path), arg, creat);
|
||||
if (!fexist(fn)) {
|
||||
warnx("Cannot find %s", arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return systemf("cat %s", fn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to open an editor for the given file, if creat is given we
|
||||
* create a new file based on /lib/finit/sample.conf
|
||||
|
||||
Reference in new issue
Block a user