Compare commits

..

30 Commits

Author SHA1 Message Date
Roy Marples
a7fabeef95 Release OpenRC-0.5.1 2009-10-08 21:27:30 +01:00
Roy Marples
07f9be7b1c Add pkg-config support, fixes #187. 2009-10-08 00:20:43 +01:00
Roy Marples
42ca23b878 Don't quote opts 2009-09-21 19:05:47 +01:00
Roy Marples
3dc712e222 Allow init scripts to show their dependencies easier 2009-09-04 16:00:08 +01:00
Roy Marples
44585fea46 Add -P to start-stop-daemon to display a . for each second elapsed.
Fixes #197.
2009-09-04 15:41:08 +01:00
Roy Marples
6e485bde39 Really fix --signal 0 2009-09-04 13:32:59 +01:00
Roy Marples
2ea1df634e Fix signed error. 2009-09-04 13:24:26 +01:00
Roy Marples
807e5d7250 Timeout for ipv6 addresses being tentative. 2009-09-04 13:23:40 +01:00
Roy Marples
7012630302 Allow any valid numeric signal and not just what we define. 2009-09-01 13:57:45 +01:00
Roy Marples
51907c7368 If there is an error setting the font, abort instead of trying to set
the font for subsequent consoles.
2009-08-19 16:49:35 +01:00
Roy Marples
8da7a49d02 Fix example 2009-08-17 21:45:11 +01:00
Roy Marples
29949a5496 If mtab is write only and a symlink then assume it's linked to /proc/mounts
and don't try and update it. Fixes #185.
2009-07-20 19:47:08 +01:00
Roy Marples
7fbb6ad427 Don't provide ourself, fixes #190 2009-07-20 19:42:15 +01:00
Roy Marples
08b5664668 Only delete /etc/nologin if we can write to it 2009-07-09 13:32:27 +01:00
Roy Marples
7962218dd8 Apply MTU and txqueuelen after creating the tunnel. 2009-07-08 22:38:48 +01:00
Roy Marples
889b317ac6 Fix wpa_supplicant to find wireless interfaces on newer kernels.
Fixes #176.
2009-07-01 00:24:08 +01:00
Roy Marples
9907c90552 Host should configure urandom.
Fixes #179.
2009-07-01 00:13:25 +01:00
Roy Marples
b4104957b1 We should use -feature instead of nofeature.
This matches the ifconfig and Gentoo USE flag syntax and is hopefully
easier to read.
Fixes #178.
2009-07-01 00:07:32 +01:00
Roy Marples
6abeec7430 Use rc_getline instead of assuming a fixed kernel cmdline length.
This is now requires as COMMAND_LINE_SIZE isn't exposed by kernel
headers anymore.
Fixes #177.
2009-06-21 12:20:53 +01:00
Roy Marples
fbb78022f9 Ensure that tmp dirs are +rw as well as +t. 2009-06-13 21:12:50 +01:00
Natanael Copa
79b24f5b79 hwclock now sends help to stderr. 2009-06-12 23:11:16 +01:00
Roy Marples
fc6cdefedb Linux FHS requires /var/lib/misc
Stop fuser from being chatty
2009-06-08 22:18:39 +01:00
Roy Marples
43f6c2196e Release openrc-0.5.0 2009-06-05 09:20:11 +01:00
Roy Marples
c568baf8c8 Ignore more foo 2009-06-05 09:20:10 +01:00
Roy Marples
aaced3face Update copyright 2009-06-05 09:20:10 +01:00
Roy Marples
c3e9a7ec14 Warn about going inactive correctly. 2009-06-01 20:10:42 +01:00
Roy Marples
efec0b5012 nexthop routes don't use metrics 2009-06-01 20:06:56 +01:00
Roy Marples
278e65b24a Ignore termencoding 2009-05-29 22:09:39 +01:00
Roy Marples
1b3a413673 Skip sysctl errors 2009-05-29 22:08:47 +01:00
Roy Marples
a685e4db0a Add FreeBSD support for AC power. 2009-05-29 21:33:44 +01:00
68 changed files with 302 additions and 159 deletions

View File

@@ -2,9 +2,7 @@
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
NAME= openrc
VERSION= 0.5.0
PKG= ${NAME}-${VERSION}
include Makefile.inc
SUBDIR= conf.d etc init.d man sh src
@@ -16,6 +14,14 @@ _OLDNET_SH= case "${MKOLDNET}" in \
_OLDNET!= ${_OLDNET_SH}
SUBDIR+= ${_OLDNET}$(shell ${_OLDNET_SH})
# Build pkgconfig or not
_PKGCONFIG_SH= case "${MKPKGCONFIG}" in \
[Yy][Ee][Ss]|"") echo "pkgconfig";; \
*) echo "";; \
esac
_PKGCONFIG!= ${_PKGCONFIG_SH}
SUBDIR+= ${_PKGCONFIG}$(shell ${_PKGCONFIG_SH})
# We need to ensure that runlevels is done last
SUBDIR+= runlevels

3
Makefile.inc Normal file
View File

@@ -0,0 +1,3 @@
NAME= openrc
VERSION= 0.5.1
PKG= ${NAME}-${VERSION}

1
README
View File

@@ -11,6 +11,7 @@ PROGLDFLAGS=-static
LIBNAME=lib64
DESTDIR=/tmp/openrc-image
MKPAM=pam
MKPKGCONFIG=no
MKTERMCAP=ncurses
MKTERMCAP=termcap
MKOLDNET=yes

View File

@@ -992,7 +992,7 @@
# # 'from 24.80.102.112/32 to 192.168.1.0/24 table localnet priority 100' \
# # 'from 216.113.223.51/32 to 192.168.1.0/24 table localnet priority 100' \
# #"
# eval set -- $\rules_${IFVAR}
# eval set -- \$rules_${IFVAR}
# if [ $# != 0 ]; then
# einfo "Adding IP policy routing rules"
# eindent

View File

@@ -14,7 +14,7 @@ depend()
use logger
after bootmisc modules
before dns dhcpcd net
keyword noshutdown
keyword -shutdown
}
find_wireless()
@@ -24,7 +24,9 @@ find_wireless()
case "$RC_UNAME" in
Linux)
for iface in /sys/class/net/*; do
if [ -e "$iface"/wireless ]; then
if [ -e "$iface"/wireless -o \
-e "$iface"/phy80211 ]
then
echo "${iface##*/}"
return 0
fi

1
init.d/.gitignore vendored
View File

@@ -35,5 +35,6 @@ rpcbind
savecore
swap-blk
syslogd
termencoding
ttys
wscons

View File

@@ -22,7 +22,7 @@ depend()
[ "$clock" != "UTC" -a ! -e /etc/wall_cmos_clock ]; then
need root
fi
keyword nojail noprefix
keyword -jail -prefix
}
start()

View File

@@ -8,7 +8,7 @@ depend()
need localmount
before logger
after clock sysctl
keyword noprefix
keyword -prefix
}
dir_writeable()
@@ -26,7 +26,7 @@ cleanup_tmp_dir()
mkdir -p "$dir" || return $?
fi
dir_writeable "$dir" || return 1
chmod +t "$dir"
chmod a+rwt "$dir"
cd "$dir"
if yesno $wipe_tmp; then
ebegin "Wiping $dir directory"
@@ -76,9 +76,10 @@ start()
# Remove any added console dirs
rm -rf "$RC_LIBEXECDIR"/console
local logw=false runw=false
local logw=false runw=false extra=
# Ensure that our basic dirs exist
for x in /var/log /var/run /tmp; do
[ "$RC_UNAME" = Linux ] && extra=/var/lib/misc # Satisfy Linux FHS
for x in /var/log /var/run /tmp $extra; do
if ! [ -d $x ]; then
if ! mkdir -p $x; then
eend 1 "failed to create needed directory $x"
@@ -105,7 +106,7 @@ start()
# Clean stale sockets
if [ -S "$x" ]; then
if type fuser >/dev/null 2>&1; then
fuser "$x" 2>/dev/null || rm -- "$x"
fuser "$x" >/dev/null 2>&1 || rm -- "$x"
else
rm -- "$x"
fi
@@ -149,7 +150,7 @@ start()
fi
fi
rm -f /etc/nologin
[ -w /etc/nologin ] && rm -f /etc/nologin
return 0
}

View File

@@ -8,7 +8,7 @@ depend()
{
need localmount termencoding
after hotplug bootmisc
keyword noopenvz noprefix nouml novserver noxenu
keyword -openvz -prefix -uml -vserver -xenu
}
start()
@@ -45,8 +45,10 @@ start()
[ -d /dev/vc ] && ttydev=/dev/vc/
x=1
while [ $x -le $ttyn ]; do
setfont $consolefont $param -C $ttydev$x >/dev/null
retval=$(($retval + $?))
if ! setfont $consolefont $param -C $ttydev$x >/dev/null; then
retval=1
break
fi
x=$(($x + 1))
done
eend $retval

View File

@@ -10,7 +10,7 @@ depend() {
need localmount
after bootmisc
before net.lo0
keyword nojail noprefix
keyword -jail -prefix
}
start_pre() {

View File

@@ -6,7 +6,7 @@ description="Mount system critical filesystems in /dev."
depend() {
use dev
keyword noprefix novserver
keyword -prefix -vserver
}
start() {

View File

@@ -7,7 +7,7 @@ description="Set the dmesg level for a cleaner boot"
depend()
{
before dev modules
keyword novserver
keyword -vserver
}
start()

View File

@@ -6,7 +6,7 @@ description="Configures a specific kernel dump device."
depend() {
need swap
keyword nojail noprefix
keyword -jail -prefix
}
start() {

View File

@@ -9,7 +9,7 @@ _IFS="
depend()
{
use dev clock modules
keyword nojail noopenvz noprefix notimeout novserver
keyword -jail -openvz -prefix -timeout -vserver
}
_abort() {
@@ -51,6 +51,11 @@ _on_ac_power()
"connected:"*"OFF") return 128;;
esac
done
elif sysctl -q hw.acpi.acline >/dev/null 2>/dev/null; then
case $(sysctl -n hw.acpi.acline) in
0) return 1;;
*) return 0;;
esac
else
return 0
fi

View File

@@ -9,7 +9,7 @@ depend()
{
use root
before devd net
keyword nojail noprefix
keyword -jail -prefix
}
_set()

View File

@@ -5,7 +5,7 @@
description="Sets the hostname of the machine."
depend() {
keyword noprefix
keyword -prefix
}
start()

View File

@@ -28,7 +28,7 @@ depend()
else
before *
fi
keyword noopenvz noprefix nouml novserver noxenu
keyword -openvz -prefix -uml -vserver -xenu
}
setupopts()
@@ -118,7 +118,7 @@ stop()
if ! yesno $clock_adjfile; then
# Some implementations don't handle adjustments
if LC_ALL=C hwclock --help | grep -q "\-\-noadjfile"; then
if LC_ALL=C hwclock --help 2>&1 | grep -q "\-\-noadjfile"; then
utc_cmd="$utc_cmd --noadjfile"
fi
fi

View File

@@ -13,7 +13,7 @@ opts="panic showstatus"
depend() {
before net
provide firewall
keyword nojail
keyword -jail
}
ipfw() {

View File

@@ -8,7 +8,7 @@ depend()
{
need localmount termencoding
after bootmisc
keyword noopenvz noprefix nouml novserver noxenu
keyword -openvz -prefix -uml -vserver -xenu
}
start()

View File

@@ -6,7 +6,7 @@ description="Kill all processes so we can unmount disks cleanly."
depend()
{
keyword noprefix
keyword -prefix
}
start()

View File

@@ -7,7 +7,7 @@ description="Executes user commands in /etc/conf.d/local"
depend()
{
after *
keyword notimeout
keyword -timeout
}
start()

View File

@@ -8,7 +8,7 @@ depend()
{
need fsck
use lvm modules mtab
keyword nojail noopenvz noprefix novserver
keyword -jail -openvz -prefix -vserver
}
start()

View File

@@ -7,7 +7,7 @@ extra_commands="restore"
depend()
{
need localmount
keyword nojail noprefix
keyword -jail -prefix
}
restore()

View File

@@ -7,7 +7,7 @@ description="Loads a user defined list of kernel modules."
depend()
{
use isapnp
keyword noopenvz noprefix novserver
keyword -openvz -prefix -vserver
}
start()

View File

@@ -7,7 +7,7 @@ description="Re-mount filesytems read-only for a clean reboot."
depend()
{
need killprocs savecache
keyword noprefix noopenvz novserver
keyword -prefix -openvz -vserver
}
start()

View File

@@ -16,7 +16,7 @@ depend()
{
need localmount
after bootmisc
keyword nojail noprefix
keyword -jail -prefix
}
start()

View File

@@ -7,11 +7,17 @@ description="Update /etc/mtab to match what the kernel knows about"
depend()
{
need root
keyword noprefix
keyword -prefix
}
start()
{
# /etc/mtab could be a symlink to /proc/mounts
if [ ! -w /etc/mtab -a -L /etc/mtab ]; then
eeinfo "Skipping mtab update (non writeable symlink)"
return 0
fi
ebegin "Updating /etc/mtab"
if ! echo 2>/dev/null >/etc/mtab; then
ewend 1 "/etc/mtab is not updateable"

View File

@@ -21,7 +21,7 @@ depend()
need localmount
after bootmisc
provide net
keyword nojail noprefix novserver
keyword -jail -prefix -vserver
case "${IFACE}" in
lo|lo0);;

View File

@@ -35,7 +35,7 @@ depend()
need net $pmap
use afc-client amd autofs openvpn
use dns nfs nfsmount portmap rpcbind rpc.statd rpc.lockd
keyword nojail noprefix novserver
keyword -jail -prefix -vserver
}
start()

View File

@@ -13,7 +13,7 @@ depend()
need localmount
after bootmisc
provide net
keyword nojail noprefix novserver
keyword -jail -prefix -vserver
}
uniqify()

View File

@@ -7,7 +7,7 @@ required_files="/etc/newsyslog.conf"
depend()
{
need localmount
keyword noprefix
keyword -prefix
}
start()

View File

@@ -9,7 +9,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
depend()
{
need localmount
keyword noopenvz noprefix novserver
keyword -openvz -prefix -vserver
}
_setleds()

View File

@@ -11,7 +11,7 @@ extra_started_commands="reload"
depend() {
need localmount
keyword nojail noprefix
keyword -jail -prefix
}
start()

View File

@@ -12,7 +12,7 @@ depend()
need localmount
use logger
after bootmisc
keyword nojail noprefix
keyword -jail -prefix
}
start_pre()

View File

@@ -8,7 +8,7 @@ depend()
{
use modules devfs
need localmount
keyword noopenvz noprefix novserver
keyword -openvz -prefix -vserver
}
start()

View File

@@ -7,7 +7,7 @@ depend()
need localmount net
after *
before local
keyword noprefix
keyword -prefix
}
start()

View File

@@ -7,7 +7,7 @@ description="Mount the root fs read/write"
depend()
{
need fsck
keyword nojail noopenvz noprefix novserver
keyword -jail -openvz -prefix -vserver
}
start()

View File

@@ -7,7 +7,7 @@ description="Saves a kernel dump."
depend()
{
need localmount
keyword nojail noprefix
keyword -jail -prefix
}
start()

View File

@@ -5,7 +5,7 @@
depend()
{
before fsck
keyword nojail noprefix
keyword -jail -prefix
}
start()

View File

@@ -5,7 +5,7 @@
depend()
{
need localmount
keyword nojail noopenvz noprefix novserver
keyword -jail -openvz -prefix -vserver
}
start()

View File

@@ -4,7 +4,7 @@
depend() {
need localmount
keyword nojail noprefix
keyword -jail -prefix
}
start() {

View File

@@ -6,7 +6,7 @@ depend()
{
use hostname
before bootmisc logger
keyword noprefix
keyword -prefix
}
start()

View File

@@ -6,7 +6,7 @@ depend()
{
use hostname
before bootmisc logger
keyword noopenvz noprefix novserver
keyword -openvz -prefix -vserver
}
start()

View File

@@ -6,7 +6,7 @@ description="Mount the sys filesystem."
depend()
{
keyword noprefix novserver
keyword -prefix -vserver
}
mount_sys()

View File

@@ -16,5 +16,5 @@ depend()
use net newsyslog
need localmount
after bootmisc
keyword noprefix
keyword -prefix
}

View File

@@ -9,7 +9,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
depend()
{
keyword noopenvz noprefix nouml novserver noxenu
keyword -openvz -prefix -uml -vserver -xenu
}
start()

View File

@@ -5,7 +5,7 @@
depend()
{
after fsck
keyword noprefix
keyword -prefix
}
start()

View File

@@ -8,7 +8,7 @@ description="Initializes the random number generator."
depend()
{
need localmount
keyword nojail noprefix
keyword -jail -openvz -prefix
}
save_seed()

View File

@@ -5,7 +5,7 @@
depend()
{
need localmount
keyword noprefix
keyword -prefix
}
start()

View File

@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd April 30, 2009
.Dd July 1, 2009
.Dt RUNSCRIPT 8 SMM
.Os OpenRC
.Sh NAME
@@ -138,30 +138,30 @@ We should recalculate our dependencies if the listed files have changed.
.It Ic keyword
Tags a service with a keyword. Here's the keywords we currently understand:-
.Bl -tag -width indent
.It Dv nojail
.It Dv -jail
When in a jail, exclude this service from any dependencies. The service can
still be run directly.
.It Dv noopenvz
Same as nojail, but for OpenVZ systems.
.It Dv noshutdown
.It Dv -openvz
Same as -jail, but for OpenVZ systems.
.It Dv -shutdown
Don't stop this service when shutting the system down.
This 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 nostop
.It Dv -stop
Don't stop this service when changing runlevels, even if not present.
This includes shutting the system down.
.It Dv notimeout
.It Dv -timeout
Do not time out waiting for that service.
.It Dv nouml
Same as nojail, but for UML systems.
.It Dv novserver
Same as nojail, but for VServer systems.
.It Dv noxen0
Same as nojail, but for Xen DOM0 systems.
.It Dv noxenu
Same as nojail, but for Xen DOMU 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

View File

@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd April 22, 2009
.Dd September 4, 2009
.Dt START-STOP-DAEMON 8 SMM
.Os OpenRC
.Sh NAME
@@ -98,6 +98,8 @@ Print the action(s) that would be taken, but don't actually do anything.
The return value is set as if the command was taken and worked.
.It Fl v , -verbose
Print the action(s) that are taken just before doing them.
.It Fl P , -progress
Echo a . to the console for each second elapsed whilst waiting.
.El
.Pp
These options are only used for starting daemons:

View File

@@ -261,6 +261,17 @@ _tunnel()
ifconfig_pre_start()
{
local tunnel=
eval tunnel=\$iptunnel_${IFVAR}
if [ -n "${tunnel}" ]; then
# Set our base metric to 1000
metric=1000
ebegin "Creating tunnel ${IFVAR}"
iptunnel add ${tunnel}
eend $? || return 1
_up
fi
# MTU support
local mtu=
eval mtu=\$mtu_${IFVAR}
@@ -271,17 +282,7 @@ ifconfig_pre_start()
eval len=\$txqueuelen_${IFVAR}
[ -n "${len}" ] && ifconfig "${IFACE}" txqueuelen "${len}"
local tunnel=
eval tunnel=\$iptunnel_${IFVAR}
[ -z "${tunnel}" ] && return 0
# Set our base metric to 1000
metric=1000
ebegin "Creating tunnel ${IFVAR}"
iptunnel add ${tunnel}
eend $?
return 0
}
ifconfig_post_stop()

View File

@@ -157,7 +157,10 @@ _add_route()
shift
done
if ! ${have_metric} && [ -n "${metric}" ]; then
# We cannot use a metric if we're using a nexthop
if ! ${have_metric} && \
[ -n "${metric}" -a -z "${cmd##* nexthop }" ]
then
cmd="${cmd} metric ${metric}"
fi
@@ -187,16 +190,6 @@ _tunnel()
iproute2_pre_start()
{
# MTU support
local mtu=
eval mtu=\$mtu_${IFVAR}
[ -n "${mtu}" ] && ip link set "${IFACE}" mtu "${mtu}"
# TX Queue Length support
local len=
eval len=\$txqueuelen_${IFVAR}
[ -n "${len}" ] && ip link set "${IFACE}" txqueuelen "${len}"
local tunnel=
eval tunnel=\$iptunnel_${IFVAR}
if [ -n "${tunnel}" ]; then
@@ -209,6 +202,16 @@ iproute2_pre_start()
_up
fi
# MTU support
local mtu=
eval mtu=\$mtu_${IFVAR}
[ -n "${mtu}" ] && ip link set "${IFACE}" mtu "${mtu}"
# TX Queue Length support
local len=
eval len=\$txqueuelen_${IFVAR}
[ -n "${len}" ] && ip link set "${IFACE}" txqueuelen "${len}"
return 0
}
@@ -222,6 +225,8 @@ _iproute2_ipv6_tentative()
iproute2_post_start()
{
local n=5
# Kernel may not have IP built in
if [ -e /proc/net/route ]; then
ip route flush table cache dev "${IFACE}"
@@ -229,11 +234,16 @@ iproute2_post_start()
if _iproute2_ipv6_tentative; then
ebegin "Waiting for IPv6 addresses"
while true; do
while [ $n -ge 0 ]; do
_iproute2_ipv6_tentative || break
sleep 1
n=$(($n - 1))
done
eend 0
[ $n -ge 0 ]
eend $?
fi
return 0
}
iproute2_post_stop()

2
pkgconfig/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
einfo.pc
openrc.pc

11
pkgconfig/Makefile Normal file
View File

@@ -0,0 +1,11 @@
DIR= ${LIBDIR}/pkgconfig
SRCS= einfo.pc.in openrc.pc.in
INC= einfo.pc openrc.pc
sed -n -e 's/^VERSION=[[:space:]]*\([^[:space:]]*\).*/#define VERSION "\1${GITVER}\"/p' ../../Makefile > version.h
SED_EXTRA= -e 's:@VERSION@:${VERSION}:g'
MK= ../mk
include ../Makefile.inc
include ${MK}/scripts.mk

9
pkgconfig/einfo.pc.in Normal file
View File

@@ -0,0 +1,9 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/@LIB@
includedir=/usr/include
Name: einfo
Description: Pretty console informational display
Version: @VERSION@
Libs: -L${libdir} -leinfo

10
pkgconfig/openrc.pc.in Normal file
View File

@@ -0,0 +1,10 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/@LIB@
includedir=/usr/include
Name: OpenRC
Description: Universal init system
Version: @VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lrc

View File

@@ -25,6 +25,29 @@ shift
# Compat
export SVCNAME=$RC_SVCNAME
# Dependency function
config() {
[ -n "$*" ] && echo "config $*"
}
need() {
[ -n "$*" ] && echo "need $*"
}
use() {
[ -n "$*" ] && echo "use $*"
}
before() {
[ -n "$*" ] && echo "before $*"
}
after() {
[ -n "$*" ] && echo "after $*"
}
provide() {
[ -n "$*" ] && echo "provide $*"
}
keyword() {
[ -n "$*" ] && echo "keyword $*"
}
# Descript the init script to the user
describe()
{
@@ -165,7 +188,7 @@ unset _f
while [ -n "$1" ]; do
# See if we have the required function and run it
for _cmd in describe start stop status ${extra_commands:-$opts} \
for _cmd in describe start stop status depend ${extra_commands:-$opts} \
$extra_started_commands
do
if [ "$_cmd" = "$1" ]; then

View File

@@ -738,7 +738,7 @@ rc_deptree_update(void)
RC_STRING *s, *s2, *s2_np, *s3, *s4;
char *line = NULL;
size_t len = 0;
char *depend, *depends, *service, *type, *nosys;
char *depend, *depends, *service, *type, *nosys, *onosys;
size_t i, k, l;
bool retval = true;
const char *sys = rc_sys();
@@ -802,6 +802,11 @@ rc_deptree_update(void)
continue;
}
/* Don't provide ourself */
if (strcmp(type, "iprovide") == 0 &&
strcmp(depend, service) == 0)
continue;
/* .sh files are not init scripts */
l = strlen(depend);
if (l > 2 &&
@@ -841,17 +846,25 @@ rc_deptree_update(void)
* work for them. This doesn't stop them from being run directly. */
if (sys) {
len = strlen(sys);
nosys = xmalloc(len + 3);
nosys[0] = 'n';
nosys[1] = 'o';
nosys = xmalloc(len + 1);
nosys[0] = '-';
for (i = 0; i < len; i++)
nosys[i + 2] = (char)tolower((unsigned char)sys[i]);
nosys[i + 2] = '\0';
nosys[i + 1] = (char)tolower((unsigned char)sys[i]);
nosys[i + 1] = '\0';
onosys = xmalloc(len + 3);
onosys[0] = 'n';
onosys[1] = 'o';
for (i = 0; i < len; i++)
onosys[i + 2] = (char)tolower((unsigned char)sys[i]);
onosys[i + 2] = '\0';
TAILQ_FOREACH_SAFE(depinfo, deptree, entries, depinfo_np)
if ((deptype = get_deptype(depinfo, "keyword")))
TAILQ_FOREACH(s, deptype->services, entries)
if (strcmp(s->value, nosys) == 0) {
if (strcmp(s->value, nosys) == 0 ||
strcmp(s->value, onosys) == 0)
{
provide = get_deptype(depinfo, "iprovide");
TAILQ_REMOVE(deptree, depinfo, entries);
TAILQ_FOREACH(di, deptree, entries) {
@@ -870,6 +883,7 @@ rc_deptree_update(void)
}
}
free(nosys);
free(onosys);
}
/* Phase 3 - add our providers to the tree */

View File

@@ -468,7 +468,7 @@ rc_service_exists(const char *service)
}
librc_hidden_def(rc_service_exists)
#define OPTSTR ". '%s'; echo \"${opts}\""
#define OPTSTR ". '%s'; echo $opts"
RC_STRINGLIST *
rc_service_extra_commands(const char *service)
{

View File

@@ -72,8 +72,6 @@
#define librc_hidden_proto(x) hidden_proto(x)
#define librc_hidden_def(x) hidden_def(x)
ssize_t rc_getline(char **, size_t *, FILE *);
librc_hidden_proto(rc_config_list)
librc_hidden_proto(rc_config_load)
librc_hidden_proto(rc_config_value)

View File

@@ -517,5 +517,9 @@ typedef LIST_HEAD(rc_pidlist, rc_pid) RC_PIDLIST;
* @return NULL terminated list of pids */
RC_PIDLIST *rc_find_pids(const char *, const char *const *, uid_t, pid_t);
/* getline is a handy glibc function that not all libcs have, so
* we have our own */
ssize_t rc_getline(char **, size_t *, FILE *);
__END_DECLS
#endif

View File

@@ -12,6 +12,7 @@ global:
rc_deptree_update_needed;
rc_environ_fd;
rc_find_pids;
rc_getline;
rc_newer_than;
rc_older_than;
rc_runlevel_exists;

View File

@@ -34,6 +34,7 @@ CPPFLAGS+= -I../includes -I../librc -I../libeinfo
LDFLAGS+= -L../librc -L../libeinfo
LDADD+= -lutil -lrc -leinfo
include ../../Makefile.inc
MK= ../../mk
include ${MK}/debug.mk
include ${MK}/prog.mk
@@ -46,7 +47,7 @@ include ${MK}/${MKPAM}.mk
${SRCS}: version.h
version.h:
sed -n -e 's/^VERSION=[[:space:]]*\([^[:space:]]*\).*/#define VERSION "\1${GITVER}\"/p' ../../Makefile > version.h
echo "#define VERSION \"${VERSION}${GITVER}\"" >version.h
if test -n "${BRANDING}"; then \
echo "#define BRANDING \"${BRANDING}\"" >> version.h; \
fi

View File

@@ -43,10 +43,6 @@ const char rc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
#include <sys/utsname.h>
#include <sys/wait.h>
#ifdef __linux__
# include <asm/setup.h> /* for COMMAND_LINE_SIZE */
#endif
#include <errno.h>
#include <dirent.h>
#include <ctype.h>
@@ -177,10 +173,8 @@ static char *
proc_getent(const char *ent)
{
FILE *fp;
char proc[COMMAND_LINE_SIZE];
char *p;
char *value = NULL;
int i;
char *proc, *p, *value = NULL;
size_t i;
if (!exists("/proc/cmdline"))
return NULL;
@@ -190,11 +184,11 @@ proc_getent(const char *ent)
return NULL;
}
memset(proc, 0, sizeof(proc));
p = fgets(proc, sizeof(proc), fp);
if (p == NULL)
eerror("fgets: %s", strerror(errno));
else if (*proc && (p = strstr(proc, ent))) {
proc = NULL;
i = 0;
if (rc_getline(&proc, &i, fp) == -1 || proc == NULL)
eerror("rc_getline: %s", strerror(errno));
if (*proc && (p = strstr(proc, ent))) {
i = p - proc;
if (i == '\0' || proc[i - 1] == ' ') {
p += strlen(ent);
@@ -205,6 +199,7 @@ proc_getent(const char *ent)
} else
errno = ENOENT;
fclose(fp);
free(proc);
return value;
}
@@ -605,8 +600,11 @@ do_stop_services(const char *newlevel, bool parallel, bool going_down)
continue;
}
kwords = rc_deptree_depend(deptree, service->value, "keyword");
if (rc_stringlist_find(kwords, "nostop") ||
(going_down && rc_stringlist_find(kwords, "noshutdown")))
if (rc_stringlist_find(kwords, "-stop") ||
rc_stringlist_find(kwords, "nostop") ||
(going_down &&
(rc_stringlist_find(kwords, "-shutdown") ||
rc_stringlist_find(kwords, "noshutdown"))))
nstop = true;
else
nstop = false;

View File

@@ -471,7 +471,8 @@ svc_wait(const char *svc)
/* Some services don't have a timeout, like fsck */
keywords = rc_deptree_depend(deptree, svc, "keyword");
if (rc_stringlist_find(keywords, "notimeout"))
if (rc_stringlist_find(keywords, "-timeout") ||
rc_stringlist_find(keywords, "notimeout"))
forever = true;
rc_stringlist_free(keywords);
@@ -755,13 +756,10 @@ static void svc_start_real()
if (ibsave)
unsetenv("IN_BACKGROUND");
if (!started)
if (rc_service_state(service) & RC_SERVICE_INACTIVE)
ewarnx("WARNING: %s has started, but is inactive", applet);
else if (!started)
eerrorx("ERROR: %s failed to start", applet);
else {
if (rc_service_state(service) & RC_SERVICE_INACTIVE)
ewarnx("WARNING: %s has started, but is inactive",
applet);
}
rc_service_mark(service, RC_SERVICE_STARTED);
exclusive_fd = svc_unlock(applet, exclusive_fd);
@@ -1275,7 +1273,8 @@ runscript(int argc, char **argv)
doneone = true;
if (strcmp(optarg, "describe") == 0 ||
strcmp(optarg, "help") == 0)
strcmp(optarg, "help") == 0 ||
strcmp(optarg, "depend") == 0)
{
save = prefix;
eprefix(NULL);

View File

@@ -155,7 +155,8 @@ parse_signal(const char *sig)
{ "STOP", SIGSTOP },
{ "TSTP", SIGTSTP },
{ "TTIN", SIGTTIN },
{ "TTOU", SIGTTOU }
{ "TTOU", SIGTTOU },
{ "NULL", 0 },
};
unsigned int i = 0;
@@ -165,7 +166,7 @@ parse_signal(const char *sig)
return -1;
if (sscanf(sig, "%u", &i) == 1) {
if (i > 0 && i < sizeof(signallist) / sizeof(signallist[0]))
if (i < NSIG)
return i;
eerrorx("%s: `%s' is not a valid signal", applet, sig);
}
@@ -369,16 +370,17 @@ do_stop(const char *exec, const char *const *argv,
static int
run_stop_schedule(const char *exec, const char *const *argv,
const char *pidfile, uid_t uid,
bool quiet, bool verbose, bool test)
bool quiet, bool verbose, bool test, bool progress)
{
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
int nkilled = 0;
int tkilled = 0;
int nrunning = 0;
long nloops;
long nloops, nsecs;
struct timespec ts;
pid_t pid = 0;
const char *const *p;
bool progressed = false;
if (verbose) {
if (exec)
@@ -416,6 +418,8 @@ run_stop_schedule(const char *exec, const char *const *argv,
quiet, verbose, test);
if (nkilled == 0) {
if (tkilled == 0) {
if (progressed)
printf("\n");
if (! quiet)
eerror("%s: no matching "
"processes found", applet);
@@ -433,30 +437,47 @@ run_stop_schedule(const char *exec, const char *const *argv,
break;
}
nloops = (ONE_SECOND / POLL_INTERVAL) * item->value;
ts.tv_sec = 0;
ts.tv_nsec = POLL_INTERVAL;
while (nloops) {
if ((nrunning = do_stop(exec, argv, pid,
uid, 0, true, false, true)) == 0)
return 0;
if (nanosleep(&ts, NULL) == -1) {
if (errno == EINTR)
eerror("%s: caught an"
" interrupt", applet);
else {
eerror("%s: nanosleep: %s",
applet, strerror(errno));
for (nsecs = 0; nsecs < item->value; nsecs++) {
for (nloops = 0;
nloops < ONE_SECOND / POLL_INTERVAL;
nloops++)
{
if ((nrunning = do_stop(exec, argv,
pid, uid, 0, true, false,
true)) == 0)
return 0;
if (nanosleep(&ts, NULL) == -1) {
if (progressed) {
printf("\n");
progressed = false;
}
if (errno == EINTR)
eerror("%s: caught an"
" interrupt", applet);
else {
eerror("%s: nanosleep: %s",
applet, strerror(errno));
return 0;
}
}
}
nloops --;
if (progress) {
printf(".");
fflush(stdout);
progressed = true;
}
}
break;
default:
if (progressed) {
printf("\n");
progressed = false;
}
eerror("%s: invalid schedule item `%d'",
applet, item->type);
return 0;
@@ -469,6 +490,8 @@ run_stop_schedule(const char *exec, const char *const *argv,
if (test || (tkilled > 0 && nrunning == 0))
return nkilled;
if (progressed)
printf("\n");
if (! quiet) {
if (nrunning == 1)
eerror("%s: %d process refused to stop",
@@ -549,7 +572,7 @@ expand_home(const char *home, const char *path)
ppath++;
if (!home) {
free(opath);
free(opath);
return xstrdup(path);
}
if (!ppath) {
@@ -565,7 +588,7 @@ expand_home(const char *home, const char *path)
}
#include "_usage.h"
#define getoptstring "KN:R:Sbc:d:e:g:ik:mn:op:s:tu:r:w:x:1:2:" getoptstring_COMMON
#define getoptstring "KN:PR:Sbc:d:e:g:ik:mn:op:s:tu:r:w:x:1:2:" getoptstring_COMMON
static const struct option longopts[] = {
{ "stop", 0, NULL, 'K'},
{ "nicelevel", 1, NULL, 'N'},
@@ -591,6 +614,7 @@ static const struct option longopts[] = {
{ "exec", 1, NULL, 'x'},
{ "stdout", 1, NULL, '1'},
{ "stderr", 1, NULL, '2'},
{ "progress", 0, NULL, 'P'},
longopts_COMMON
};
static const char * const longopts_help[] = {
@@ -618,6 +642,7 @@ static const char * const longopts_help[] = {
"Binary to start/stop",
"Redirect stdout to file",
"Redirect stderr to file",
"Print dots each second while waiting",
longopts_help_COMMON
};
#include "_usage.c"
@@ -648,11 +673,12 @@ start_stop_daemon(int argc, char **argv)
char *name = NULL;
char *pidfile = NULL;
char *retry = NULL;
int sig = 0;
int sig = -1;
int nicelevel = 0;
bool background = false;
bool makepidfile = false;
bool interpreted = false;
bool progress = false;
uid_t uid = 0;
gid_t gid = 0;
char *home = NULL;
@@ -714,12 +740,17 @@ start_stop_daemon(int argc, char **argv)
case 'K': /* --stop */
stop = true;
break;
case 'N': /* --nice */
if (sscanf(optarg, "%d", &nicelevel) != 1)
eerrorx("%s: invalid nice level `%s'",
applet, optarg);
break;
case 'P': /* --progress */
progress = true;
break;
case 'R': /* --retry <schedule>|<timeout> */
retry = optarg;
break;
@@ -885,8 +916,8 @@ start_stop_daemon(int argc, char **argv)
else if (exec)
*--argv = exec;
if (stop || sig != 0) {
if (sig == 0)
if (stop || sig != -1) {
if (sig == -1)
sig = SIGTERM;
if (!*argv && !pidfile && !name && !uid)
eerrorx("%s: --stop needs --exec, --pidfile,"
@@ -989,8 +1020,8 @@ start_stop_daemon(int argc, char **argv)
}
margv = nav ? nav : argv;
if (stop || sig) {
if (sig == 0)
if (stop || sig != -1) {
if (sig == -1)
sig = SIGTERM;
if (!stop)
oknodo = true;
@@ -1001,7 +1032,7 @@ start_stop_daemon(int argc, char **argv)
else
parse_schedule(NULL, sig);
i = run_stop_schedule(exec, (const char *const *)margv,
pidfile, uid, quiet, verbose, test);
pidfile, uid, quiet, verbose, test, progress);
if (i < 0)
/* We failed to stop something */

View File

@@ -20,6 +20,8 @@ rc_deptree_update_needed
rc_deptree_update_needed@@RC_1.0
rc_find_pids
rc_find_pids@@RC_1.0
rc_getline
rc_getline@@RC_1.0
rc_newer_than
rc_newer_than@@RC_1.0
rc_older_than