mirror of
https://github.com/troglobit/finit.git
synced 2026-10-20 11:19:35 +00:00
initctl: add companion delete command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
4c2bbf7d93
commit
49582c70c5
3 files changed
+27
-1
No files matched your search
+3
-1
@@ -681,9 +681,10 @@ static int usage(int rc)
|
||||
fprintf(stderr,
|
||||
" ls | list List all .conf in " FINIT_RCSD "\n"
|
||||
" create <CONF> Create .conf in %s\n"
|
||||
" delete <CONF> Delete .conf in %s\n"
|
||||
" edit <CONF> Edit .conf in %s\n"
|
||||
" touch <CONF> Change .conf in %s\n",
|
||||
avail, avail, avail);
|
||||
avail, avail, avail, avail);
|
||||
if (has_ena)
|
||||
fprintf(stderr,
|
||||
" enable <CONF> Enable .conf in %s\n", avail);
|
||||
@@ -750,6 +751,7 @@ int main(int argc, char *argv[])
|
||||
{ "touch", serv_touch },
|
||||
{ "edit", serv_edit },
|
||||
{ "create", serv_creat },
|
||||
{ "delete", serv_delete },
|
||||
{ "reload", do_reload },
|
||||
|
||||
{ "cond", do_cond },
|
||||
|
||||
+23
@@ -322,6 +322,29 @@ int serv_creat(char *arg)
|
||||
return fclose(fp);
|
||||
}
|
||||
|
||||
int serv_delete(char *arg)
|
||||
{
|
||||
char buf[256];
|
||||
char *fn;
|
||||
|
||||
if (!arg || !arg[0])
|
||||
errx(1, "missing argument to delete");
|
||||
|
||||
fn = conf(buf, sizeof(buf), arg, 0);
|
||||
if (!fn)
|
||||
errx(1, FINIT_RCSD " missing on system.");
|
||||
|
||||
if (!fexist(fn))
|
||||
errx(1, "Cannot find %s", fn);
|
||||
|
||||
if (yorn("Remove %s and any enabled symlink (y/N)? ", fn)) {
|
||||
serv_disable(arg);
|
||||
remove(fn);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
|
||||
@@ -30,6 +30,7 @@ int serv_disable (char *arg);
|
||||
int serv_touch (char *arg);
|
||||
int serv_edit (char *arg);
|
||||
int serv_creat (char *arg);
|
||||
int serv_delete (char *arg);
|
||||
|
||||
#endif /* FINIT_SERV_H_ */
|
||||
|
||||
|
||||
Reference in new issue
Block a user