initctl: let -n ignore errors from enable/disable as well

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2023-03-27 14:27:16 +02:00
1 parent 7703d00e82
commit 8f1d1717f8
3 files changed
+5 -4

No files matched your search

+1 -1
View File
@@ -1267,7 +1267,7 @@ static int usage(int rc)
" -f, --force Ignore missing files and arguments, never prompt\n"
" -h, --help This help text\n"
" -j, --json JSON output in 'status' and 'cond' commands\n"
" -n, --noerr Ignore error for non-existent services\n"
" -n, --noerr Ignore error, e.g., already started/enabled/...\n"
" -1, --once Only one lap in commands like 'top'\n"
" -p, --plain Use plain table headings, no ctrl chars\n"
" -q, --quiet Silent, only return status of command\n"
+1
View File
@@ -37,6 +37,7 @@ extern int iforce; /* initctl -f */
extern int ionce; /* initctl -1 */
extern int heading; /* initctl -t */
extern int json; /* initctl -j */
extern int noerr; /* initctl -n */
extern int verbose; /* initctl -v */
extern int plain; /* initctl -p */
extern int quiet; /* initctl -q */
+3 -3
View File
@@ -282,7 +282,7 @@ int serv_enable(char *arg)
snprintf(argpath, sizeof(argpath), "%s/enabled/%s", finit_rcsd, arg);
if (fexist(argpath))
ERRX(1, "%s already enabled", arg);
ERRX(noerr ? 0 : 1, "%s already enabled", arg);
return symlink(path, argpath) != 0;
}
@@ -308,10 +308,10 @@ int do_disable(char *arg, int check)
dbg("Failed changing to %s/enabled/: %s", finit_rcsd, strerror(errno));
if (check && stat(arg, &st))
ERRX(6, "%s not (an) enabled (service).", arg);
ERRX(noerr ? 0 : 6, "%s not (an) enabled (service).", arg);
if (check && (st.st_mode & S_IFMT) == S_IFLNK)
ERRX(1, "cannot disable %s, not a symlink.", arg);
ERRX(noerr ? 0 : 1, "cannot disable %s, not a symlink.", arg);
return remove(arg) != 0;
}