aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-02-08 21:11:44 +0000
committerRoy Marples <roy@marples.name>2008-02-08 21:11:44 +0000
commit09ff8eeecd3e4c3819f3c3783c9a56d398cd8ec3 (patch)
tree8417ab169af648afa1e6f6b15a22b62c57bd4b4c
parent04b1a62c4b3d4269b357c1d12bbd8c68389f1ad4 (diff)
rc-status -r now shows the current runlevel name.
-rw-r--r--man/rc-status.82
-rw-r--r--src/rc/rc-status.c10
2 files changed, 11 insertions, 1 deletions
diff --git a/man/rc-status.8 b/man/rc-status.8
index 732530d4..fb2c15b9 100644
--- a/man/rc-status.8
+++ b/man/rc-status.8
@@ -44,6 +44,8 @@ The options are as follows:
Show all runlevels and their services.
.It Fl l , -list
List all defined runlevels.
+.It fl r , -runlevel
+Print the current runlevel name.
.It Fl s , -servicelist
Show all services.
.It Fl u , -unused
diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c
index 5c7f1c60..9d73adb3 100644
--- a/src/rc/rc-status.c
+++ b/src/rc/rc-status.c
@@ -94,10 +94,11 @@ static void print_service (char *service)
#include "_usage.h"
#define extraopts "[runlevel1] [runlevel2] ..."
-#define getoptstring "alsu" getoptstring_COMMON
+#define getoptstring "alrsu" getoptstring_COMMON
static const struct option longopts[] = {
{"all", 0, NULL, 'a'},
{"list", 0, NULL, 'l'},
+ {"runlevel", 0, NULL, 'r'},
{"servicelist", 0, NULL, 's'},
{"unused", 0, NULL, 'u'},
longopts_COMMON
@@ -105,6 +106,7 @@ static const struct option longopts[] = {
static const char * const longopts_help[] = {
"Show services from all run levels",
"Show list of run levels",
+ "Show the name of the current runlevel",
"Show service list",
"Show services not assigned to any runlevel",
longopts_help_COMMON
@@ -137,6 +139,12 @@ int rc_status (int argc, char **argv)
rc_strlist_free (levels);
exit (EXIT_SUCCESS);
/* NOTREACHED */
+ case 'r':
+ level = rc_runlevel_get ();
+ printf ("%s\n", level);
+ free (level);
+ exit (EXIT_SUCCESS);
+ /* NOTREACHED */
case 's':
services = rc_services_in_runlevel (NULL);
STRLIST_FOREACH (services, service, i)