* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2012-01-10 3:22 Robin H. Johnson
0 siblings, 0 replies; 12+ messages in thread
From: Robin H. Johnson @ 2012-01-10 3:22 UTC (permalink / raw
To: gentoo-commits
commit: 66f4305e1cb596c3243a67e83beed0cb6d973eb8
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 10 03:20:47 2012 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Jan 10 03:20:47 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=66f4305e
rc/checkpath: tmpfiles.d backend creation code
This commit provides the checkpath applet with feature parity to
systemd's tmpfiles.c create_item function.
Very similarly to the systemd function, it does NOT do any of the
cleanup work in this function.
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
---
man/runscript.8 | 3 ++
src/rc/checkpath.c | 95 ++++++++++++++++++++++++++++++++++++---------------
2 files changed, 70 insertions(+), 28 deletions(-)
diff --git a/man/runscript.8 b/man/runscript.8
index 08f302e..6ad6031 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -296,8 +296,11 @@ Mark the service as coldplugged.
Mark the service as inactive.
.It Xo
.Ic checkpath
+.Op Fl D , -directory-truncate
.Op Fl d , -directory
+.Op Fl F , -file-truncate
.Op Fl f , -file
+.Op Fl p , -pipe
.Op Fl m , -mode Ar mode
.Op Fl o , owner Ar owner
.Ar path ...
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index c8bd8ad..4ad4ea7 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <features.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@@ -46,44 +47,68 @@
#include "einfo.h"
#include "rc-misc.h"
+typedef enum {
+ inode_unknown = 0,
+ inode_file = 1,
+ inode_dir = 2,
+ inode_fifo = 3,
+} inode_t;
+
extern const char *applet;
static int
-do_check(char *path, uid_t uid, gid_t gid, mode_t mode, int file)
+do_check(char *path, uid_t uid, gid_t gid, mode_t mode, inode_t type, bool trunc)
{
struct stat st;
- int fd;
+ int fd, flags;
if (stat(path, &st)) {
- if (file) {
+ if (type == inode_file) {
einfo("%s: creating file", path);
- if (!mode)
- mode = S_IRUSR | S_IWUSR | S_IRGRP |
- S_IWGRP | S_IROTH;
- if ((fd = open(path, O_CREAT, mode)) == -1) {
+ if (!mode) /* 664 */
+ mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
+ flags = O_CREAT|O_NDELAY|O_WRONLY|O_NOCTTY;
+#ifdef __USE_XOPEN2K8
+ flags |= O_CLOEXEC|O_NOFOLLOW;
+#endif
+ if (trunc)
+ flags |= O_TRUNC;
+ if ((fd = open(path, flags, mode)) == -1) {
eerror("%s: open: %s", applet, strerror(errno));
return -1;
}
close (fd);
- } else {
+ } else if (type == inode_dir) {
einfo("%s: creating directory", path);
- if (!mode)
+ if (!mode) /* 775 */
mode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH;
- if (mkdir(path, mode)) {
+ if (mkdir(path, mode) == -1) {
eerror("%s: mkdir: %s", applet,
strerror (errno));
return -1;
}
mode = 0;
+ } else if (type == inode_fifo) {
+ einfo("%s: creating fifo", path);
+ if (!mode) /* 600 */
+ mode = S_IRUSR | S_IWUSR;
+ if (mkfifo(path, mode) == -1) {
+ eerror("%s: mkfifo: %s", applet,
+ strerror (errno));
+ return -1;
+ }
}
} else {
- if ((file && S_ISDIR(st.st_mode)) ||
- (!file && !S_ISDIR(st.st_mode)))
- {
- if (file)
- eerror("%s: is a directory", path);
- else
- eerror("%s: is a file", path);
+ if (type != inode_dir && S_ISDIR(st.st_mode)) {
+ eerror("%s: is a directory", path);
+ return 1;
+ }
+ if (type != inode_file && S_ISREG(st.st_mode)) {
+ eerror("%s: is a file", path);
+ return 1;
+ }
+ if (type != inode_fifo && S_ISFIFO(st.st_mode)) {
+ eerror("%s: is a fifo", path);
return -1;
}
}
@@ -143,17 +168,23 @@ parse_owner(struct passwd **user, struct group **group, const char *owner)
#include "_usage.h"
#define extraopts "path1 path2 ..."
-#define getoptstring "dfm:o:" getoptstring_COMMON
+#define getoptstring "dDfFpm:o:" getoptstring_COMMON
static const struct option longopts[] = {
- { "directory", 0, NULL, 'd'},
- { "file", 0, NULL, 'f'},
- { "mode", 1, NULL, 'm'},
- { "owner", 1, NULL, 'o'},
+ { "directory", 0, NULL, 'd'},
+ { "directory-truncate", 0, NULL, 'D'},
+ { "file", 0, NULL, 'f'},
+ { "file-truncate", 0, NULL, 'F'},
+ { "pipe", 0, NULL, 'p'},
+ { "mode", 1, NULL, 'm'},
+ { "owner", 1, NULL, 'o'},
longopts_COMMON
};
static const char * const longopts_help[] = {
- "Check if a directory",
- "Check if a file",
+ "Create a directory if not exists",
+ "Create/empty directory",
+ "Create a file if not exists",
+ "Truncate file",
+ "Create a named pipe (FIFO) if not exists",
"Mode to check",
"Owner to check (user:group)",
longopts_help_COMMON
@@ -169,18 +200,26 @@ checkpath(int argc, char **argv)
mode_t mode = 0;
struct passwd *pw = NULL;
struct group *gr = NULL;
- bool file = 0;
+ inode_t type = inode_unknown;
int retval = EXIT_SUCCESS;
+ bool trunc = 0;
while ((opt = getopt_long(argc, argv, getoptstring,
longopts, (int *) 0)) != -1)
{
switch (opt) {
+ case 'D':
+ trunc = 1;
case 'd':
- file = 0;
+ type = inode_dir;
break;
+ case 'F':
+ trunc = 1;
case 'f':
- file = 1;
+ type = inode_file;
+ break;
+ case 'p':
+ type = inode_fifo;
break;
case 'm':
if (parse_mode(&mode, optarg) != 0)
@@ -208,7 +247,7 @@ checkpath(int argc, char **argv)
gid = gr->gr_gid;
while (optind < argc) {
- if (do_check(argv[optind], uid, gid, mode, file))
+ if (do_check(argv[optind], uid, gid, mode, type, trunc))
retval = EXIT_FAILURE;
optind++;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2012-01-15 1:11 Christian Ruppert
0 siblings, 0 replies; 12+ messages in thread
From: Christian Ruppert @ 2012-01-15 1:11 UTC (permalink / raw
To: gentoo-commits
commit: 30a56cdb4680f90e6c371c75c27c6ecec2d7aeec
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 15 01:10:35 2012 +0000
Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 01:10:35 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=30a56cdb
Add "ifstopped" command to runscript
Signed-off-by: Christian Ruppert <idl0r <AT> gentoo.org>
---
man/runscript.8 | 3 +++
src/rc/runscript.c | 8 +++++++-
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/man/runscript.8 b/man/runscript.8
index 6ad6031..dbc0b7d 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -32,6 +32,7 @@
.Op Fl D , -nodeps
.Op Fl d , -debug
.Op Fl s , -ifstarted
+.Op Fl S , -ifstopped
.Op Fl Z , -dry-run
.Op Ar command ...
.Sh DESCRIPTION
@@ -76,6 +77,8 @@ Set xtrace on in the shell to assist in debugging.
Ignore all dependency information the service supplies.
.It Fl s , -ifstarted
Only run the command if the service has been started.
+.It Fl S , -ifstopped
+Only run the command if the service has been stopped.
.It Fl q , -quiet
Turns off all informational output the service generates.
Output from any non OpenRC commands is not affected.
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 2f66971..8e0ced9 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1079,12 +1079,13 @@ service_plugable(void)
}
#include "_usage.h"
-#define getoptstring "dDsvl:Z" getoptstring_COMMON
+#define getoptstring "dDsSvl:Z" getoptstring_COMMON
#define extraopts "stop | start | restart | describe | zap"
static const struct option longopts[] = {
{ "debug", 0, NULL, 'd'},
{ "dry-run", 0, NULL, 'Z'},
{ "ifstarted", 0, NULL, 's'},
+ { "ifstopped", 0, NULL, 'S'},
{ "nodeps", 0, NULL, 'D'},
{ "lockfd", 1, NULL, 'l'},
longopts_COMMON
@@ -1093,6 +1094,7 @@ static const char *const longopts_help[] = {
"set xtrace when running the script",
"show what would be done",
"only run commands when started",
+ "only run commands when stopped",
"ignore dependencies",
"fd of the exclusive lock from rc",
longopts_help_COMMON
@@ -1235,6 +1237,10 @@ runscript(int argc, char **argv)
if (!(rc_service_state(service) & RC_SERVICE_STARTED))
exit(EXIT_FAILURE);
break;
+ case 'S':
+ if (!(rc_service_state(service) & RC_SERVICE_STOPPED))
+ exit(EXIT_FAILURE);
+ break;
case 'D':
deps = false;
break;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2012-01-26 20:51 William Hubbs
0 siblings, 0 replies; 12+ messages in thread
From: William Hubbs @ 2012-01-26 20:51 UTC (permalink / raw
To: gentoo-commits
commit: 7ea5c614d9c9e36c55f1da3d7fb894e83bbb56f3
Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 25 22:18:08 2012 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jan 26 20:42:18 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=7ea5c614
Add -W/--writable function to checkpath
Checkpath -W will use access(3p) to determine whether or not a path is
writable. This is more accurate than test(1p) because it also takes into
account whether or not the filesystem is mounted read-only.
Modified by William Hubbs to add the man page update.
---
man/runscript.8 | 5 +++++
src/rc/checkpath.c | 11 +++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/man/runscript.8 b/man/runscript.8
index 30fde94..5901f47 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -315,6 +315,11 @@ Mark the service as inactive.
.Xc
Checks to see if the path exists, is of the right type, owned by the right
people and has the correct access modes. If not, then it corrects the path.
+.It Ic checkpath
+.Op Fl W , -writable
+.Ar path
+.Xc
+checks to see if the path is writable.
.It Ic yesno Ar value
If
.Ar value
diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c
index b0914f3..7ebbb64 100644
--- a/src/rc/checkpath.c
+++ b/src/rc/checkpath.c
@@ -185,8 +185,8 @@ parse_owner(struct passwd **user, struct group **group, const char *owner)
}
#include "_usage.h"
-#define extraopts "path1 path2 ..."
-#define getoptstring "dDfFpm:o:" getoptstring_COMMON
+#define extraopts "path1 [path2] [...]"
+#define getoptstring "dDfFpm:o:W:" getoptstring_COMMON
static const struct option longopts[] = {
{ "directory", 0, NULL, 'd'},
{ "directory-truncate", 0, NULL, 'D'},
@@ -195,6 +195,7 @@ static const struct option longopts[] = {
{ "pipe", 0, NULL, 'p'},
{ "mode", 1, NULL, 'm'},
{ "owner", 1, NULL, 'o'},
+ { "writable", 1, NULL, 'W'},
longopts_COMMON
};
static const char * const longopts_help[] = {
@@ -205,6 +206,7 @@ static const char * const longopts_help[] = {
"Create a named pipe (FIFO) if not exists",
"Mode to check",
"Owner to check (user:group)",
+ "Check whether the path is writable or not",
longopts_help_COMMON
};
#include "_usage.c"
@@ -249,6 +251,11 @@ checkpath(int argc, char **argv)
eerrorx("%s: owner `%s' not found",
applet, optarg);
break;
+ case 'W':
+ if (argv[optind] != NULL)
+ ewarn("-W/--writable takes only one path, everything else will be ignored");
+ exit(!is_writable(optarg));
+ break;
case_RC_COMMON_GETOPT
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2013-04-28 18:04 William Hubbs
0 siblings, 0 replies; 12+ messages in thread
From: William Hubbs @ 2013-04-28 18:04 UTC (permalink / raw
To: gentoo-commits
commit: 10a4385e409b48d9aa60590c140d4ca6485a7a72
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Apr 28 17:51:12 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Apr 28 17:51:12 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=10a4385e
rc: allow switching runlevels without stopping services
OpenRC, by default, stops all services that are not listed in a runlevel
when rc is used to switch runlevels. This adds a -n/--no-stop command
line option to rc which tells it to skip stopping the services which are
not in the runlevel.
Reported-by: gentoo <AT> thoth.purplefrog.com
X-Gentoo-Bug: 372585
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=372585
---
man/rc.8 | 9 +++++----
src/rc/rc.c | 16 +++++++++++-----
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/man/rc.8 b/man/rc.8
index 0d645bf..dd45788 100644
--- a/man/rc.8
+++ b/man/rc.8
@@ -29,16 +29,17 @@
.Nd stops and starts services for the specified runlevel
.Sh SYNOPSIS
.Nm
+.Op Fl n , -no-stop
.Op Fl o , -override
.Op Ar runlevel
.Sh DESCRIPTION
.Nm
-first stops any services that are not for the runlevel and then starts any
-services in the runlevel and from stacked runlevels added by
+first stops any services that are not in the specified runlevel unless
+--no-stop is specified, then starts any services in the runlevel and
+stacked runlevels added by
.Nm rc-update
that are not currently started.
-If no runlevel is specified then we use the current runlevel the system
-is currently in.
+If no runlevel is specified, we use the current runlevel.
.Pp
There are some special runlevels that you should be aware of:
.Bl -tag -width "shutdown"
diff --git a/src/rc/rc.c b/src/rc/rc.c
index a5d7085..0e37182 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -729,16 +729,18 @@ handle_bad_signal(int sig)
#include "_usage.h"
#define usagestring "" \
"Usage: rc [options] [<runlevel>]"
-#define getoptstring "a:o:s:S" getoptstring_COMMON
+#define getoptstring "a:no:s:S" getoptstring_COMMON
static const struct option longopts[] = {
{ "applet", 1, NULL, 'a' },
- { "override", 1, NULL, 'o' },
- { "service", 1, NULL, 's' },
- { "sys", 0, NULL, 'S' },
+ { "no-stop", 0, NULL, 'n' },
+ { "override", 1, NULL, 'o' },
+ { "service", 1, NULL, 's' },
+ { "sys", 0, NULL, 'S' },
longopts_COMMON
};
static const char * const longopts_help[] = {
"runs the applet specified by the next argument",
+ "do not stop any services",
"override the next runlevel to change into\n"
"when leaving single user or boot runlevels",
"runs the service specified with the rest\nof the arguments",
@@ -762,6 +764,7 @@ main(int argc, char **argv)
int opt;
bool parallel;
int regen = 0;
+ bool nostop = false;
#ifdef __linux__
char *proc;
char *p;
@@ -812,6 +815,9 @@ main(int argc, char **argv)
/* Do nothing, actual logic in run_applets, this
* is a placeholder */
break;
+ case 'n':
+ nostop = true;
+ break;
case 'o':
if (*optarg == '\0')
optarg = NULL;
@@ -1022,7 +1028,7 @@ main(int argc, char **argv)
parallel = rc_conf_yesno("rc_parallel");
/* Now stop the services that shouldn't be running */
- if (stop_services)
+ if (stop_services && !nostop)
do_stop_services(newlevel, parallel, going_down);
/* Wait for our services to finish */
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2013-05-02 18:58 William Hubbs
0 siblings, 0 replies; 12+ messages in thread
From: William Hubbs @ 2013-05-02 18:58 UTC (permalink / raw
To: gentoo-commits
commit: a09a60c4cf6e390fc4c2964c4a7a3674214283ee
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed May 1 23:01:11 2013 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu May 2 18:52:27 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=a09a60c4
Add service applet
The service applet is equivalent to rc-service. This was added so that
we will be more compatible with Debian and Fedora.
Reported-by: cardoe <AT> gentoo.org
X-Gentoo-Bug: 468168
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=468168
---
man/Makefile | 2 +-
man/service.8 | 1 +
src/rc/Makefile | 2 +-
src/rc/rc-applets.c | 1 +
4 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/man/Makefile b/man/Makefile
index 3ad717d..4110c8f 100644
--- a/man/Makefile
+++ b/man/Makefile
@@ -2,7 +2,7 @@ MAN3= einfo.3 \
rc_config.3 rc_deptree.3 rc_find_pids.3 rc_plugin_hook.3 \
rc_runlevel.3 rc_service.3 rc_stringlist.3
MAN8= rc-service.8 rc-status.8 rc-update.8 rc.8 runscript.8 \
- start-stop-daemon.8
+ service.8 start-stop-daemon.8
# Handy macro to create symlinks
# This does rely on correctly formatting our manpages!
diff --git a/man/service.8 b/man/service.8
new file mode 100644
index 0000000..cd9dfa8
--- /dev/null
+++ b/man/service.8
@@ -0,0 +1 @@
+.so rc-service.8
diff --git a/src/rc/Makefile b/src/rc/Makefile
index dcd8e5a..a2e638e 100644
--- a/src/rc/Makefile
+++ b/src/rc/Makefile
@@ -11,7 +11,7 @@ SBINDIR= ${PREFIX}/sbin
LINKDIR= ${LIBEXECDIR}
BINLINKS= rc-status
-SBINLINKS= rc-service rc-update runscript start-stop-daemon
+SBINLINKS= rc-service rc-update runscript service start-stop-daemon
RC_BINLINKS= einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
eindent eoutdent esyslog eval_ecolors ewaitfile \
veinfo vewarn vebegin veend vewend veindent veoutdent \
diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
index 4481b08..64b6e88 100644
--- a/src/rc/rc-applets.c
+++ b/src/rc/rc-applets.c
@@ -507,6 +507,7 @@ static const struct {
{ "rc-service", rc_service, },
{ "rc-status", rc_status, },
{ "rc-update", rc_update, },
+ { "service", rc_service, },
{ "update-rc", rc_update, },
A(runscript),
{ "start-stop-daemon", start_stop_daemon, },
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2014-01-18 7:56 William Hubbs
0 siblings, 0 replies; 12+ messages in thread
From: William Hubbs @ 2014-01-18 7:56 UTC (permalink / raw
To: gentoo-commits
commit: abadaa04abe1833c6016f203e5d10168002bd8d3
Author: Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 13 15:18:40 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jan 13 16:41:38 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=abadaa04
rc-update: add option to remove a service from all runlevels
The -a option,which only applies to the del command, is used to remove a
service from all runlevels.
X-Gentoo-Bug: 497740
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=497740
---
man/rc-update.8 | 10 +++++++++-
src/rc/rc-update.c | 24 +++++++++++++++++++-----
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/man/rc-update.8 b/man/rc-update.8
index 3fa97a4..dca4b90 100644
--- a/man/rc-update.8
+++ b/man/rc-update.8
@@ -21,7 +21,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 2, 2009
+.Dd Jan 13, 2014
.Dt RC-UPDATE 8 SMM
.Os OpenRC
.Sh NAME
@@ -35,6 +35,7 @@
.Op Ar runlevel ...
.Nm
.Op Fl s , -stack
+.Op Fl a , -all
.Ar delete
.Ar service
.Op Ar runlevel ...
@@ -86,9 +87,16 @@ If the
.Fl s , -stack
option is given then we either add or remove the runlevel from the runlevel.
This allows inheritance of runlevels.
+
+If the
+.Fl a, -all
+option is given, we remove the service from all runlevels. This is
+useful, for example, to clean up the dangling symlinks after a service
+is removed.
.Sh SEE ALSO
.Xr openrc 8 ,
.Xr openrc-run 8 ,
.Xr rc-status 8
.Sh AUTHORS
.An Roy Marples <roy@marples.name>
+.An The OpenRC Team <openrc@gentoo.org>
diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c
index 8885637..d16af1b 100644
--- a/src/rc/rc-update.c
+++ b/src/rc/rc-update.c
@@ -199,13 +199,15 @@ show(RC_STRINGLIST *runlevels, bool verbose)
"Usage: rc-update [options] add <service> [<runlevel>...]\n" \
" or: rc-update [options] del <service> [<runlevel>...]\n" \
" or: rc-update [options] [show [<runlevel>...]]"
-#define getoptstring "su" getoptstring_COMMON
+#define getoptstring "asu" getoptstring_COMMON
static const struct option longopts[] = {
+ { "all", 0, NULL, 'a' },
{ "stack", 0, NULL, 's' },
{ "update", 0, NULL, 'u' },
longopts_COMMON
};
static const char * const longopts_help[] = {
+ "Process all runlevels",
"Stack a runlevel instead of a service",
"Force an update of the dependency tree",
longopts_help_COMMON
@@ -225,7 +227,7 @@ rc_update(int argc, char **argv)
char *service = NULL;
char *p;
int action = 0;
- bool verbose = false, stack = false;
+ bool verbose = false, stack = false, all_runlevels = false;
int opt;
int retval = EXIT_FAILURE;
int num_updated = 0;
@@ -235,6 +237,9 @@ rc_update(int argc, char **argv)
while ((opt = getopt_long(argc, argv, getoptstring,
longopts, (int *)0)) != -1)
switch (opt) {
+ case 'a':
+ all_runlevels = true;
+ break;
case 's':
stack = true;
break;
@@ -306,6 +311,10 @@ rc_update(int argc, char **argv)
eerror ("%s: no service specified", applet);
else {
if (action & DOADD) {
+ if (all_runlevels) {
+ rc_stringlist_free(runlevels);
+ eerrorx("%s: the -a option is invalid with add", applet);
+ }
actfunc = stack ? addstack : add;
} else if (action & DODELETE) {
actfunc = stack ? delstack : delete;
@@ -315,9 +324,14 @@ rc_update(int argc, char **argv)
}
if (!TAILQ_FIRST(runlevels)) {
- p = rc_runlevel_get();
- rc_stringlist_add(runlevels, p);
- free(p);
+ if (all_runlevels) {
+ free(runlevels);
+ runlevels = rc_runlevel_list();
+ } else {
+ p = rc_runlevel_get();
+ rc_stringlist_add(runlevels, p);
+ free(p);
+ }
}
if (!TAILQ_FIRST(runlevels)) {
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2016-01-28 19:08 William Hubbs
0 siblings, 0 replies; 12+ messages in thread
From: William Hubbs @ 2016-01-28 19:08 UTC (permalink / raw
To: gentoo-commits
commit: 8a7e4d38a74c714e1a532e1b7a53fd2a5c528b63
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Sep 21 18:54:51 2014 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Jan 28 18:57:11 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=8a7e4d38
rc-service: add --ifinactive and --ifnotstarted flags
X-Gentoo-Bug: 523174
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=523174
man/rc-service.8 | 15 +++++++++++++++
src/rc/rc-service.c | 20 +++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/man/rc-service.8 b/man/rc-service.8
index 9260329..80deb5e 100644
--- a/man/rc-service.8
+++ b/man/rc-service.8
@@ -20,6 +20,14 @@
.Ar service cmd
.Op Ar ...
.Nm
+.Op Fl I , -ifinactive
+.Ar service cmd
+.Op Ar ...
+.Nm
+.Op Fl N , -ifnotstarted
+.Ar service cmd
+.Op Ar ...
+.Nm
.Fl e , -exists
.Ar service
.Nm
@@ -36,6 +44,13 @@ If
is given then
.Nm
returns 0 even if the service does not exist.
+If
+.Fl I , -ifinactive
+or
+.Fl N , -ifnotstarted
+is given then
+.Nm
+returns 0 if the service exists but is in the wrong state.
.Pp
If given the
.Fl l , -list
diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c
index 8e9da44..3fd94b2 100644
--- a/src/rc/rc-service.c
+++ b/src/rc/rc-service.c
@@ -29,10 +29,12 @@
const char *applet = NULL;
const char *extraopts = NULL;
-const char *getoptstring = "e:ilr:" getoptstring_COMMON;
+const char *getoptstring = "e:ilr:IN" getoptstring_COMMON;
const struct option longopts[] = {
{ "exists", 1, NULL, 'e' },
{ "ifexists", 0, NULL, 'i' },
+ { "ifinactive", 0, NULL, 'I' },
+ { "ifnotstarted", 0, NULL, 'N' },
{ "list", 0, NULL, 'l' },
{ "resolve", 1, NULL, 'r' },
longopts_COMMON
@@ -40,6 +42,8 @@ const struct option longopts[] = {
const char * const longopts_help[] = {
"tests if the service exists or not",
"if the service exists then run the command",
+ "if the service is inactive then run the command",
+ "if the service is not started then run the command",
"list all available services",
"resolve the service name to an init script",
longopts_help_COMMON
@@ -56,7 +60,10 @@ int main(int argc, char **argv)
char *service;
RC_STRINGLIST *list;
RC_STRING *s;
+ RC_SERVICE state;
bool if_exists = false;
+ bool if_inactive = false;
+ bool if_notstarted = false;
applet = basename_c(argv[0]);
/* Ensure that we are only quiet when explicitly told to be */
@@ -77,6 +84,12 @@ int main(int argc, char **argv)
case 'i':
if_exists = true;
break;
+ case 'I':
+ if_inactive = true;
+ break;
+ case 'N':
+ if_notstarted = true;
+ break;
case 'l':
list = rc_services_in_runlevel(NULL);
if (TAILQ_FIRST(list) == NULL)
@@ -113,6 +126,11 @@ int main(int argc, char **argv)
return 0;
eerrorx("%s: service `%s' does not exist", applet, *argv);
}
+ state = rc_service_state(*argv);
+ if (if_inactive && ! (state & RC_SERVICE_INACTIVE))
+ return 0;
+ if (if_notstarted && (state & RC_SERVICE_STARTED))
+ return 0;
*argv = service;
execv(*argv, argv);
eerrorx("%s: %s", applet, strerror(errno));
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2017-04-12 22:57 William Hubbs
0 siblings, 0 replies; 12+ messages in thread
From: William Hubbs @ 2017-04-12 22:57 UTC (permalink / raw
To: gentoo-commits
commit: 05738bfce120114037d4f02c67ec740813f94b89
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Apr 12 22:56:30 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Apr 12 22:56:36 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=05738bfc
init: add re-exec capability
This will allow the re-execution of the init process after upgrading
OpenRC.
man/openrc-shutdown.8 | 7 ++++++-
src/rc/openrc-init.c | 22 +++++++++++++++++++---
src/rc/openrc-shutdown.c | 14 ++++++++++++--
3 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/man/openrc-shutdown.8 b/man/openrc-shutdown.8
index 98ec64a6..eae16ae8 100644
--- a/man/openrc-shutdown.8
+++ b/man/openrc-shutdown.8
@@ -19,11 +19,13 @@
.Op Fl H , -halt
.Op Fl k , -kexec
.Op Fl p , -poweroff
+.Op Fl R , -reexec
.Op Fl r , -reboot
.Sh DESCRIPTION
.Nm
is the utility that communicates with openrc-init(8) to bring down the
-system. The following options affect how the system is brought down:
+system or instruct openrc-init to re-execute itself. It supports the
+following options:
.Bl -tag -width "poweroff"
.It Fl H , -halt
Stop all services, kill all remaining processes and halt the system.
@@ -32,6 +34,9 @@ Stop all services, kill all processes and boot directly into a new
kernel loaded via kexec(8).
.It Fl p , -poweroff
Stop all services, kill all processes and power off the system.
+.It Fl R , -reexec
+instruct openrc-init to re-exec itself. This should be used after an
+upgrade of OpenRC if you are using openrc-init as your init process.
.It Fl r , -reboot
Stop all services, kill all processes and reboot the system.
.El
diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c
index fb3347a4..61052806 100644
--- a/src/rc/openrc-init.c
+++ b/src/rc/openrc-init.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -79,6 +80,12 @@ static void init(const char *default_runlevel)
waitpid(pid, NULL, 0);
}
+static void handle_reexec(char *my_name)
+{
+ execl(my_name, my_name, "reexec", NULL);
+ return;
+}
+
static void handle_shutdown(const char *runlevel, int cmd)
{
pid_t pid;
@@ -123,10 +130,11 @@ static void signal_handler(int sig)
int main(int argc, char **argv)
{
- char *default_runlevel = NULL;
+ char *default_runlevel;
char buf[2048];
int count;
FILE *fifo;
+ bool reexec = false;
struct sigaction sa;
if (getpid() != 1)
@@ -134,16 +142,22 @@ int main(int argc, char **argv)
if (argc > 1)
default_runlevel = argv[1];
+ else
+ default_runlevel = NULL;
+
+ if (default_runlevel && strcmp(default_runlevel, "reexec") == 0)
+ reexec = true;
printf("OpenRC init version %s starting\n", VERSION);
- init(default_runlevel);
+ if (! reexec)
+ init(default_runlevel);
memset(&sa, 0, sizeof(sa));
sa.sa_handler = signal_handler;
sigaction(SIGCHLD, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
reboot(RB_DISABLE_CAD);
- if (mkfifo(RC_INIT_FIFO, 0600) == -1)
+ if (mkfifo(RC_INIT_FIFO, 0600) == -1 && errno != EEXIST)
perror("mkfifo");
for (;;) {
@@ -166,6 +180,8 @@ int main(int argc, char **argv)
handle_shutdown("shutdown", RB_POWER_OFF);
else if (strcmp(buf, "reboot") == 0)
handle_shutdown("reboot", RB_AUTOBOOT);
+ else if (strcmp(buf, "reexec") == 0)
+ handle_reexec(argv[0]);
}
return 0;
}
diff --git a/src/rc/openrc-shutdown.c b/src/rc/openrc-shutdown.c
index 978e8a68..8905d354 100644
--- a/src/rc/openrc-shutdown.c
+++ b/src/rc/openrc-shutdown.c
@@ -35,11 +35,12 @@
const char *applet = NULL;
const char *extraopts = NULL;
-const char *getoptstring = "kpr" getoptstring_COMMON;
+const char *getoptstring = "HkpRr" getoptstring_COMMON;
const struct option longopts[] = {
{ "halt", no_argument, NULL, 'H'},
{ "kexec", no_argument, NULL, 'k'},
{ "poweroff", no_argument, NULL, 'p'},
+ { "reexec", no_argument, NULL, 'R'},
{ "reboot", no_argument, NULL, 'r'},
longopts_COMMON
};
@@ -47,11 +48,13 @@ const char * const longopts_help[] = {
"halt the system",
"reboot the system using kexec",
"power off the system",
+ "re-execute init (use after upgrading)",
"reboot the system",
longopts_help_COMMON
};
const char *usagestring = NULL;
-const char *exclusive = "Select one of --halt, --kexec, --poweroff or --reboot";
+const char *exclusive = "Select one of "
+"--halt, --kexec, --poweroff, --reexec or --reboot";
static void send_cmd(const char *cmd)
{
@@ -79,6 +82,7 @@ int main(int argc, char **argv)
bool do_kexec = false;
bool do_poweroff = false;
bool do_reboot = false;
+ bool do_reexec = false;
applet = basename_c(argv[0]);
if (geteuid() != 0)
@@ -99,6 +103,10 @@ if (geteuid() != 0)
do_poweroff = true;
cmd_count++;
break;
+ case 'R':
+ do_reexec = true;
+ cmd_count++;
+ break;
case 'r':
do_reboot = true;
cmd_count++;
@@ -118,5 +126,7 @@ if (geteuid() != 0)
send_cmd("poweroff");
else if (do_reboot)
send_cmd("reboot");
+ else if (do_reexec)
+ send_cmd("reexec");
return 0;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2017-05-22 17:54 William Hubbs
0 siblings, 0 replies; 12+ messages in thread
From: William Hubbs @ 2017-05-22 17:54 UTC (permalink / raw
To: gentoo-commits
commit: 1ece16bfcd0ab71d2f9fe17a75ee6184e0fa4828
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon May 22 17:42:37 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon May 22 17:42:37 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=1ece16bf
openrc-shutdown: add dry-run option
man/openrc-shutdown.8 | 3 +++
src/rc/openrc-shutdown.c | 31 ++++++++++++++++++++-----------
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/man/openrc-shutdown.8 b/man/openrc-shutdown.8
index d0e95e24..5d81c4af 100644
--- a/man/openrc-shutdown.8
+++ b/man/openrc-shutdown.8
@@ -27,6 +27,9 @@ is the utility that communicates with openrc-init(8) to bring down the
system or instruct openrc-init to re-execute itself. It supports the
following options:
.Bl -tag -width "poweroff"
+.It Fl d , -dry-run
+Print the action that would be taken without executing it. This is to
+allow testing.
.It Fl H , -halt
Stop all services, kill all remaining processes and halt the system.
.It Fl k , -kexec
diff --git a/src/rc/openrc-shutdown.c b/src/rc/openrc-shutdown.c
index 0ed77445..ecb251a8 100644
--- a/src/rc/openrc-shutdown.c
+++ b/src/rc/openrc-shutdown.c
@@ -35,8 +35,9 @@
const char *applet = NULL;
const char *extraopts = NULL;
-const char *getoptstring = "HkpRr" getoptstring_COMMON;
+const char *getoptstring = "dHkpRr" getoptstring_COMMON;
const struct option longopts[] = {
+ { "dry-run", no_argument, NULL, 'd'},
{ "halt", no_argument, NULL, 'H'},
{ "kexec", no_argument, NULL, 'k'},
{ "poweroff", no_argument, NULL, 'p'},
@@ -45,6 +46,7 @@ const struct option longopts[] = {
longopts_COMMON
};
const char * const longopts_help[] = {
+ "print actions instead of executing them",
"halt the system",
"reboot the system using kexec",
"power off the system",
@@ -56,13 +58,16 @@ const char *usagestring = NULL;
const char *exclusive = "Select one of "
"--halt, --kexec, --poweroff, --reexec or --reboot";
-static void send_cmd(const char *cmd)
+static void send_cmd(const char *cmd, bool dryrun)
{
FILE *fifo;
size_t ignored;
+ if (dryrun) {
+ einfo("Would send %s to init", cmd);
+ return;
+ }
fifo = fopen(RC_INIT_FIFO, "w");
-
if (!fifo) {
perror("fopen");
return;
@@ -78,6 +83,7 @@ int main(int argc, char **argv)
{
int opt;
int cmd_count = 0;
+ bool do_dryrun = false;
bool do_halt = false;
bool do_kexec = false;
bool do_poweroff = false;
@@ -85,12 +91,13 @@ int main(int argc, char **argv)
bool do_reexec = false;
applet = basename_c(argv[0]);
-if (geteuid() != 0)
- eerrorx("%s: you must be root\n", applet);
while ((opt = getopt_long(argc, argv, getoptstring,
longopts, (int *) 0)) != -1)
{
switch (opt) {
+ case 'd':
+ do_dryrun = true;
+ break;
case 'H':
do_halt = true;
cmd_count++;
@@ -114,21 +121,23 @@ if (geteuid() != 0)
case_RC_COMMON_GETOPT
}
}
+if (geteuid() != 0 && ! do_dryrun)
+ eerrorx("%s: you must be root\n", applet);
if (cmd_count > 1) {
eerror("%s: %s\n", applet, exclusive);
usage(EXIT_FAILURE);
}
if (do_halt)
- send_cmd("halt");
+ send_cmd("halt", do_dryrun);
else if (do_kexec)
- send_cmd("kexec");
+ send_cmd("kexec", do_dryrun);
else if (do_poweroff)
- send_cmd("poweroff");
+ send_cmd("poweroff", do_dryrun);
else if (do_reboot)
- send_cmd("reboot");
+ send_cmd("reboot", do_dryrun);
else if (do_reexec)
- send_cmd("reexec");
+ send_cmd("reexec", do_dryrun);
else
- send_cmd("single");
+ send_cmd("single", do_dryrun);
return 0;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2017-05-22 17:54 William Hubbs
0 siblings, 0 replies; 12+ messages in thread
From: William Hubbs @ 2017-05-22 17:54 UTC (permalink / raw
To: gentoo-commits
commit: 0cfd0dd9ef580ed9dc563ccc164d70efe8f299db
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon May 22 17:15:15 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon May 22 17:15:15 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=0cfd0dd9
openrc-shutdown: move to single user mode by default
To be more compatible with sysvinit, move to single user mode if no
options are specified on the command line.
man/openrc-shutdown.8 | 5 ++++-
src/rc/openrc-shutdown.c | 4 +++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/man/openrc-shutdown.8 b/man/openrc-shutdown.8
index eae16ae8..d0e95e24 100644
--- a/man/openrc-shutdown.8
+++ b/man/openrc-shutdown.8
@@ -8,7 +8,7 @@
.\" This file may not be copied, modified, propagated, or distributed
.\" except according to the terms contained in the LICENSE file.
.\"
-.Dd April 6, 2017
+.Dd May 22, 2017
.Dt openrc-shutdown 8 SMM
.Os OpenRC
.Sh NAME
@@ -40,6 +40,9 @@ upgrade of OpenRC if you are using openrc-init as your init process.
.It Fl r , -reboot
Stop all services, kill all processes and reboot the system.
.El
+.Pp
+If none of these options are given, the default is to move the system
+into single user mode.
.Sh SEE ALSO
.Xr openrc-init 8 ,
.Xr kexec 8 ,
diff --git a/src/rc/openrc-shutdown.c b/src/rc/openrc-shutdown.c
index 8905d354..0ed77445 100644
--- a/src/rc/openrc-shutdown.c
+++ b/src/rc/openrc-shutdown.c
@@ -114,7 +114,7 @@ if (geteuid() != 0)
case_RC_COMMON_GETOPT
}
}
- if (cmd_count != 1) {
+ if (cmd_count > 1) {
eerror("%s: %s\n", applet, exclusive);
usage(EXIT_FAILURE);
}
@@ -128,5 +128,7 @@ if (geteuid() != 0)
send_cmd("reboot");
else if (do_reexec)
send_cmd("reexec");
+ else
+ send_cmd("single");
return 0;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2018-05-15 0:11 William Hubbs
0 siblings, 0 replies; 12+ messages in thread
From: William Hubbs @ 2018-05-15 0:11 UTC (permalink / raw
To: gentoo-commits
commit: a7f475ca04856ef8232364c5b0c3191566b0696c
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue May 15 00:00:04 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 15 00:00:04 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a7f475ca
rc-service: add a --dry-run option
This is for #225.
man/rc-service.8 | 6 ++++++
src/rc/rc-service.c | 7 ++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/man/rc-service.8 b/man/rc-service.8
index 8f075de4..a0202a8e 100644
--- a/man/rc-service.8
+++ b/man/rc-service.8
@@ -35,6 +35,9 @@
.Fl e , -exists
.Ar service
.Nm
+.Fl Z , -dry-run
+.Ar service
+.Nm
.Fl l , -list
.Nm
.Fl r , -resolve
@@ -68,6 +71,9 @@ return 0 if it can find
otherwise -1.
.Fl r , -resolve
does the same and also prints the full path of the service to stdout.
+.Pp
+.Fl Z , -dry-run
+prints out the commands it would execute rather than executing them.
.Sh SEE ALSO
.Xr openrc 8 ,
.Xr stdout 3
diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c
index 8e7b00dc..77f0336b 100644
--- a/src/rc/rc-service.c
+++ b/src/rc/rc-service.c
@@ -29,7 +29,7 @@
const char *applet = NULL;
const char *extraopts = NULL;
-const char *getoptstring = "ce:ilr:IN" getoptstring_COMMON;
+const char *getoptstring = "ce:ilr:INZ" getoptstring_COMMON;
const struct option longopts[] = {
{ "exists", 1, NULL, 'e' },
{ "ifcrashed", 0, NULL, 'c' },
@@ -38,6 +38,7 @@ const struct option longopts[] = {
{ "ifnotstarted", 0, NULL, 'N' },
{ "list", 0, NULL, 'l' },
{ "resolve", 1, NULL, 'r' },
+ { "dry-run", 0, NULL, 'Z' },
longopts_COMMON
};
const char * const longopts_help[] = {
@@ -48,6 +49,7 @@ const char * const longopts_help[] = {
"if the service is not started then run the command",
"list all available services",
"resolve the service name to an init script",
+ "dry run (show what would happen)",
longopts_help_COMMON
};
const char *usagestring = "" \
@@ -112,6 +114,9 @@ int main(int argc, char **argv)
free(service);
return EXIT_SUCCESS;
/* NOTREACHED */
+ case 'Z':
+ setenv("IN_DRYRUN", "yes", 1);
+ break;
case_RC_COMMON_GETOPT
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
@ 2018-05-15 22:11 William Hubbs
0 siblings, 0 replies; 12+ messages in thread
From: William Hubbs @ 2018-05-15 22:11 UTC (permalink / raw
To: gentoo-commits
commit: 4d47ce440c3e8f193cff82a77e6691ee6e7fac33
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue May 15 21:59:21 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue May 15 21:59:21 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=4d47ce44
rc-service: add -d/--debug and -D/--nodeps options
man/rc-service.8 | 14 ++++++++++++++
src/rc/rc-service.c | 12 +++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/man/rc-service.8 b/man/rc-service.8
index a0202a8e..3613f8b8 100644
--- a/man/rc-service.8
+++ b/man/rc-service.8
@@ -20,6 +20,14 @@
.Ar service cmd
.Op Ar ...
.Nm
+.Fl d , -debug
+.Ar service cmd
+.Op Ar ...
+.Nm
+.Fl D , -nodeps
+.Ar service cmd
+.Op Ar ...
+.Nm
.Op Fl i , -ifexists
.Ar service cmd
.Op Ar ...
@@ -72,6 +80,12 @@ otherwise -1.
.Fl r , -resolve
does the same and also prints the full path of the service to stdout.
.Pp
+.Fl d , -debug
+sets -x when running the service script(s).
+.Pp
+.Fl D , -nodeps
+ignores dependencies when running the service.
+.Pp
.Fl Z , -dry-run
prints out the commands it would execute rather than executing them.
.Sh SEE ALSO
diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c
index 77f0336b..ea69dab5 100644
--- a/src/rc/rc-service.c
+++ b/src/rc/rc-service.c
@@ -29,8 +29,10 @@
const char *applet = NULL;
const char *extraopts = NULL;
-const char *getoptstring = "ce:ilr:INZ" getoptstring_COMMON;
+const char *getoptstring = "cdDe:ilr:INZ" getoptstring_COMMON;
const struct option longopts[] = {
+ { "debug", 0, NULL, 'd' },
+ { "nodeps", 0, NULL, 'D' },
{ "exists", 1, NULL, 'e' },
{ "ifcrashed", 0, NULL, 'c' },
{ "ifexists", 0, NULL, 'i' },
@@ -42,6 +44,8 @@ const struct option longopts[] = {
longopts_COMMON
};
const char * const longopts_help[] = {
+ "set xtrace when running the command",
+ "ignore dependencies",
"tests if the service exists or not",
"if the service is crashed then run the command",
"if the service exists then run the command",
@@ -78,6 +82,12 @@ int main(int argc, char **argv)
longopts, (int *) 0)) != -1)
{
switch (opt) {
+ case 'd':
+ setenv("RC_DEBUG", "yes", 1);
+ break;
+ case 'D':
+ setenv("RC_NODEPS", "yes", 1);
+ break;
case 'e':
service = rc_service_resolve(optarg);
opt = service ? EXIT_SUCCESS : EXIT_FAILURE;
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2018-05-15 22:11 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-10 3:22 [gentoo-commits] proj/openrc:master commit in: man/, src/rc/ Robin H. Johnson
-- strict thread matches above, loose matches on Subject: below --
2012-01-15 1:11 Christian Ruppert
2012-01-26 20:51 William Hubbs
2013-04-28 18:04 William Hubbs
2013-05-02 18:58 William Hubbs
2014-01-18 7:56 William Hubbs
2016-01-28 19:08 William Hubbs
2017-04-12 22:57 William Hubbs
2017-05-22 17:54 William Hubbs
2017-05-22 17:54 William Hubbs
2018-05-15 0:11 William Hubbs
2018-05-15 22:11 William Hubbs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox