From 3470eda3f5cea437a6de132b1ead3f27effd3902 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sat, 21 Dec 2013 14:51:11 -0600 Subject: Rename runscript to openrc-run This was requested by Debian, because the minicom software, which is available on Debian and other distros, has a binary named runscript. We are keeping a backward compatibility symlink for now, but this allows Debian or any other distro to safely remove the symlink. X-Gentoo-Bug: 494220 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=494220 --- README | 11 +- init.d.misc/avahi-dnsconfd.in | 2 +- init.d.misc/avahid.in | 2 +- init.d.misc/dbus.in | 2 +- init.d.misc/dhcpcd.in | 2 +- init.d.misc/dnsmasq.in | 2 +- init.d.misc/hald.in | 2 +- init.d.misc/named.in | 2 +- init.d.misc/ntpd.in | 2 +- init.d.misc/openvpn.in | 2 +- init.d.misc/polkitd.in | 2 +- init.d.misc/sshd.in | 2 +- init.d.misc/wpa_supplicant.in | 2 +- init.d/adjkerntz.in | 2 +- init.d/bootmisc.in | 2 +- init.d/consolefont.in | 2 +- init.d/devd.in | 2 +- init.d/devdb.in | 2 +- init.d/devfs.in | 2 +- init.d/dmesg.in | 2 +- init.d/dumpon.in | 2 +- init.d/encswap.in | 2 +- init.d/fsck.in | 2 +- init.d/hostid.in | 2 +- init.d/hostname.in | 2 +- init.d/hwclock.in | 2 +- init.d/ipfw.in | 2 +- init.d/keymaps.in | 2 +- init.d/killprocs.in | 2 +- init.d/local.in | 2 +- init.d/localmount.in | 2 +- init.d/loopback.in | 2 +- init.d/mixer.in | 2 +- init.d/modules.in | 2 +- init.d/mount-ro.in | 2 +- init.d/moused.in | 2 +- init.d/mtab.in | 2 +- init.d/netmount.in | 2 +- init.d/network.in | 2 +- init.d/newsyslog.in | 2 +- init.d/nscd.in | 2 +- init.d/numlock.in | 2 +- init.d/pf.in | 2 +- init.d/powerd.in | 2 +- init.d/procfs.in | 2 +- init.d/rarpd.in | 2 +- init.d/rc-enabled.in | 2 +- init.d/root.in | 2 +- init.d/rpcbind.in | 2 +- init.d/savecache.in | 2 +- init.d/savecore.in | 2 +- init.d/staticroute.in | 2 +- init.d/swap-blk.in | 2 +- init.d/swap.in | 2 +- init.d/swapfiles.in | 2 +- init.d/swclock.in | 4 +- init.d/syscons.in | 2 +- init.d/sysctl.BSD.in | 2 +- init.d/sysctl.Linux.in | 2 +- init.d/sysfs.in | 2 +- init.d/syslogd.in | 2 +- init.d/termencoding.in | 2 +- init.d/tmpfiles.dev.in | 2 +- init.d/tmpfiles.setup.in | 2 +- init.d/ttys.in | 2 +- init.d/urandom.in | 2 +- init.d/wscons.in | 2 +- man/Makefile | 2 +- man/openrc-run.8 | 547 ++++++++++++++++++++++++++++++++++++++++++ man/rc-update.8 | 4 +- man/rc_deptree.3 | 2 +- man/rc_plugin_hook.3 | 2 +- man/rc_service.3 | 2 +- man/runscript.8 | 547 ------------------------------------------ sh/gendepends.sh.in | 4 +- src/rc/.gitignore | 1 + src/rc/Makefile | 3 +- src/rc/builtins.h | 1 + src/rc/rc-applets.c | 1 + src/rc/runscript.c | 13 +- 80 files changed, 646 insertions(+), 628 deletions(-) create mode 100644 man/openrc-run.8 delete mode 100644 man/runscript.8 diff --git a/README b/README index 53408c3..798ef4e 100644 --- a/README +++ b/README @@ -61,10 +61,13 @@ As of OpenRC-0.12, the net.* scripts, originally from Gentoo Linux, have been removed. If you need these scripts, look for a package called netifrc, which is maintained by them. -As of OpenRC-0.13, the /sbin/rc binary has been renamed /sbin/openrc. -There is a /sbin/rc symbolic link in place currently in case you are -still using the old name. However, it is strongly advised that you -migrate your system to the new name. +As of OpenRC-0.13, two binaries have been renamed due to naming +conflicts with other software. The /sbin/rc binary was renamed to +/sbin/openrc, and /sbin/runscript was renamed to /sbin/openrc-run. + +Backward compatible symbolic links are currently in place so your +system will keep working if you are using the old names; however, it is +strongly advised that you migrate to the new names. Reporting Bugs -------------- diff --git a/init.d.misc/avahi-dnsconfd.in b/init.d.misc/avahi-dnsconfd.in index abe2d22..5e022a1 100644 --- a/init.d.misc/avahi-dnsconfd.in +++ b/init.d.misc/avahi-dnsconfd.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/avahid.in b/init.d.misc/avahid.in index ea2241b..bc8ce15 100644 --- a/init.d.misc/avahid.in +++ b/init.d.misc/avahid.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/dbus.in b/init.d.misc/dbus.in index d0004e7..5259853 100644 --- a/init.d.misc/dbus.in +++ b/init.d.misc/dbus.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/dhcpcd.in b/init.d.misc/dhcpcd.in index b22d4d1..ff71979 100644 --- a/init.d.misc/dhcpcd.in +++ b/init.d.misc/dhcpcd.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/dnsmasq.in b/init.d.misc/dnsmasq.in index bdb0411..fa57164 100644 --- a/init.d.misc/dnsmasq.in +++ b/init.d.misc/dnsmasq.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/hald.in b/init.d.misc/hald.in index 741442f..eb7ce06 100644 --- a/init.d.misc/hald.in +++ b/init.d.misc/hald.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/named.in b/init.d.misc/named.in index 924f5b5..3f55884 100644 --- a/init.d.misc/named.in +++ b/init.d.misc/named.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/ntpd.in b/init.d.misc/ntpd.in index 6f18521..080ce2f 100644 --- a/init.d.misc/ntpd.in +++ b/init.d.misc/ntpd.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/openvpn.in b/init.d.misc/openvpn.in index 699fc04..3237946 100644 --- a/init.d.misc/openvpn.in +++ b/init.d.misc/openvpn.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/polkitd.in b/init.d.misc/polkitd.in index fda0764..829e93b 100644 --- a/init.d.misc/polkitd.in +++ b/init.d.misc/polkitd.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/sshd.in b/init.d.misc/sshd.in index 7efb666..ae51505 100644 --- a/init.d.misc/sshd.in +++ b/init.d.misc/sshd.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d.misc/wpa_supplicant.in b/init.d.misc/wpa_supplicant.in index f908e36..d924612 100644 --- a/init.d.misc/wpa_supplicant.in +++ b/init.d.misc/wpa_supplicant.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/adjkerntz.in b/init.d/adjkerntz.in index d1349c8..93a200b 100644 --- a/init.d/adjkerntz.in +++ b/init.d/adjkerntz.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in index 72202f0..ca333be 100644 --- a/init.d/bootmisc.in +++ b/init.d/bootmisc.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/consolefont.in b/init.d/consolefont.in index 61e76c3..7ec93d6 100644 --- a/init.d/consolefont.in +++ b/init.d/consolefont.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/devd.in b/init.d/devd.in index 395dfa7..d071911 100644 --- a/init.d/devd.in +++ b/init.d/devd.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/devdb.in b/init.d/devdb.in index 9213758..3cc08a5 100644 --- a/init.d/devdb.in +++ b/init.d/devdb.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/devfs.in b/init.d/devfs.in index afc2cb7..5c167b0 100644 --- a/init.d/devfs.in +++ b/init.d/devfs.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/dmesg.in b/init.d/dmesg.in index 1c72f76..5b001fc 100644 --- a/init.d/dmesg.in +++ b/init.d/dmesg.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/dumpon.in b/init.d/dumpon.in index fdbdd49..1e23076 100644 --- a/init.d/dumpon.in +++ b/init.d/dumpon.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/encswap.in b/init.d/encswap.in index 57cc762..3df4a35 100644 --- a/init.d/encswap.in +++ b/init.d/encswap.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright 1992-2012 FreeBSD Project # Released under the 2-clause BSD license diff --git a/init.d/fsck.in b/init.d/fsck.in index 9db5119..d3b6607 100644 --- a/init.d/fsck.in +++ b/init.d/fsck.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/hostid.in b/init.d/hostid.in index ce5574b..4495ddf 100644 --- a/init.d/hostid.in +++ b/init.d/hostid.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/hostname.in b/init.d/hostname.in index 4374548..eaeb79a 100644 --- a/init.d/hostname.in +++ b/init.d/hostname.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/hwclock.in b/init.d/hwclock.in index 0f94993..823a5ab 100644 --- a/init.d/hwclock.in +++ b/init.d/hwclock.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/ipfw.in b/init.d/ipfw.in index cb9b6df..df30f3b 100644 --- a/init.d/ipfw.in +++ b/init.d/ipfw.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/keymaps.in b/init.d/keymaps.in index 7abd731..eeed22a 100644 --- a/init.d/keymaps.in +++ b/init.d/keymaps.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/killprocs.in b/init.d/killprocs.in index 5c95925..5cd4fc4 100644 --- a/init.d/killprocs.in +++ b/init.d/killprocs.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/local.in b/init.d/local.in index e82d3cc..2f20568 100644 --- a/init.d/local.in +++ b/init.d/local.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/localmount.in b/init.d/localmount.in index 42b7988..bf3dd0f 100644 --- a/init.d/localmount.in +++ b/init.d/localmount.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/loopback.in b/init.d/loopback.in index 6267ec4..ec45a98 100644 --- a/init.d/loopback.in +++ b/init.d/loopback.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2013 William Hubbs # Released under the 2-clause BSD license. diff --git a/init.d/mixer.in b/init.d/mixer.in index a658e57..8bf152b 100644 --- a/init.d/mixer.in +++ b/init.d/mixer.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/modules.in b/init.d/modules.in index 0d6d21b..acce97e 100644 --- a/init.d/modules.in +++ b/init.d/modules.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/mount-ro.in b/init.d/mount-ro.in index 3e09352..a6438b5 100644 --- a/init.d/mount-ro.in +++ b/init.d/mount-ro.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/moused.in b/init.d/moused.in index ffbed76..2b63a34 100644 --- a/init.d/moused.in +++ b/init.d/moused.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/mtab.in b/init.d/mtab.in index beee3e1..8e5bc2f 100644 --- a/init.d/mtab.in +++ b/init.d/mtab.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/netmount.in b/init.d/netmount.in index 86cdcba..39ab0bc 100644 --- a/init.d/netmount.in +++ b/init.d/netmount.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/network.in b/init.d/network.in index 17237d3..2e9b897 100644 --- a/init.d/network.in +++ b/init.d/network.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/newsyslog.in b/init.d/newsyslog.in index 1cbbe95..894b0c0 100644 --- a/init.d/newsyslog.in +++ b/init.d/newsyslog.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/nscd.in b/init.d/nscd.in index 41e42ae..670f206 100644 --- a/init.d/nscd.in +++ b/init.d/nscd.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/numlock.in b/init.d/numlock.in index 433ba93..1b6d0a5 100644 --- a/init.d/numlock.in +++ b/init.d/numlock.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/pf.in b/init.d/pf.in index a8b301d..f4344a9 100644 --- a/init.d/pf.in +++ b/init.d/pf.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/powerd.in b/init.d/powerd.in index 88f050d..36d60a7 100644 --- a/init.d/powerd.in +++ b/init.d/powerd.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/procfs.in b/init.d/procfs.in index 1432ecf..0db5305 100644 --- a/init.d/procfs.in +++ b/init.d/procfs.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/rarpd.in b/init.d/rarpd.in index 8ea29ac..e11de6d 100644 --- a/init.d/rarpd.in +++ b/init.d/rarpd.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/rc-enabled.in b/init.d/rc-enabled.in index fed30ce..50587bc 100644 --- a/init.d/rc-enabled.in +++ b/init.d/rc-enabled.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/root.in b/init.d/root.in index 387f205..1668368 100644 --- a/init.d/root.in +++ b/init.d/root.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/rpcbind.in b/init.d/rpcbind.in index 77d6c87..c10deeb 100644 --- a/init.d/rpcbind.in +++ b/init.d/rpcbind.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/savecache.in b/init.d/savecache.in index 3dec78b..9040732 100644 --- a/init.d/savecache.in +++ b/init.d/savecache.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/savecore.in b/init.d/savecore.in index e256fba..b1b6ca3 100644 --- a/init.d/savecore.in +++ b/init.d/savecore.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/staticroute.in b/init.d/staticroute.in index 55d0680..34214e0 100644 --- a/init.d/staticroute.in +++ b/init.d/staticroute.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/swap-blk.in b/init.d/swap-blk.in index 4ddf61c..5a14083 100644 --- a/init.d/swap-blk.in +++ b/init.d/swap-blk.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/swap.in b/init.d/swap.in index 4d7a02c..a64ea60 100644 --- a/init.d/swap.in +++ b/init.d/swap.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/swapfiles.in b/init.d/swapfiles.in index 144096a..1c80500 100644 --- a/init.d/swapfiles.in +++ b/init.d/swapfiles.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/swclock.in b/init.d/swclock.in index 465f76c..b74d49a 100644 --- a/init.d/swclock.in +++ b/init.d/swclock.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2009 Roy Marples # Released under the 2-clause BSD license. @@ -17,7 +17,7 @@ start() { ebegin "Setting the local clock based on last shutdown time" if ! swclock 2> /dev/null; then - swclock --warn @SBINDIR@/runscript + swclock --warn @SBINDIR@/openrc-run fi eend $? } diff --git a/init.d/syscons.in b/init.d/syscons.in index 6a7523b..ce0b5a1 100644 --- a/init.d/syscons.in +++ b/init.d/syscons.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/sysctl.BSD.in b/init.d/sysctl.BSD.in index 9f84e36..92d5868 100644 --- a/init.d/sysctl.BSD.in +++ b/init.d/sysctl.BSD.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/sysctl.Linux.in b/init.d/sysctl.Linux.in index 2413154..1ebce66 100644 --- a/init.d/sysctl.Linux.in +++ b/init.d/sysctl.Linux.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/sysfs.in b/init.d/sysfs.in index 7658cb5..1dba73f 100644 --- a/init.d/sysfs.in +++ b/init.d/sysfs.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/syslogd.in b/init.d/syslogd.in index 28090f2..953742b 100644 --- a/init.d/syslogd.in +++ b/init.d/syslogd.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/termencoding.in b/init.d/termencoding.in index d03633d..d3aa027 100644 --- a/init.d/termencoding.in +++ b/init.d/termencoding.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2008-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/tmpfiles.dev.in b/init.d/tmpfiles.dev.in index 477fafa..c2de59f 100644 --- a/init.d/tmpfiles.dev.in +++ b/init.d/tmpfiles.dev.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright 1999-2012 Gentoo Foundation # Released under the 2-clause BSD license. diff --git a/init.d/tmpfiles.setup.in b/init.d/tmpfiles.setup.in index fd9b015..7edef5a 100644 --- a/init.d/tmpfiles.setup.in +++ b/init.d/tmpfiles.setup.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright 1999-2012 Gentoo Foundation # Released under the 2-clause BSD license. diff --git a/init.d/ttys.in b/init.d/ttys.in index aec8340..8fdd169 100644 --- a/init.d/ttys.in +++ b/init.d/ttys.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2008 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/urandom.in b/init.d/urandom.in index 97d0407..ded4113 100644 --- a/init.d/urandom.in +++ b/init.d/urandom.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2007-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/init.d/wscons.in b/init.d/wscons.in index 35bd2b0..8467122 100644 --- a/init.d/wscons.in +++ b/init.d/wscons.in @@ -1,4 +1,4 @@ -#!@SBINDIR@/runscript +#!@SBINDIR@/openrc-run # Copyright (c) 2008-2009 Roy Marples # Released under the 2-clause BSD license. diff --git a/man/Makefile b/man/Makefile index 04862da..436f647 100644 --- a/man/Makefile +++ b/man/Makefile @@ -1,7 +1,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 openrc.8 runscript.8 \ +MAN8= rc-service.8 rc-status.8 rc-update.8 openrc.8 openrc-run.8 \ service.8 start-stop-daemon.8 # Handy macro to create symlinks diff --git a/man/openrc-run.8 b/man/openrc-run.8 new file mode 100644 index 0000000..0346241 --- /dev/null +++ b/man/openrc-run.8 @@ -0,0 +1,547 @@ +.\" Copyright (c) 2007-2009 Roy Marples +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd December 31, 2011 +.Dt openrc-run 8 SMM +.Os OpenRC +.Sh NAME +.Nm openrc-run +.Nd a means of hooking shell commands into a service +.Sh SYNOPSIS +.Nm +.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 +.Nm +is basically an interpreter for shell scripts which provides an easy interface +to the often complex system commands and daemons. +When a service runs a command it first loads its multiplexed configuration +file, then its master configuration file, then +.Pa /etc/rc.conf +and finally the script itself. At this point +.Nm +then runs the command given. +.Pp +Commands are defined as shell functions within the script. Here is a list of +some functions that all scripts have by default: +.Bl -tag -width "RC_DEFAULTLEVEL" +.It Ar describe +Describes what the service does and each command the service defines. +.It Ar start +First we ensure that any services we depend on are started. If any needed +services fail to start then we exit with a suitable error, otherwise call the +supplied start function if it exists. +.It Ar stop +First we ensure that any services that depend on us are stopped. If any +services that need us fail to stop then we exit with a suitable error, +otherwise call the supplied stop function if it exists. +.It Ar restart +Stops and starts the service, including dependencies. This cannot be +overridden. See the description of the RC_CMD variable below for the +method to make your service behave differently when restart is being +executed. +.It Ar status +Shows the status of the service. The return code matches the status, with the +exception of "started" returning 0 to match standard command behaviour. +.It Ar zap +Resets the service state to stopped and removes all saved data about the +service. +.El +.Pp +The following options affect how the service is run: +.Bl -tag -width "RC_DEFAULTLEVEL" +.It Fl d , -debug +Set xtrace on in the shell to assist in debugging. +.It Fl D , -nodeps +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. +.It Fl v , -verbose +Turns on any extra informational output the service generates. +.It Fl Z , -dry-run +Shows which services would be stopped and/or started without actually stopping +or starting them. +.El +.Pp +The following variables affect the service script: +.Bl -tag -width "RC_DEFAULTLEVEL" +.It Ar extra_commands +Space separated list of extra commands the service defines. These should +not depend on the service being stopped or started. +.It Ar extra_started_commands +Space separated list of extra commands the service defines. These only work if +the service has already been started. +.It Ar extra_stopped_commands +Space separated list of extra commands the service defines. These only work if +the service has already been stopped. +.It Ar description +String describing the service. +.It Ar description_$command +String describing the extra command. +.It Ar start_stop_daemon_args +List of arguments passed to start-stop-daemon when starting the daemon. +.It Ar command +Daemon to start or stop via +.Nm start-stop-daemon +if no start or stop function is defined by the service. +.It Ar command_args +List of arguments to pass to the daemon when starting. +.It Ar command_background +Set this to "true", "yes" or "1" (case-insensitive) to force the daemon into +the background. This implies the "--make-pidfile" and "--pidfile" option of +.Xr start-stop-daemon 8 +so the pidfile variable must be set. +.It Ar pidfile +Pidfile to use for the above defined command. +.It Ar name +Display name used for the above defined command. +.It Ar retry +Retry schedule to use when stopping the daemon. It can either be a +timeout in seconds or multiple signal/timeout pairs (like SIGTERM/5). +.It Ar required_dirs +A list of directories which must exist for the service to start. +.It Ar required_files +A list of files which must exist for the service to start. +.El +.Sh DEPENDENCIES +You should define a +.Ic depend +function for the service so that +.Nm +will start and stop it in the right order in relation to other services. +As it's a function it can be very flexible, see the example below. +Here is a list of the functions you can use in a +.Ic depend +function. You simply pass the names of the services to it to add to that +dependency type, or prefix it with ! to remove it. +.Bl -tag -width "RC_DEFAULTLEVEL" +.It Ic need +The service will refuse to start until needed services have started and it +will refuse to stop until any services that need it have stopped. +.It Ic use +The service will attempt to start any services we use that have been added +to the runlevel. +.It Ic after +The service will start after these services and stop before these services. +.It Ic before +The service will start before these services and stop after these services. +.It Ic provide +We provide this virtual service. For example, named provides dns. +Virtual services take precedence over real services, so it is highly +recommended that you do not have a real service that has the same name +as a virtual service. +.It Ic config +We should recalculate our dependencies if the listed files have changed. +.It Ic keyword +Tags a service with a keyword. These are the keywords we currently understand: +.Bl -tag -width indent +.It Dv -shutdown +Don't stop this service when shutting the system down. +This is normally quite safe as remaining daemons will be sent a SIGTERM just +before final shutdown. +Network related services such as the network and dhcpcd init scripts normally +have this keyword. +.It Dv -stop +Don't stop this service when changing runlevels, even if not present. +This includes shutting the system down. +.It Dv -timeout +Other services should wait indefinitely for this service to start. Use +this keyword if your service may take longer than 60 seconds to start. +.It Dv -jail +When in a jail, exclude this service from any dependencies. The service can +still be run directly. Set via +.Ic rc_sys +in +.Pa /etc/rc.conf +.It Dv -lxc +Same as -jail, but for Linux Resource Containers (LXC). +.It Dv -openvz +Same as -jail, but for OpenVZ systems. +.It Dv -prefix +Same as -jail, but for Prefix systems. +.It Dv -uml +Same as -jail, but for UML systems. +.It Dv -vserver +Same as -jail, but for VServer systems. +.It Dv -xen0 +Same as -jail, but for Xen DOM0 systems. +.It Dv -xenu +Same as -jail, but for Xen DOMU systems. +.El +.El +.Pp +To see how to influence dependencies in configuration files, see the +.Sx FILES +section below. +.Sh BUILTINS +.Nm +defines some builtin functions that you can use inside your service scripts: +.Bl -tag -width indent +.It Ic einfo Op Ar string +Output a green asterisk followed by the string. +.It Ic ewarn Op Ar string +Output a yellow asterisk followed by the string. +.It Ic eerror Op Ar string +Output a red asterisk followed by the string to stderr. +.It Ic ebegin Op Ar string +Same as einfo, but append 3 dots to the end. +.It Ic eend Ar retval Op Ar string +If +.Ar retval +does not equal 0 then output the string using +.Ic eerror +and !! in square brackets +at the end of the line. +Otherwise output ok in square brackets at the end of the line. +The value of +.Ar retval +is returned. +.It Ic ewend Ar retval Op Ar string +Same as +.Ic eend , +but use +.Ic ewarn +instead of +.Ic eerror . +.El +.Pp +You can prefix the above commands with the letter +.Ic v , +which means they only +output when the environment variable +.Va EINFO_VERBOSE +is true. +.Bl -tag -width indent +.It Ic ewaitfile Ar timeout Ar file1 Ar file2 ... +Wait for +.Ar timeout +seconds until all files exist. +Returns 0 if all files exist, otherwise non zero. +If +.Ar timeout +is less than 1 then we wait indefinitely. +.It Ic is_newer_than Ar file1 Ar file2 ... +If +.Ar file1 +is newer than +.Ar file2 +return 0, otherwise 1. +If +.Ar file2 +is a directory, then check all its contents too. +.It Ic is_older_than Ar file1 Ar file2 ... +If +.Ar file1 +is newer than +.Ar file2 +return 0, otherwise 1. +If +.Ar file2 +is a directory, then check all its contents too. +.It Ic service_set_value Ar name Ar value +Saves the +.Ar name +.Ar value +for later retrieval. Saved values are lost when the service stops. +.It Ic service_get_value Ar name +Returns the saved value called +.Ar name . +.It Ic service_started Op Ar service +If the service is started, return 0 otherwise 1. +.It Ic service_starting Op Ar service +If the service is starting, return 0 otherwise 1. +.It Ic service_inactive Op Ar service +If the service is inactive, return 0 otherwise 1. +.It Ic service_stopping Op Ar service +If the service is stopping, return 0 otherwise 1. +.It Ic service_stopped Op Ar service +If the service is stopped, return 0 otherwise 1. +.It Ic service_coldplugged Op Ar service +If the service is coldplugged, return 0 otherwise 1. +.It Ic service_wasinactive Op Ar service +If the service was inactive, return 0 otherwise 1. +.It Xo +.Ic service_started_daemon +.Op Ar service +.Ar daemon +.Op Ar index +.Xc +If the service has started the daemon using +.Nm start-stop-daemon , +return 0 otherwise 1. +If an index is specified, it has to be the nth daemon started by the service. +.It Ic mark_service_started Op Ar service +Mark the service as started. +.It Ic mark_service_starting Op Ar service +Mark the service as starting. +.It Ic mark_service_inactive Op Ar service +Mark the service as inactive. +.It Ic mark_service_stopping Op Ar service +Mark the service as stopping. +.It Ic mark_service_stopped Op Ar service +Mark the service as stopped. +.It Ic mark_service_coldplugged Op Ar service +Mark the service as coldplugged. +.It Ic mark_service_wasinactive Op Ar service +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 ... +.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 +matches YES, TRUE, ON or 1 regardless of case then we return 0, otherwise 1. +.El +.Sh ENVIRONMENT +.Nm +sets the following environment variables for use in the service scripts: +.Bl -tag -width "RC_DEFAULTLEVEL" +.It Va RC_SVCNAME +Name of the service. +.It Va RC_RUNLEVEL +Current runlevel that OpenRC is in. Note that, in OpenRC, the reboot +runlevel is mapped to the shutdown runlevel. This was done because most +services do not need to know if a system is shutting down or rebooting. +If you are writing a service that does need to know this, see the +RC_REBOOT variable. +.It Va RC_REBOOT +This variable contains YES if the system is rebooting. If your service +needs to know the system is rebooting, you should test this variable. +.It Va RC_BOOTLEVEL +Boot runlevel chosen. Default is boot. +.It Va RC_DEFAULTLEVEL +Default runlevel chosen. Default is default. +.It Va RC_SYS +A special variable to describe the system more. +Possible values are OPENVZ, XENU, XEN0, UML and VSERVER. +.It Va RC_PREFIX +In a Gentoo Prefix installation, this variable contains the prefix +offset. Otherwise it is undefined. +.It Va RC_UNAME +The result of `uname -s`. +.It Va RC_CMD +This contains the name of the command the service script is executing, such +as start, stop, restart etc. One example of using this is to make a +service script behave differently when restart is being executed. +.El +.Sh FILES +.Pp +Configuration files, relative to the location of the service. +If a file ending with .${RC_RUNLEVEL} exists then we use that instead. +.Bl -ohang +.It Pa ../conf.d/${RC_SVCNAME%%.*} +multiplexed configuration file. +Example: if ${RC_SVCNAME} is net.eth1 then look for +.Pa ../conf.d/net . +.It Pa ../conf.d/${RC_SVCNAME} +service configuration file. +.It Pa /etc/rc.conf +host configuration file. +.El +.Pp +With the exception of +.Pa /etc/rc.conf , +the configuration files can also influence the dependencies of the service +through variables. Simply prefix the name of the dependency with rc_. +Examples: +.Bd -literal -offset indent +# Whilst most services don't bind to a specific interface, our +# openvpn configuration requires a specific interface, namely bge0. +rc_need="net.bge0" +# To put it in /etc/rc.conf you would do it like this +rc_openvpn_need="net.bge0" + +# Services should not depend on the tap1 interface for network, +# but we need to add net.tap1 to the default runlevel to start it. +rc_provide="!net" +# To put it in /etc/conf.d/net you would do it like this +rc_provide_tap1="!net" +# To put in in /etc/rc.conf you would do it like this +rc_net_tap1_provide="!net" + +# It's also possible to negate keywords. This is mainly useful for prefix +# users testing OpenRC. +rc_keyword="!-prefix" +.Ed +.Sh EXAMPLES +.Pp +An example service script for foo. +.Bd -literal -offset indent +#!/sbin/openrc-run +command=/usr/bin/foo +command_args="${foo_args} --bar" +pidfile=/var/run/foo.pid +name="FooBar Daemon" + +description="FooBar is a daemon that eats and drinks" +extra_commands="show" +extra_started_commands="drink eat" +description_drink="Opens mouth and reflexively swallows" +description_eat="Chews food in mouth" +description_show="Shows what's in the tummy" + +_need_dbus() +{ + grep -q dbus /etc/foo/plugins +} + +depend() +{ + # We write a pidfile and to /var/cache, so we need localmount. + need localmount + # We can optionally use the network, but it's not essential. + use net + # We should be after bootmisc so that /var/run is cleaned before + # we put our pidfile there. + after bootmisc + + # Foo may use a dbus plugin. + # However, if we add the dbus plugin whilst foo is running and + # stop dbus, we don't need to stop foo as foo didn't use dbus. + config /etc/foo/plugins + local _need= + if service_started; then + _need=`service_get_value need` + else + if _need_dbus; then + _need="${_need} dbus" + fi + fi + need ${_need} +} + +# This function does any pre-start setup. If it fails, the service will +# not be started. +# If you need this function to behave differently for a restart command, +# you should check the value of RC_CMD for "restart". +# This also applies to start_post, stop_pre and stop_post. +start_pre() +{ + if [ "$RC_CMD" = restart ]; then + # This block will only execute for a restart command. Use a + # structure like this if you need special processing for a + # restart which you do not need for a normal start. + # The function can also fail from here, which will mean that a + # restart can fail. + # This logic can also be used in start_post, stop_pre and + # stop_post. + fi + # Ensure that our dirs are correct + checkpath --directory --owner foo:foo --mode 0775 \\ + /var/run/foo /var/cache/foo +} + +start_post() +{ + # Save our need + if _need_dbus; then + service_set_value need dbus + fi +} + +stop_post() { + # Clean any spills + rm -rf /var/cache/foo/* +} + +drink() +{ + ebegin "Starting to drink" + ${command} --drink beer + eend $? "Failed to drink any beer :(" +} + +eat() +{ + local result=0 retval= ate= food= + ebegin "Starting to eat" + + if yesno "${foo_diet}"; then + eend 1 "We are on a diet!" + return 1 + fi + + for food in /usr/share/food/*; do + veinfo "Eating `basename ${food}`" + ${command} --eat ${food} + retval=$? + : $(( result += retval )) + [ ${retval} = 0 ] && ate="${ate} `basename ${food}`" + done + + if eend ${result} "Failed to eat all the food"; then + service_set_value ate "${ate}" + fi +} + +show() +{ + einfo "Foo has eaten: `service_get_value ate`" +} + +.Ed +.Sh BUGS +Because of the way we load our configuration files and the need to handle +more than one service directory, you can only use symlinks in service +directories to other services in the same directory. +You cannot symlink to a service in a different directory even if it is +another service directory. +.Pp +is_older_than should return 0 on success. +Instead we return 1 to be compliant with Gentoo baselayout. +Users are encouraged to use the is_newer_than function which returns correctly. +.Sh SEE ALSO +.Xr einfo 3 , +.Xr openrc 8 , +.Xr rc-status 8 , +.Xr rc-update 8 , +.Xr rc_plugin_hook 3 , +.Xr sh 1p , +.Xr start-stop-daemon 8 , +.Xr uname 1 +.Sh AUTHORS +.An Roy Marples diff --git a/man/rc-update.8 b/man/rc-update.8 index 459f069..3fa97a4 100644 --- a/man/rc-update.8 +++ b/man/rc-update.8 @@ -53,7 +53,8 @@ All services must reside in the or .Pa /usr/local/etc/init.d directories. -They must also conform to the OpenRC runscript standard. +They must also be standard OpenRC scripts, meaning they must use +openrc-run. .Pp .Bl -tag -width "Fl a , -delete service" .It Ar add Ar service @@ -87,6 +88,7 @@ option is given then we either add or remove the runlevel from the runlevel. This allows inheritance of runlevels. .Sh SEE ALSO .Xr openrc 8 , +.Xr openrc-run 8 , .Xr rc-status 8 .Sh AUTHORS .An Roy Marples diff --git a/man/rc_deptree.3 b/man/rc_deptree.3 index e980534..64fcf60 100644 --- a/man/rc_deptree.3 +++ b/man/rc_deptree.3 @@ -107,6 +107,6 @@ when done. .Xr malloc 3 , .Xr free 3 , .Xr rc_stringlist_free 3 , -.Xr runscript 8 +.Xr openrc-run 8 .Sh AUTHORS .An Roy Marples diff --git a/man/rc_plugin_hook.3 b/man/rc_plugin_hook.3 index 22a1c58..955ecb8 100644 --- a/man/rc_plugin_hook.3 +++ b/man/rc_plugin_hook.3 @@ -45,6 +45,6 @@ Plugins can affect the parent environment by writing NULL separated strings to .Va rc_environ_fd . .Sh SEE ALSO .Xr openrc 8 , -.Xr runscript 8 +.Xr openrc-run 8 .Sh AUTHORS .An Roy Marples diff --git a/man/rc_service.3 b/man/rc_service.3 index 4c1ee01..aba1636 100644 --- a/man/rc_service.3 +++ b/man/rc_service.3 @@ -141,7 +141,7 @@ is lost. returns a list of extra commands the .Fa service supports beyond the default ones. See -.Nm runscript +.Nm openrc-run for default commands. .Pp .Fn rc_service_plugable diff --git a/man/runscript.8 b/man/runscript.8 deleted file mode 100644 index e0d7cf0..0000000 --- a/man/runscript.8 +++ /dev/null @@ -1,547 +0,0 @@ -.\" Copyright (c) 2007-2009 Roy Marples -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd December 31, 2011 -.Dt RUNSCRIPT 8 SMM -.Os OpenRC -.Sh NAME -.Nm runscript -.Nd a means of hooking shell commands into a service -.Sh SYNOPSIS -.Nm -.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 -.Nm -is basically an interpreter for shell scripts which provides an easy interface -to the often complex system commands and daemons. -When a service runs a command it first loads its multiplexed configuration -file, then its master configuration file, then -.Pa /etc/rc.conf -and finally the script itself. At this point -.Nm -then runs the command given. -.Pp -Commands are defined as shell functions within the script. Here is a list of -some functions that all runscripts have by default: -.Bl -tag -width "RC_DEFAULTLEVEL" -.It Ar describe -Describes what the service does and each command the service defines. -.It Ar start -First we ensure that any services we depend on are started. If any needed -services fail to start then we exit with a suitable error, otherwise call the -supplied start function if it exists. -.It Ar stop -First we ensure that any services that depend on us are stopped. If any -services that need us fail to stop then we exit with a suitable error, -otherwise call the supplied stop function if it exists. -.It Ar restart -Stops and starts the service, including dependencies. This cannot be -overridden. See the description of the RC_CMD variable below for the -method to make your service behave differently when restart is being -executed. -.It Ar status -Shows the status of the service. The return code matches the status, with the -exception of "started" returning 0 to match standard command behaviour. -.It Ar zap -Resets the service state to stopped and removes all saved data about the -service. -.El -.Pp -The following options affect how the service is run: -.Bl -tag -width "RC_DEFAULTLEVEL" -.It Fl d , -debug -Set xtrace on in the shell to assist in debugging. -.It Fl D , -nodeps -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. -.It Fl v , -verbose -Turns on any extra informational output the service generates. -.It Fl Z , -dry-run -Shows which services would be stopped and/or started without actually stopping -or starting them. -.El -.Pp -The following variables affect the service script: -.Bl -tag -width "RC_DEFAULTLEVEL" -.It Ar extra_commands -Space separated list of extra commands the service defines. These should -not depend on the service being stopped or started. -.It Ar extra_started_commands -Space separated list of extra commands the service defines. These only work if -the service has already been started. -.It Ar extra_stopped_commands -Space separated list of extra commands the service defines. These only work if -the service has already been stopped. -.It Ar description -String describing the service. -.It Ar description_$command -String describing the extra command. -.It Ar start_stop_daemon_args -List of arguments passed to start-stop-daemon when starting the daemon. -.It Ar command -Daemon to start or stop via -.Nm start-stop-daemon -if no start or stop function is defined by the service. -.It Ar command_args -List of arguments to pass to the daemon when starting. -.It Ar command_background -Set this to "true", "yes" or "1" (case-insensitive) to force the daemon into -the background. This implies the "--make-pidfile" and "--pidfile" option of -.Xr start-stop-daemon 8 -so the pidfile variable must be set. -.It Ar pidfile -Pidfile to use for the above defined command. -.It Ar name -Display name used for the above defined command. -.It Ar retry -Retry schedule to use when stopping the daemon. It can either be a -timeout in seconds or multiple signal/timeout pairs (like SIGTERM/5). -.It Ar required_dirs -A list of directories which must exist for the service to start. -.It Ar required_files -A list of files which must exist for the service to start. -.El -.Sh DEPENDENCIES -You should define a -.Ic depend -function for the service so that -.Nm -will start and stop it in the right order in relation to other services. -As it's a function it can be very flexible, see the example below. -Here is a list of the functions you can use in a -.Ic depend -function. You simply pass the names of the services to it to add to that -dependency type, or prefix it with ! to remove it. -.Bl -tag -width "RC_DEFAULTLEVEL" -.It Ic need -The service will refuse to start until needed services have started and it -will refuse to stop until any services that need it have stopped. -.It Ic use -The service will attempt to start any services we use that have been added -to the runlevel. -.It Ic after -The service will start after these services and stop before these services. -.It Ic before -The service will start before these services and stop after these services. -.It Ic provide -We provide this virtual service. For example, named provides dns. -Virtual services take precedence over real services, so it is highly -recommended that you do not have a real service that has the same name -as a virtual service. -.It Ic config -We should recalculate our dependencies if the listed files have changed. -.It Ic keyword -Tags a service with a keyword. These are the keywords we currently understand: -.Bl -tag -width indent -.It Dv -shutdown -Don't stop this service when shutting the system down. -This is normally quite safe as remaining daemons will be sent a SIGTERM just -before final shutdown. -Network related services such as the network and dhcpcd init scripts normally -have this keyword. -.It Dv -stop -Don't stop this service when changing runlevels, even if not present. -This includes shutting the system down. -.It Dv -timeout -Other services should wait indefinitely for this service to start. Use -this keyword if your service may take longer than 60 seconds to start. -.It Dv -jail -When in a jail, exclude this service from any dependencies. The service can -still be run directly. Set via -.Ic rc_sys -in -.Pa /etc/rc.conf -.It Dv -lxc -Same as -jail, but for Linux Resource Containers (LXC). -.It Dv -openvz -Same as -jail, but for OpenVZ systems. -.It Dv -prefix -Same as -jail, but for Prefix systems. -.It Dv -uml -Same as -jail, but for UML systems. -.It Dv -vserver -Same as -jail, but for VServer systems. -.It Dv -xen0 -Same as -jail, but for Xen DOM0 systems. -.It Dv -xenu -Same as -jail, but for Xen DOMU systems. -.El -.El -.Pp -To see how to influence dependencies in configuration files, see the -.Sx FILES -section below. -.Sh BUILTINS -.Nm -defines some builtin functions that you can use inside your service scripts: -.Bl -tag -width indent -.It Ic einfo Op Ar string -Output a green asterisk followed by the string. -.It Ic ewarn Op Ar string -Output a yellow asterisk followed by the string. -.It Ic eerror Op Ar string -Output a red asterisk followed by the string to stderr. -.It Ic ebegin Op Ar string -Same as einfo, but append 3 dots to the end. -.It Ic eend Ar retval Op Ar string -If -.Ar retval -does not equal 0 then output the string using -.Ic eerror -and !! in square brackets -at the end of the line. -Otherwise output ok in square brackets at the end of the line. -The value of -.Ar retval -is returned. -.It Ic ewend Ar retval Op Ar string -Same as -.Ic eend , -but use -.Ic ewarn -instead of -.Ic eerror . -.El -.Pp -You can prefix the above commands with the letter -.Ic v , -which means they only -output when the environment variable -.Va EINFO_VERBOSE -is true. -.Bl -tag -width indent -.It Ic ewaitfile Ar timeout Ar file1 Ar file2 ... -Wait for -.Ar timeout -seconds until all files exist. -Returns 0 if all files exist, otherwise non zero. -If -.Ar timeout -is less than 1 then we wait indefinitely. -.It Ic is_newer_than Ar file1 Ar file2 ... -If -.Ar file1 -is newer than -.Ar file2 -return 0, otherwise 1. -If -.Ar file2 -is a directory, then check all its contents too. -.It Ic is_older_than Ar file1 Ar file2 ... -If -.Ar file1 -is newer than -.Ar file2 -return 0, otherwise 1. -If -.Ar file2 -is a directory, then check all its contents too. -.It Ic service_set_value Ar name Ar value -Saves the -.Ar name -.Ar value -for later retrieval. Saved values are lost when the service stops. -.It Ic service_get_value Ar name -Returns the saved value called -.Ar name . -.It Ic service_started Op Ar service -If the service is started, return 0 otherwise 1. -.It Ic service_starting Op Ar service -If the service is starting, return 0 otherwise 1. -.It Ic service_inactive Op Ar service -If the service is inactive, return 0 otherwise 1. -.It Ic service_stopping Op Ar service -If the service is stopping, return 0 otherwise 1. -.It Ic service_stopped Op Ar service -If the service is stopped, return 0 otherwise 1. -.It Ic service_coldplugged Op Ar service -If the service is coldplugged, return 0 otherwise 1. -.It Ic service_wasinactive Op Ar service -If the service was inactive, return 0 otherwise 1. -.It Xo -.Ic service_started_daemon -.Op Ar service -.Ar daemon -.Op Ar index -.Xc -If the service has started the daemon using -.Nm start-stop-daemon , -return 0 otherwise 1. -If an index is specified, it has to be the nth daemon started by the service. -.It Ic mark_service_started Op Ar service -Mark the service as started. -.It Ic mark_service_starting Op Ar service -Mark the service as starting. -.It Ic mark_service_inactive Op Ar service -Mark the service as inactive. -.It Ic mark_service_stopping Op Ar service -Mark the service as stopping. -.It Ic mark_service_stopped Op Ar service -Mark the service as stopped. -.It Ic mark_service_coldplugged Op Ar service -Mark the service as coldplugged. -.It Ic mark_service_wasinactive Op Ar service -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 ... -.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 -matches YES, TRUE, ON or 1 regardless of case then we return 0, otherwise 1. -.El -.Sh ENVIRONMENT -.Nm -sets the following environment variables for use in the service scripts: -.Bl -tag -width "RC_DEFAULTLEVEL" -.It Va RC_SVCNAME -Name of the service. -.It Va RC_RUNLEVEL -Current runlevel that OpenRC is in. Note that, in OpenRC, the reboot -runlevel is mapped to the shutdown runlevel. This was done because most -services do not need to know if a system is shutting down or rebooting. -If you are writing a service that does need to know this, see the -RC_REBOOT variable. -.It Va RC_REBOOT -This variable contains YES if the system is rebooting. If your service -needs to know the system is rebooting, you should test this variable. -.It Va RC_BOOTLEVEL -Boot runlevel chosen. Default is boot. -.It Va RC_DEFAULTLEVEL -Default runlevel chosen. Default is default. -.It Va RC_SYS -A special variable to describe the system more. -Possible values are OPENVZ, XENU, XEN0, UML and VSERVER. -.It Va RC_PREFIX -In a Gentoo Prefix installation, this variable contains the prefix -offset. Otherwise it is undefined. -.It Va RC_UNAME -The result of `uname -s`. -.It Va RC_CMD -This contains the name of the command the service script is executing, such -as start, stop, restart etc. One example of using this is to make a -service script behave differently when restart is being executed. -.El -.Sh FILES -.Pp -Configuration files, relative to the location of the service. -If a file ending with .${RC_RUNLEVEL} exists then we use that instead. -.Bl -ohang -.It Pa ../conf.d/${RC_SVCNAME%%.*} -multiplexed configuration file. -Example: if ${RC_SVCNAME} is net.eth1 then look for -.Pa ../conf.d/net . -.It Pa ../conf.d/${RC_SVCNAME} -service configuration file. -.It Pa /etc/rc.conf -host configuration file. -.El -.Pp -With the exception of -.Pa /etc/rc.conf , -the configuration files can also influence the dependencies of the service -through variables. Simply prefix the name of the dependency with rc_. -Examples: -.Bd -literal -offset indent -# Whilst most services don't bind to a specific interface, our -# openvpn configuration requires a specific interface, namely bge0. -rc_need="net.bge0" -# To put it in /etc/rc.conf you would do it like this -rc_openvpn_need="net.bge0" - -# Services should not depend on the tap1 interface for network, -# but we need to add net.tap1 to the default runlevel to start it. -rc_provide="!net" -# To put it in /etc/conf.d/net you would do it like this -rc_provide_tap1="!net" -# To put in in /etc/rc.conf you would do it like this -rc_net_tap1_provide="!net" - -# It's also possible to negate keywords. This is mainly useful for prefix -# users testing OpenRC. -rc_keyword="!-prefix" -.Ed -.Sh EXAMPLES -.Pp -An example service script for foo. -.Bd -literal -offset indent -#!/sbin/runscript -command=/usr/bin/foo -command_args="${foo_args} --bar" -pidfile=/var/run/foo.pid -name="FooBar Daemon" - -description="FooBar is a daemon that eats and drinks" -extra_commands="show" -extra_started_commands="drink eat" -description_drink="Opens mouth and reflexively swallows" -description_eat="Chews food in mouth" -description_show="Shows what's in the tummy" - -_need_dbus() -{ - grep -q dbus /etc/foo/plugins -} - -depend() -{ - # We write a pidfile and to /var/cache, so we need localmount. - need localmount - # We can optionally use the network, but it's not essential. - use net - # We should be after bootmisc so that /var/run is cleaned before - # we put our pidfile there. - after bootmisc - - # Foo may use a dbus plugin. - # However, if we add the dbus plugin whilst foo is running and - # stop dbus, we don't need to stop foo as foo didn't use dbus. - config /etc/foo/plugins - local _need= - if service_started; then - _need=`service_get_value need` - else - if _need_dbus; then - _need="${_need} dbus" - fi - fi - need ${_need} -} - -# This function does any pre-start setup. If it fails, the service will -# not be started. -# If you need this function to behave differently for a restart command, -# you should check the value of RC_CMD for "restart". -# This also applies to start_post, stop_pre and stop_post. -start_pre() -{ - if [ "$RC_CMD" = restart ]; then - # This block will only execute for a restart command. Use a - # structure like this if you need special processing for a - # restart which you do not need for a normal start. - # The function can also fail from here, which will mean that a - # restart can fail. - # This logic can also be used in start_post, stop_pre and - # stop_post. - fi - # Ensure that our dirs are correct - checkpath --directory --owner foo:foo --mode 0775 \\ - /var/run/foo /var/cache/foo -} - -start_post() -{ - # Save our need - if _need_dbus; then - service_set_value need dbus - fi -} - -stop_post() { - # Clean any spills - rm -rf /var/cache/foo/* -} - -drink() -{ - ebegin "Starting to drink" - ${command} --drink beer - eend $? "Failed to drink any beer :(" -} - -eat() -{ - local result=0 retval= ate= food= - ebegin "Starting to eat" - - if yesno "${foo_diet}"; then - eend 1 "We are on a diet!" - return 1 - fi - - for food in /usr/share/food/*; do - veinfo "Eating `basename ${food}`" - ${command} --eat ${food} - retval=$? - : $(( result += retval )) - [ ${retval} = 0 ] && ate="${ate} `basename ${food}`" - done - - if eend ${result} "Failed to eat all the food"; then - service_set_value ate "${ate}" - fi -} - -show() -{ - einfo "Foo has eaten: `service_get_value ate`" -} - -.Ed -.Sh BUGS -Because of the way we load our configuration files and the need to handle -more than one service directory, you can only use symlinks in service -directories to other services in the same directory. -You cannot symlink to a service in a different directory even if it is -another service directory. -.Pp -is_older_than should return 0 on success. -Instead we return 1 to be compliant with Gentoo baselayout. -Users are encouraged to use the is_newer_than function which returns correctly. -.Sh SEE ALSO -.Xr einfo 3 , -.Xr openrc 8 , -.Xr rc-status 8 , -.Xr rc-update 8 , -.Xr rc_plugin_hook 3 , -.Xr sh 1p , -.Xr start-stop-daemon 8 , -.Xr uname 1 -.Sh AUTHORS -.An Roy Marples diff --git a/sh/gendepends.sh.in b/sh/gendepends.sh.in index 461c688..dfe7444 100644 --- a/sh/gendepends.sh.in +++ b/sh/gendepends.sh.in @@ -51,10 +51,12 @@ do for RC_SERVICE in *; do [ -x "$RC_SERVICE" -a -f "$RC_SERVICE" ] || continue - # Only generate dependencies for runscripts + # Only generate dependencies for OpenRC scripts read one two three <"$RC_SERVICE" [ "$one" = "#!@SBINDIR@/runscript" ] || \ + [ "$one" = "#!@SBINDIR@/openrc-run" ] || \ [ "$one" = "#!" -a "$two" = "@SBINDIR@/runscript" ] || \ + [ "$one" = "#!" -a "$two" = "@SBINDIR@/openrc-run" ] || \ continue unset one two three diff --git a/src/rc/.gitignore b/src/rc/.gitignore index e04e2f3..bbfede6 100644 --- a/src/rc/.gitignore +++ b/src/rc/.gitignore @@ -58,3 +58,4 @@ mark_service_failed rc-abort rc openrc +openrc-run diff --git a/src/rc/Makefile b/src/rc/Makefile index 209523a..5f5aa63 100644 --- a/src/rc/Makefile +++ b/src/rc/Makefile @@ -11,7 +11,8 @@ SBINDIR= ${PREFIX}/sbin LINKDIR= ${LIBEXECDIR} BINLINKS= rc-status -SBINLINKS= rc rc-service rc-update runscript service start-stop-daemon +SBINLINKS= rc rc-service rc-update openrc-run 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/builtins.h b/src/rc/builtins.h index 22bd0f2..2b38c67 100644 --- a/src/rc/builtins.h +++ b/src/rc/builtins.h @@ -28,6 +28,7 @@ int checkpath(int, char **); int fstabinfo(int, char **); int mountinfo(int, char **); +int openrc_run(int, char **); int rc_depend(int, char **); int rc_service(int, char **); int rc_status(int, char **); diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c index 8431eea..b4f61d9 100644 --- a/src/rc/rc-applets.c +++ b/src/rc/rc-applets.c @@ -503,6 +503,7 @@ static const struct { #define A(a) { #a, a } A(fstabinfo), A(mountinfo), + { "openrc-run", openrc_run, }, { "rc-depend", rc_depend, }, { "rc-service", rc_service, }, { "rc-status", rc_status, }, diff --git a/src/rc/runscript.c b/src/rc/runscript.c index e5cb62e..981e606 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -1116,7 +1116,7 @@ static const char *const longopts_help[] = { #include "_usage.c" int -runscript(int argc, char **argv) +openrc_run(int argc, char **argv) { bool doneone = false; int retval, opt, depoptions = RC_DEP_TRACE; @@ -1130,12 +1130,12 @@ runscript(int argc, char **argv) /* Show help if insufficient args */ if (argc < 2 || !exists(argv[1])) { - fprintf(stderr, "runscript should not be run directly\n"); + fprintf(stderr, "openrc-run should not be run directly\n"); exit(EXIT_FAILURE); } if (stat(argv[1], &stbuf) != 0) { - fprintf(stderr, "runscript `%s': %s\n", + fprintf(stderr, "openrc-run `%s': %s\n", argv[1], strerror(errno)); exit(EXIT_FAILURE); } @@ -1420,3 +1420,10 @@ runscript(int argc, char **argv) return retval; } + +int +runscript(int argc, char **argv) +{ + ewarn("runscript is deprecated; please use openrc-run instead."); + return (openrc_run(argc, argv)); +} -- cgit v1.2.3