mirror of
https://github.com/troglobit/finit.git
synced 2026-11-07 16:01:08 +00:00
initctl: skip errors from disable while deleting services
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
928110b19e
commit
c5db989bed
1 file changed
+9
-4
+9
-4
@@ -190,7 +190,7 @@ int serv_enable(char *arg)
|
|||||||
return symlink(path, arg) != 0;
|
return symlink(path, arg) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int serv_disable(char *arg)
|
int do_disable(char *arg, int check)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char corr[40];
|
char corr[40];
|
||||||
@@ -209,15 +209,20 @@ int serv_disable(char *arg)
|
|||||||
err(1, "failed cd %s", FINIT_RCSD);
|
err(1, "failed cd %s", FINIT_RCSD);
|
||||||
chdir("enabled"); /* System *may* have enabled/ dir. */
|
chdir("enabled"); /* System *may* have enabled/ dir. */
|
||||||
|
|
||||||
if (stat(arg, &st))
|
if (check && stat(arg, &st))
|
||||||
errx(1, "%s not (an) enabled (service).", arg);
|
errx(1, "%s not (an) enabled (service).", arg);
|
||||||
|
|
||||||
if ((st.st_mode & S_IFMT) == S_IFLNK)
|
if (check && (st.st_mode & S_IFMT) == S_IFLNK)
|
||||||
errx(1, "cannot disable %s, not a symlink.", arg);
|
errx(1, "cannot disable %s, not a symlink.", arg);
|
||||||
|
|
||||||
return remove(arg) != 0;
|
return remove(arg) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int serv_disable(char *arg)
|
||||||
|
{
|
||||||
|
return do_disable(arg, 1);
|
||||||
|
}
|
||||||
|
|
||||||
int serv_touch(char *arg)
|
int serv_touch(char *arg)
|
||||||
{
|
{
|
||||||
char path[256];
|
char path[256];
|
||||||
@@ -351,7 +356,7 @@ int serv_delete(char *arg)
|
|||||||
errx(1, "Cannot find %s", fn);
|
errx(1, "Cannot find %s", fn);
|
||||||
|
|
||||||
if (yorn("Remove %s and any enabled symlink (y/N)? ", fn)) {
|
if (yorn("Remove %s and any enabled symlink (y/N)? ", fn)) {
|
||||||
serv_disable(arg);
|
do_disable(arg, 0);
|
||||||
remove(fn);
|
remove(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user