Rationalise more functions into rc_service_
This commit is contained in:
parent
837f43e163
commit
b19e646575
32
src/librc.c
32
src/librc.c
@ -132,7 +132,7 @@ bool rc_runlevel_exists (const char *runlevel)
|
|||||||
librc_hidden_def(rc_runlevel_exists)
|
librc_hidden_def(rc_runlevel_exists)
|
||||||
|
|
||||||
/* Resolve a service name to it's full path */
|
/* Resolve a service name to it's full path */
|
||||||
char *rc_resolve_service (const char *service)
|
char *rc_service_resolve (const char *service)
|
||||||
{
|
{
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
char *file;
|
char *file;
|
||||||
@ -165,7 +165,7 @@ char *rc_resolve_service (const char *service)
|
|||||||
snprintf (buffer, sizeof (buffer), RC_INITDIR "/%s", service);
|
snprintf (buffer, sizeof (buffer), RC_INITDIR "/%s", service);
|
||||||
return (rc_xstrdup (buffer));
|
return (rc_xstrdup (buffer));
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_resolve_service)
|
librc_hidden_def(rc_service_resolve)
|
||||||
|
|
||||||
bool rc_service_exists (const char *service)
|
bool rc_service_exists (const char *service)
|
||||||
{
|
{
|
||||||
@ -184,7 +184,7 @@ bool rc_service_exists (const char *service)
|
|||||||
service[len - 1] == 'h')
|
service[len - 1] == 'h')
|
||||||
return (false);
|
return (false);
|
||||||
|
|
||||||
file = rc_resolve_service (service);
|
file = rc_service_resolve (service);
|
||||||
if (rc_exists (file))
|
if (rc_exists (file))
|
||||||
retval = rc_is_exec (file);
|
retval = rc_is_exec (file);
|
||||||
free (file);
|
free (file);
|
||||||
@ -202,7 +202,7 @@ char **rc_service_options (const char *service)
|
|||||||
char *p = buffer;
|
char *p = buffer;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if (! (svc = rc_resolve_service (service)))
|
if (! (svc = rc_service_resolve (service)))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
snprintf (cmd, sizeof (cmd), ". '%s'; echo \"${opts}\"", svc);
|
snprintf (cmd, sizeof (cmd), ". '%s'; echo \"${opts}\"", svc);
|
||||||
@ -230,7 +230,7 @@ char *rc_service_description (const char *service, const char *option)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (! (svc = rc_resolve_service (service)))
|
if (! (svc = rc_service_resolve (service)))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (! option)
|
if (! option)
|
||||||
@ -279,14 +279,14 @@ bool rc_service_in_runlevel (const char *service, const char *runlevel)
|
|||||||
}
|
}
|
||||||
librc_hidden_def(rc_service_in_runlevel)
|
librc_hidden_def(rc_service_in_runlevel)
|
||||||
|
|
||||||
bool rc_mark_service (const char *service, const rc_service_state_t state)
|
bool rc_service_mark (const char *service, const rc_service_state_t state)
|
||||||
{
|
{
|
||||||
char *file;
|
char *file;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int skip_state = -1;
|
int skip_state = -1;
|
||||||
char *base;
|
char *base;
|
||||||
char *svc;
|
char *svc;
|
||||||
char *init = rc_resolve_service (service);
|
char *init = rc_service_resolve (service);
|
||||||
bool skip_wasinactive = false;
|
bool skip_wasinactive = false;
|
||||||
|
|
||||||
if (! service)
|
if (! service)
|
||||||
@ -408,7 +408,7 @@ bool rc_mark_service (const char *service, const rc_service_state_t state)
|
|||||||
free (init);
|
free (init);
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_mark_service)
|
librc_hidden_def(rc_service_mark)
|
||||||
|
|
||||||
rc_service_state_t rc_service_state (const char *service)
|
rc_service_state_t rc_service_state (const char *service)
|
||||||
{
|
{
|
||||||
@ -497,9 +497,9 @@ static pid_t _exec_service (const char *service, const char *arg)
|
|||||||
pid_t pid = -1;
|
pid_t pid = -1;
|
||||||
char *svc;
|
char *svc;
|
||||||
|
|
||||||
file = rc_resolve_service (service);
|
file = rc_service_resolve (service);
|
||||||
if (! rc_is_file (file)) {
|
if (! rc_is_file (file)) {
|
||||||
rc_mark_service (service, RC_SERVICE_STOPPED);
|
rc_service_mark (service, RC_SERVICE_STOPPED);
|
||||||
free (file);
|
free (file);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -548,23 +548,23 @@ int rc_waitpid (pid_t pid)
|
|||||||
}
|
}
|
||||||
librc_hidden_def(rc_waitpid)
|
librc_hidden_def(rc_waitpid)
|
||||||
|
|
||||||
pid_t rc_stop_service (const char *service)
|
pid_t rc_service_stop (const char *service)
|
||||||
{
|
{
|
||||||
if (rc_service_state (service) & RC_SERVICE_STOPPED)
|
if (rc_service_state (service) & RC_SERVICE_STOPPED)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
return (_exec_service (service, "stop"));
|
return (_exec_service (service, "stop"));
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_stop_service)
|
librc_hidden_def(rc_service_stop)
|
||||||
|
|
||||||
pid_t rc_start_service (const char *service)
|
pid_t rc_service_start (const char *service)
|
||||||
{
|
{
|
||||||
if (! rc_service_state (service) & RC_SERVICE_STOPPED)
|
if (! rc_service_state (service) & RC_SERVICE_STOPPED)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
return (_exec_service (service, "start"));
|
return (_exec_service (service, "start"));
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_start_service)
|
librc_hidden_def(rc_service_start)
|
||||||
|
|
||||||
bool rc_schedule_start_service (const char *service,
|
bool rc_schedule_start_service (const char *service,
|
||||||
const char *service_to_start)
|
const char *service_to_start)
|
||||||
@ -589,7 +589,7 @@ bool rc_schedule_start_service (const char *service,
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
init = rc_resolve_service (service_to_start);
|
init = rc_service_resolve (service_to_start);
|
||||||
svc = rc_xstrdup (service_to_start);
|
svc = rc_xstrdup (service_to_start);
|
||||||
file = rc_strcatpaths (dir, basename (svc), (char *) NULL);
|
file = rc_strcatpaths (dir, basename (svc), (char *) NULL);
|
||||||
free (svc);
|
free (svc);
|
||||||
@ -733,7 +733,7 @@ bool rc_service_add (const char *runlevel, const char *service)
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
init = rc_resolve_service (service);
|
init = rc_service_resolve (service);
|
||||||
svc = rc_xstrdup (service);
|
svc = rc_xstrdup (service);
|
||||||
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename (svc),
|
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename (svc),
|
||||||
(char *) NULL);
|
(char *) NULL);
|
||||||
|
@ -76,8 +76,6 @@ librc_hidden_proto(rc_is_file)
|
|||||||
librc_hidden_proto(rc_is_link)
|
librc_hidden_proto(rc_is_link)
|
||||||
librc_hidden_proto(rc_ls_dir)
|
librc_hidden_proto(rc_ls_dir)
|
||||||
librc_hidden_proto(rc_make_env)
|
librc_hidden_proto(rc_make_env)
|
||||||
librc_hidden_proto(rc_mark_service)
|
|
||||||
librc_hidden_proto(rc_resolve_service)
|
|
||||||
librc_hidden_proto(rc_rm_dir)
|
librc_hidden_proto(rc_rm_dir)
|
||||||
librc_hidden_proto(rc_runlevel_exists)
|
librc_hidden_proto(rc_runlevel_exists)
|
||||||
librc_hidden_proto(rc_runlevel_starting)
|
librc_hidden_proto(rc_runlevel_starting)
|
||||||
@ -91,6 +89,10 @@ librc_hidden_proto(rc_service_description)
|
|||||||
librc_hidden_proto(rc_service_exists)
|
librc_hidden_proto(rc_service_exists)
|
||||||
librc_hidden_proto(rc_service_in_runlevel)
|
librc_hidden_proto(rc_service_in_runlevel)
|
||||||
librc_hidden_proto(rc_service_options)
|
librc_hidden_proto(rc_service_options)
|
||||||
|
librc_hidden_proto(rc_service_mark)
|
||||||
|
librc_hidden_proto(rc_service_resolve)
|
||||||
|
librc_hidden_proto(rc_service_start)
|
||||||
|
librc_hidden_proto(rc_service_stop)
|
||||||
librc_hidden_proto(rc_services_in_runlevel)
|
librc_hidden_proto(rc_services_in_runlevel)
|
||||||
librc_hidden_proto(rc_services_in_state)
|
librc_hidden_proto(rc_services_in_state)
|
||||||
librc_hidden_proto(rc_services_scheduled)
|
librc_hidden_proto(rc_services_scheduled)
|
||||||
@ -100,8 +102,6 @@ librc_hidden_proto(rc_service_state)
|
|||||||
librc_hidden_proto(rc_set_runlevel)
|
librc_hidden_proto(rc_set_runlevel)
|
||||||
librc_hidden_proto(rc_set_service_daemon)
|
librc_hidden_proto(rc_set_service_daemon)
|
||||||
librc_hidden_proto(rc_set_service_option)
|
librc_hidden_proto(rc_set_service_option)
|
||||||
librc_hidden_proto(rc_start_service)
|
|
||||||
librc_hidden_proto(rc_stop_service)
|
|
||||||
librc_hidden_proto(rc_strcatpaths)
|
librc_hidden_proto(rc_strcatpaths)
|
||||||
librc_hidden_proto(rc_strlist_add)
|
librc_hidden_proto(rc_strlist_add)
|
||||||
librc_hidden_proto(rc_strlist_addu)
|
librc_hidden_proto(rc_strlist_addu)
|
||||||
|
30
src/rc.c
30
src/rc.c
@ -303,17 +303,17 @@ static int do_mark_service (int argc, char **argv)
|
|||||||
eerrorx ("%s: no service specified", applet);
|
eerrorx ("%s: no service specified", applet);
|
||||||
|
|
||||||
if (strcmp (applet, "mark_service_started") == 0)
|
if (strcmp (applet, "mark_service_started") == 0)
|
||||||
ok = rc_mark_service (argv[0], RC_SERVICE_STARTED);
|
ok = rc_service_mark (argv[0], RC_SERVICE_STARTED);
|
||||||
else if (strcmp (applet, "mark_service_stopped") == 0)
|
else if (strcmp (applet, "mark_service_stopped") == 0)
|
||||||
ok = rc_mark_service (argv[0], RC_SERVICE_STOPPED);
|
ok = rc_service_mark (argv[0], RC_SERVICE_STOPPED);
|
||||||
else if (strcmp (applet, "mark_service_inactive") == 0)
|
else if (strcmp (applet, "mark_service_inactive") == 0)
|
||||||
ok = rc_mark_service (argv[0], RC_SERVICE_INACTIVE);
|
ok = rc_service_mark (argv[0], RC_SERVICE_INACTIVE);
|
||||||
else if (strcmp (applet, "mark_service_starting") == 0)
|
else if (strcmp (applet, "mark_service_starting") == 0)
|
||||||
ok = rc_mark_service (argv[0], RC_SERVICE_STOPPING);
|
ok = rc_service_mark (argv[0], RC_SERVICE_STOPPING);
|
||||||
else if (strcmp (applet, "mark_service_stopping") == 0)
|
else if (strcmp (applet, "mark_service_stopping") == 0)
|
||||||
ok = rc_mark_service (argv[0], RC_SERVICE_STOPPING);
|
ok = rc_service_mark (argv[0], RC_SERVICE_STOPPING);
|
||||||
else if (strcmp (applet, "mark_service_coldplugged") == 0)
|
else if (strcmp (applet, "mark_service_coldplugged") == 0)
|
||||||
ok = rc_mark_service (argv[0], RC_SERVICE_COLDPLUGGED);
|
ok = rc_service_mark (argv[0], RC_SERVICE_COLDPLUGGED);
|
||||||
else
|
else
|
||||||
eerrorx ("%s: unknown applet", applet);
|
eerrorx ("%s: unknown applet", applet);
|
||||||
|
|
||||||
@ -1041,7 +1041,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
STRLIST_FOREACH (start_services, service, i)
|
STRLIST_FOREACH (start_services, service, i)
|
||||||
if (rc_allow_plug (service))
|
if (rc_allow_plug (service))
|
||||||
rc_mark_service (service, RC_SERVICE_COLDPLUGGED);
|
rc_service_mark (service, RC_SERVICE_COLDPLUGGED);
|
||||||
/* We need to dump this list now.
|
/* We need to dump this list now.
|
||||||
This may seem redunant, but only Linux needs this and saves on
|
This may seem redunant, but only Linux needs this and saves on
|
||||||
code bloat. */
|
code bloat. */
|
||||||
@ -1066,7 +1066,7 @@ int main (int argc, char **argv)
|
|||||||
tmp = rc_xmalloc (sizeof (char *) * j);
|
tmp = rc_xmalloc (sizeof (char *) * j);
|
||||||
snprintf (tmp, j, "net.%s", service);
|
snprintf (tmp, j, "net.%s", service);
|
||||||
if (rc_service_exists (tmp) && rc_allow_plug (tmp))
|
if (rc_service_exists (tmp) && rc_allow_plug (tmp))
|
||||||
rc_mark_service (tmp, RC_SERVICE_COLDPLUGGED);
|
rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED);
|
||||||
CHAR_FREE (tmp);
|
CHAR_FREE (tmp);
|
||||||
}
|
}
|
||||||
rc_strlist_free (start_services);
|
rc_strlist_free (start_services);
|
||||||
@ -1085,7 +1085,7 @@ int main (int argc, char **argv)
|
|||||||
tmp = rc_xmalloc (sizeof (char *) * j);
|
tmp = rc_xmalloc (sizeof (char *) * j);
|
||||||
snprintf (tmp, j, "moused.%s", service);
|
snprintf (tmp, j, "moused.%s", service);
|
||||||
if (rc_service_exists (tmp) && rc_allow_plug (tmp))
|
if (rc_service_exists (tmp) && rc_allow_plug (tmp))
|
||||||
rc_mark_service (tmp, RC_SERVICE_COLDPLUGGED);
|
rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED);
|
||||||
CHAR_FREE (tmp);
|
CHAR_FREE (tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1185,7 +1185,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
/* We always stop the service when in these runlevels */
|
/* We always stop the service when in these runlevels */
|
||||||
if (going_down) {
|
if (going_down) {
|
||||||
pid_t pid = rc_stop_service (service);
|
pid_t pid = rc_service_stop (service);
|
||||||
if (pid > 0 && ! rc_env_bool ("RC_PARALLEL"))
|
if (pid > 0 && ! rc_env_bool ("RC_PARALLEL"))
|
||||||
rc_waitpid (pid);
|
rc_waitpid (pid);
|
||||||
continue;
|
continue;
|
||||||
@ -1250,7 +1250,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
/* After all that we can finally stop the blighter! */
|
/* After all that we can finally stop the blighter! */
|
||||||
if (! found) {
|
if (! found) {
|
||||||
pid_t pid = rc_stop_service (service);
|
pid_t pid = rc_service_stop (service);
|
||||||
if (pid > 0 && ! rc_env_bool ("RC_PARALLEL"))
|
if (pid > 0 && ! rc_env_bool ("RC_PARALLEL"))
|
||||||
rc_waitpid (pid);
|
rc_waitpid (pid);
|
||||||
}
|
}
|
||||||
@ -1294,7 +1294,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
/* Re-add our coldplugged services if they stopped */
|
/* Re-add our coldplugged services if they stopped */
|
||||||
STRLIST_FOREACH (coldplugged_services, service, i)
|
STRLIST_FOREACH (coldplugged_services, service, i)
|
||||||
rc_mark_service (service, RC_SERVICE_COLDPLUGGED);
|
rc_service_mark (service, RC_SERVICE_COLDPLUGGED);
|
||||||
|
|
||||||
/* Order the services to start */
|
/* Order the services to start */
|
||||||
rc_strlist_add (&types, "ineed");
|
rc_strlist_add (&types, "ineed");
|
||||||
@ -1316,7 +1316,7 @@ int main (int argc, char **argv)
|
|||||||
char *token;
|
char *token;
|
||||||
|
|
||||||
while ((token = strsep (&p, ",")))
|
while ((token = strsep (&p, ",")))
|
||||||
rc_mark_service (token, RC_SERVICE_STARTED);
|
rc_service_mark (token, RC_SERVICE_STARTED);
|
||||||
free (service);
|
free (service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1349,7 +1349,7 @@ interactive_option:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remember the pid if we're running in parallel */
|
/* Remember the pid if we're running in parallel */
|
||||||
if ((pid = rc_start_service (service)))
|
if ((pid = rc_service_start (service)))
|
||||||
add_pid (pid);
|
add_pid (pid);
|
||||||
|
|
||||||
if (! rc_env_bool ("RC_PARALLEL")) {
|
if (! rc_env_bool ("RC_PARALLEL")) {
|
||||||
@ -1372,7 +1372,7 @@ interactive_option:
|
|||||||
char *token;
|
char *token;
|
||||||
|
|
||||||
while ((token = strsep (&p, ",")))
|
while ((token = strsep (&p, ",")))
|
||||||
rc_mark_service (token, RC_SERVICE_STOPPED);
|
rc_service_mark (token, RC_SERVICE_STOPPED);
|
||||||
free (service);
|
free (service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
src/rc.h
8
src/rc.h
@ -62,7 +62,7 @@ typedef enum
|
|||||||
/*! Resolves a service name to its full path.
|
/*! Resolves a service name to its full path.
|
||||||
* @param service to check
|
* @param service to check
|
||||||
* @return pointer to full path of service */
|
* @return pointer to full path of service */
|
||||||
char *rc_resolve_service (const char *service);
|
char *rc_service_resolve (const char *service);
|
||||||
/*! Checks if a service exists or not.
|
/*! Checks if a service exists or not.
|
||||||
* @param service to check
|
* @param service to check
|
||||||
* @return true if service exists, otherwise false */
|
* @return true if service exists, otherwise false */
|
||||||
@ -94,17 +94,17 @@ rc_service_state_t rc_service_state (const char *service);
|
|||||||
* @param service to mark
|
* @param service to mark
|
||||||
* @param state service should be in
|
* @param state service should be in
|
||||||
* @return true if service state change was successful, otherwise false */
|
* @return true if service state change was successful, otherwise false */
|
||||||
bool rc_mark_service (const char *service, rc_service_state_t state);
|
bool rc_service_mark (const char *service, rc_service_state_t state);
|
||||||
|
|
||||||
/*! Stop a service
|
/*! Stop a service
|
||||||
* @param service to stop
|
* @param service to stop
|
||||||
* @return pid of service stopping process */
|
* @return pid of service stopping process */
|
||||||
pid_t rc_stop_service (const char *service);
|
pid_t rc_service_stop (const char *service);
|
||||||
|
|
||||||
/*! Start a service
|
/*! Start a service
|
||||||
* @param service to start
|
* @param service to start
|
||||||
* @return pid of the service starting process */
|
* @return pid of the service starting process */
|
||||||
pid_t rc_start_service (const char *service);
|
pid_t rc_service_start (const char *service);
|
||||||
|
|
||||||
/*! Wait for a process to finish
|
/*! Wait for a process to finish
|
||||||
* @param pid to wait for
|
* @param pid to wait for
|
||||||
|
@ -241,7 +241,7 @@ static void start_services (char **list) {
|
|||||||
ewarn ("WARNING: %s is scheduled to started when %s has started",
|
ewarn ("WARNING: %s is scheduled to started when %s has started",
|
||||||
svc, applet);
|
svc, applet);
|
||||||
} else
|
} else
|
||||||
rc_start_service (svc);
|
rc_service_start (svc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,11 +278,11 @@ static void cleanup (void)
|
|||||||
rc_runlevel_stopping () &&
|
rc_runlevel_stopping () &&
|
||||||
(strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 ||
|
(strcmp (softlevel, RC_LEVEL_SHUTDOWN) == 0 ||
|
||||||
strcmp (softlevel, RC_LEVEL_REBOOT) == 0)))
|
strcmp (softlevel, RC_LEVEL_REBOOT) == 0)))
|
||||||
rc_mark_service (applet, RC_SERVICE_STOPPED);
|
rc_service_mark (applet, RC_SERVICE_STOPPED);
|
||||||
else if (state & RC_SERVICE_WASINACTIVE)
|
else if (state & RC_SERVICE_WASINACTIVE)
|
||||||
rc_mark_service (applet, RC_SERVICE_INACTIVE);
|
rc_service_mark (applet, RC_SERVICE_INACTIVE);
|
||||||
else
|
else
|
||||||
rc_mark_service (applet, RC_SERVICE_STARTED);
|
rc_service_mark (applet, RC_SERVICE_STARTED);
|
||||||
}
|
}
|
||||||
if (exclusive && rc_exists (exclusive))
|
if (exclusive && rc_exists (exclusive))
|
||||||
unlink (exclusive);
|
unlink (exclusive);
|
||||||
@ -566,7 +566,7 @@ static void svc_start (bool deps)
|
|||||||
else if (state & RC_SERVICE_INACTIVE && ! background)
|
else if (state & RC_SERVICE_INACTIVE && ! background)
|
||||||
ewarnx ("WARNING: %s has already started, but is inactive", applet);
|
ewarnx ("WARNING: %s has already started, but is inactive", applet);
|
||||||
|
|
||||||
if (! rc_mark_service (service, RC_SERVICE_STOPPING))
|
if (! rc_service_mark (service, RC_SERVICE_STOPPING))
|
||||||
eerrorx ("ERROR: %s has been started by something else", applet);
|
eerrorx ("ERROR: %s has been started by something else", applet);
|
||||||
|
|
||||||
make_exclusive (service);
|
make_exclusive (service);
|
||||||
@ -616,7 +616,7 @@ static void svc_start (bool deps)
|
|||||||
if (! rc_runlevel_starting ()) {
|
if (! rc_runlevel_starting ()) {
|
||||||
STRLIST_FOREACH (use_services, svc, i)
|
STRLIST_FOREACH (use_services, svc, i)
|
||||||
if (rc_service_state (svc) & RC_SERVICE_STOPPED) {
|
if (rc_service_state (svc) & RC_SERVICE_STOPPED) {
|
||||||
pid_t pid = rc_start_service (svc);
|
pid_t pid = rc_service_start (svc);
|
||||||
if (! rc_env_bool ("RC_PARALLEL"))
|
if (! rc_env_bool ("RC_PARALLEL"))
|
||||||
rc_waitpid (pid);
|
rc_waitpid (pid);
|
||||||
}
|
}
|
||||||
@ -673,7 +673,7 @@ static void svc_start (bool deps)
|
|||||||
|
|
||||||
/* Set the state now, then unlink our exclusive so that
|
/* Set the state now, then unlink our exclusive so that
|
||||||
our scheduled list is preserved */
|
our scheduled list is preserved */
|
||||||
rc_mark_service (service, RC_SERVICE_STOPPED);
|
rc_service_mark (service, RC_SERVICE_STOPPED);
|
||||||
unlink_mtime_test ();
|
unlink_mtime_test ();
|
||||||
|
|
||||||
rc_strlist_free (types);
|
rc_strlist_free (types);
|
||||||
@ -729,16 +729,16 @@ static void svc_start (bool deps)
|
|||||||
if (in_control ()) {
|
if (in_control ()) {
|
||||||
if (! started) {
|
if (! started) {
|
||||||
if (rc_service_state (service) & RC_SERVICE_WASINACTIVE)
|
if (rc_service_state (service) & RC_SERVICE_WASINACTIVE)
|
||||||
rc_mark_service (service, RC_SERVICE_INACTIVE);
|
rc_service_mark (service, RC_SERVICE_INACTIVE);
|
||||||
else {
|
else {
|
||||||
rc_mark_service (service, RC_SERVICE_STOPPED);
|
rc_service_mark (service, RC_SERVICE_STOPPED);
|
||||||
if (rc_runlevel_starting ())
|
if (rc_runlevel_starting ())
|
||||||
rc_mark_service (service, RC_SERVICE_FAILED);
|
rc_service_mark (service, RC_SERVICE_FAILED);
|
||||||
}
|
}
|
||||||
rc_plugin_run (RC_HOOK_SERVICE_START_DONE, applet);
|
rc_plugin_run (RC_HOOK_SERVICE_START_DONE, applet);
|
||||||
eerrorx ("ERROR: %s failed to start", applet);
|
eerrorx ("ERROR: %s failed to start", applet);
|
||||||
}
|
}
|
||||||
rc_mark_service (service, RC_SERVICE_STARTED);
|
rc_service_mark (service, RC_SERVICE_STARTED);
|
||||||
unlink_mtime_test ();
|
unlink_mtime_test ();
|
||||||
rc_plugin_run (RC_HOOK_SERVICE_START_DONE, applet);
|
rc_plugin_run (RC_HOOK_SERVICE_START_DONE, applet);
|
||||||
} else {
|
} else {
|
||||||
@ -754,7 +754,7 @@ static void svc_start (bool deps)
|
|||||||
services = rc_services_scheduled (service);
|
services = rc_services_scheduled (service);
|
||||||
STRLIST_FOREACH (services, svc, i)
|
STRLIST_FOREACH (services, svc, i)
|
||||||
if (rc_service_state (svc) & RC_SERVICE_STOPPED)
|
if (rc_service_state (svc) & RC_SERVICE_STOPPED)
|
||||||
rc_start_service (svc);
|
rc_service_start (svc);
|
||||||
rc_strlist_free (services);
|
rc_strlist_free (services);
|
||||||
services = NULL;
|
services = NULL;
|
||||||
|
|
||||||
@ -773,7 +773,7 @@ static void svc_start (bool deps)
|
|||||||
services = rc_services_scheduled (svc2);
|
services = rc_services_scheduled (svc2);
|
||||||
STRLIST_FOREACH (services, svc, i)
|
STRLIST_FOREACH (services, svc, i)
|
||||||
if (rc_service_state (svc) & RC_SERVICE_STOPPED)
|
if (rc_service_state (svc) & RC_SERVICE_STOPPED)
|
||||||
rc_start_service (svc);
|
rc_service_start (svc);
|
||||||
}
|
}
|
||||||
|
|
||||||
hook_out = 0;
|
hook_out = 0;
|
||||||
@ -802,7 +802,7 @@ static void svc_stop (bool deps)
|
|||||||
} else if (state & RC_SERVICE_STOPPING)
|
} else if (state & RC_SERVICE_STOPPING)
|
||||||
ewarnx ("WARNING: %s is already stopping", applet);
|
ewarnx ("WARNING: %s is already stopping", applet);
|
||||||
|
|
||||||
if (! rc_mark_service (service, RC_SERVICE_STOPPING))
|
if (! rc_service_mark (service, RC_SERVICE_STOPPING))
|
||||||
eerrorx ("ERROR: %s has been stopped by something else", applet);
|
eerrorx ("ERROR: %s has been stopped by something else", applet);
|
||||||
|
|
||||||
make_exclusive (service);
|
make_exclusive (service);
|
||||||
@ -847,7 +847,7 @@ static void svc_stop (bool deps)
|
|||||||
if (svcs & RC_SERVICE_STARTED ||
|
if (svcs & RC_SERVICE_STARTED ||
|
||||||
svcs & RC_SERVICE_INACTIVE)
|
svcs & RC_SERVICE_INACTIVE)
|
||||||
{
|
{
|
||||||
pid_t pid = rc_stop_service (svc);
|
pid_t pid = rc_service_stop (svc);
|
||||||
if (! rc_env_bool ("RC_PARALLEL"))
|
if (! rc_env_bool ("RC_PARALLEL"))
|
||||||
rc_waitpid (pid);
|
rc_waitpid (pid);
|
||||||
rc_strlist_add (&tmplist, svc);
|
rc_strlist_add (&tmplist, svc);
|
||||||
@ -871,7 +871,7 @@ static void svc_stop (bool deps)
|
|||||||
strcmp (softlevel, RC_LEVEL_REBOOT) == 0 ||
|
strcmp (softlevel, RC_LEVEL_REBOOT) == 0 ||
|
||||||
strcmp (softlevel, RC_LEVEL_SINGLE) == 0))
|
strcmp (softlevel, RC_LEVEL_SINGLE) == 0))
|
||||||
continue;
|
continue;
|
||||||
rc_mark_service (service, RC_SERVICE_FAILED);
|
rc_service_mark (service, RC_SERVICE_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
eerrorx ("ERROR: cannot stop %s as %s is still up",
|
eerrorx ("ERROR: cannot stop %s as %s is still up",
|
||||||
@ -913,17 +913,17 @@ static void svc_stop (bool deps)
|
|||||||
|
|
||||||
if (! stopped) {
|
if (! stopped) {
|
||||||
if (rc_service_state (service) & RC_SERVICE_WASINACTIVE)
|
if (rc_service_state (service) & RC_SERVICE_WASINACTIVE)
|
||||||
rc_mark_service (service, RC_SERVICE_INACTIVE);
|
rc_service_mark (service, RC_SERVICE_INACTIVE);
|
||||||
else
|
else
|
||||||
rc_mark_service (service, RC_SERVICE_STARTED);
|
rc_service_mark (service, RC_SERVICE_STARTED);
|
||||||
rc_plugin_run (RC_HOOK_SERVICE_STOP_DONE, applet);
|
rc_plugin_run (RC_HOOK_SERVICE_STOP_DONE, applet);
|
||||||
eerrorx ("ERROR: %s failed to stop", applet);
|
eerrorx ("ERROR: %s failed to stop", applet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_background)
|
if (in_background)
|
||||||
rc_mark_service (service, RC_SERVICE_INACTIVE);
|
rc_service_mark (service, RC_SERVICE_INACTIVE);
|
||||||
else
|
else
|
||||||
rc_mark_service (service, RC_SERVICE_STOPPED);
|
rc_service_mark (service, RC_SERVICE_STOPPED);
|
||||||
|
|
||||||
unlink_mtime_test ();
|
unlink_mtime_test ();
|
||||||
rc_plugin_run (RC_HOOK_SERVICE_STOP_DONE, applet);
|
rc_plugin_run (RC_HOOK_SERVICE_STOP_DONE, applet);
|
||||||
@ -1249,7 +1249,7 @@ int runscript (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
} else if (strcmp (optarg, "zap") == 0) {
|
} else if (strcmp (optarg, "zap") == 0) {
|
||||||
einfo ("Manually resetting %s to stopped state", applet);
|
einfo ("Manually resetting %s to stopped state", applet);
|
||||||
rc_mark_service (applet, RC_SERVICE_STOPPED);
|
rc_service_mark (applet, RC_SERVICE_STOPPED);
|
||||||
uncoldplug ();
|
uncoldplug ();
|
||||||
} else
|
} else
|
||||||
svc_exec (optarg, NULL);
|
svc_exec (optarg, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user