Compare commits
15 Commits
funtoo-ope
...
openrc-0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0853c110e5 | ||
|
|
1a43ce11d0 | ||
|
|
46e504b403 | ||
|
|
fc1f3d14f4 | ||
|
|
b8a016aaba | ||
|
|
63f5256b59 | ||
|
|
c420f56856 | ||
|
|
5b0f323da9 | ||
|
|
d86853538a | ||
|
|
f2c0e700c6 | ||
|
|
b1de9d7324 | ||
|
|
5b4886d23e | ||
|
|
2a53efbc07 | ||
|
|
a530722f65 | ||
|
|
661e9cf002 |
@@ -1,3 +1,3 @@
|
|||||||
NAME= openrc
|
NAME= openrc
|
||||||
VERSION= 0.12.1
|
VERSION= 0.12.4
|
||||||
PKG= ${NAME}-${VERSION}
|
PKG= ${NAME}-${VERSION}
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
# Set to the fully-qualified hostname of this machine
|
# Set to the hostname of this machine
|
||||||
hostname="localhost"
|
hostname="localhost"
|
||||||
|
|||||||
11
etc/rc.conf.GNU-kFreeBSD
Normal file
11
etc/rc.conf.GNU-kFreeBSD
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
##############################################################################
|
||||||
|
# GNU/kFreeBSD SPECIFIC OPTIONS
|
||||||
|
|
||||||
|
# This is the subsystem type. Valid options on GNU/kFreeBSD:
|
||||||
|
# "" - nothing special
|
||||||
|
# "jail" - FreeBSD jails (not yet implemented)
|
||||||
|
# If this is commented out, automatic detection will be used.
|
||||||
|
#
|
||||||
|
# This should be set to the value representing the environment this file is
|
||||||
|
# PRESENTLY in, not the virtualization the environment is capable of.
|
||||||
|
#rc_sys=""
|
||||||
3
init.d/.gitignore
vendored
3
init.d/.gitignore
vendored
@@ -4,6 +4,8 @@ hostname
|
|||||||
local
|
local
|
||||||
localmount
|
localmount
|
||||||
moused
|
moused
|
||||||
|
net.lo
|
||||||
|
net.lo0
|
||||||
netmount
|
netmount
|
||||||
network
|
network
|
||||||
root
|
root
|
||||||
@@ -39,5 +41,4 @@ syslogd
|
|||||||
termencoding
|
termencoding
|
||||||
ttys
|
ttys
|
||||||
wscons
|
wscons
|
||||||
tmpfiles.dev
|
|
||||||
tmpfiles.setup
|
tmpfiles.setup
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
include ../mk/net.mk
|
include ../mk/net.mk
|
||||||
|
|
||||||
DIR= ${INITDIR}
|
DIR= ${INITDIR}
|
||||||
SRCS= bootmisc.in fsck.in hostname.in local.in localmount.in \
|
SRCS= bootmisc.in fsck.in hostname.in local.in localmount.in loopback.in \
|
||||||
netmount.in root.in savecache.in swap.in swapfiles.in \
|
netmount.in root.in savecache.in swap.in swapfiles.in \
|
||||||
tmpfiles.setup.in swclock.in sysctl.in urandom.in ${SRCS-${OS}}
|
tmpfiles.setup.in swclock.in sysctl.in urandom.in ${SRCS-${OS}}
|
||||||
BIN= ${OBJS}
|
BIN= ${OBJS}
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ migrate_to_run()
|
|||||||
|
|
||||||
clean_run()
|
clean_run()
|
||||||
{
|
{
|
||||||
|
[ "$RC_SYS" = VSERVER ] && return 0
|
||||||
local dir
|
local dir
|
||||||
dir=$(mktemp -d)
|
dir=$(mktemp -d)
|
||||||
mount --bind / $dir
|
mount --bind / $dir
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ _IFS="
|
|||||||
depend()
|
depend()
|
||||||
{
|
{
|
||||||
use dev clock modules
|
use dev clock modules
|
||||||
keyword -jail -openvz -prefix -timeout -vserver -lxc
|
keyword -jail -openvz -prefix -timeout -vserver -lxc -uml
|
||||||
}
|
}
|
||||||
|
|
||||||
_abort() {
|
_abort() {
|
||||||
|
|||||||
@@ -1,42 +1,18 @@
|
|||||||
#!@PREFIX@/sbin/runscript
|
#!@SBINDIR@/runscript
|
||||||
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
||||||
# Released under the 2-clause BSD license.
|
# Released under the 2-clause BSD license.
|
||||||
|
|
||||||
description="Sets the hostname of the machine."
|
description="Sets the hostname of the machine."
|
||||||
|
|
||||||
depend() {
|
depend() {
|
||||||
need root
|
keyword -prefix -lxc
|
||||||
}
|
}
|
||||||
|
|
||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
hostname=${hostname-${HOSTNAME-localhost}}
|
# HOSTNAME variable used to be defined in caps in conf.d/hostname.
|
||||||
out=$hostname
|
# It is also a magic variable in bash.
|
||||||
short=${hostname%%.*}
|
hostname=${hostname-${HOSTNAME-localhost}} # checkbashisms: false positive
|
||||||
if [ "$short" != "$hostname" ]; then
|
|
||||||
out="$out $short"
|
|
||||||
fi
|
|
||||||
if [ "$nisdomainname" != "" ]; then
|
|
||||||
ebegin "Setting NIS domain name to $nisdomainname"
|
|
||||||
nisdomainname $nisdomainname
|
|
||||||
eend $? "Failed to set the NIS domain name"
|
|
||||||
fi
|
|
||||||
if [ "$short" != "localhost" ]; then
|
|
||||||
out="$out localhost"
|
|
||||||
fi
|
|
||||||
if [ "$hostname" != "localhost.localdomain" ]; then
|
|
||||||
out="$out localhost.localdomain"
|
|
||||||
fi
|
|
||||||
[ -n "$aliases" ] && out="$out $aliases"
|
|
||||||
ebegin "Configuring /etc/hosts"
|
|
||||||
[ -e /etc/hosts ] && sed -i -e '/[[:space:]]*127.0.0.1[[:space:]]/d' -e '/[[:space:]]*::1[[:space:]]/d' /etc/hosts
|
|
||||||
cat <<END >> /etc/hosts
|
|
||||||
127.0.0.1 $out
|
|
||||||
::1 $out
|
|
||||||
END
|
|
||||||
chmod 0644 /etc/hosts
|
|
||||||
eend $?
|
|
||||||
[ "$RC_SYS" = "LXC" ] && return 0
|
|
||||||
ebegin "Setting hostname to $hostname"
|
ebegin "Setting hostname to $hostname"
|
||||||
hostname "$hostname"
|
hostname "$hostname"
|
||||||
eend $? "Failed to set the hostname"
|
eend $? "Failed to set the hostname"
|
||||||
|
|||||||
35
init.d/loopback.in
Normal file
35
init.d/loopback.in
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!@SBINDIR@/runscript
|
||||||
|
# Copyright (c) 2013 William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
# Released under the 2-clause BSD license.
|
||||||
|
|
||||||
|
description="Configures the loopback interface."
|
||||||
|
|
||||||
|
depend()
|
||||||
|
{
|
||||||
|
keyword -jail -prefix -vserver
|
||||||
|
}
|
||||||
|
|
||||||
|
start()
|
||||||
|
{
|
||||||
|
if [ "$RC_UNAME" = Linux ]; then
|
||||||
|
ebegin "Bringing up network interface lo"
|
||||||
|
if type ip > /dev/null 2>&1; then
|
||||||
|
ip addr add 127.0.0.1/8 dev lo brd + scope host
|
||||||
|
ip route add 127.0.0.0/8 dev lo scope host
|
||||||
|
ip link set lo up
|
||||||
|
else
|
||||||
|
ifconfig lo 127.0.0.1 netmask 255.0.0.0
|
||||||
|
route add -net 127.0.0.0 netmask 255.0.0.0 gw 127.0.0.1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
ebegin "Bringing up network interface lo0"
|
||||||
|
ifconfig lo0 127.0.0.1 netmask 255.0.0.0
|
||||||
|
route -q add -inet 127.0.0.0 -netmask 255.0.0.0 127.0.0.1
|
||||||
|
fi
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
stop()
|
||||||
|
{
|
||||||
|
return 0
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#!@PREFIX@/sbin/runscript
|
#!@SBINDIR@/runscript
|
||||||
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
||||||
# Released under the 2-clause BSD license.
|
# Released under the 2-clause BSD license.
|
||||||
|
|
||||||
depend()
|
depend()
|
||||||
{
|
{
|
||||||
before bootmisc logger
|
before bootmisc logger
|
||||||
keyword -lxc -vserver
|
keyword -lxc -prefix -vserver
|
||||||
}
|
}
|
||||||
|
|
||||||
start()
|
start()
|
||||||
@@ -15,14 +15,6 @@ start()
|
|||||||
ebegin "Configuring kernel parameters"
|
ebegin "Configuring kernel parameters"
|
||||||
eindent
|
eindent
|
||||||
|
|
||||||
# default sysctl System V max shared memory to 1/4 of RAM:
|
|
||||||
mem_bytes=`awk '/MemTotal:/ { printf "%0.f",$2 * 1024}' /proc/meminfo`
|
|
||||||
mem_max=`expr $mem_bytes / 4`
|
|
||||||
page_size=`getconf PAGE_SIZE`
|
|
||||||
shmall=`expr $mem_bytes / $page_size`
|
|
||||||
sysctl kernel.shmmax=$mem_max > /dev/null
|
|
||||||
sysctl kernel.shmall=$shmall > /dev/null
|
|
||||||
|
|
||||||
for conf in @SYSCONFDIR@/sysctl.conf @SYSCONFDIR@/sysctl.d/*.conf; do
|
for conf in @SYSCONFDIR@/sysctl.conf @SYSCONFDIR@/sysctl.d/*.conf; do
|
||||||
if [ -r "$conf" ]; then
|
if [ -r "$conf" ]; then
|
||||||
vebegin "applying $conf"
|
vebegin "applying $conf"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
MAN3= \
|
MAN3= einfo.3 \
|
||||||
rc_config.3 rc_deptree.3 rc_find_pids.3 rc_plugin_hook.3 \
|
rc_config.3 rc_deptree.3 rc_find_pids.3 rc_plugin_hook.3 \
|
||||||
rc_runlevel.3 rc_service.3 rc_stringlist.3
|
rc_runlevel.3 rc_service.3 rc_stringlist.3
|
||||||
MAN8= rc-service.8 rc-status.8 rc-update.8 rc.8 runscript.8 \
|
MAN8= rc-service.8 rc-status.8 rc-update.8 rc.8 runscript.8 \
|
||||||
|
|||||||
203
man/einfo.3
Normal file
203
man/einfo.3
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
.\" Copyright (c) 2007-2008 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 Mar 16, 2008
|
||||||
|
.Dt EINFO 3 SMM
|
||||||
|
.Os OpenRC
|
||||||
|
.Sh NAME
|
||||||
|
.Nm einfo , ewarn , eerror , ebegin ,
|
||||||
|
.Nm einfon , ewarnn , eerrorn , ebeginn ,
|
||||||
|
.Nm einfov , ewarnv , ebeginv ,
|
||||||
|
.Nm einfovn , ewarnvn , ebeginvn ,
|
||||||
|
.Nm ewarnx , eerrorx ,
|
||||||
|
.Nm eend , ewend ,
|
||||||
|
.Nm eendv , ewendv ,
|
||||||
|
.Nm ebracket ,
|
||||||
|
.Nm eindent , eoutdent ,
|
||||||
|
.Nm eindentv , eoutdentv ,
|
||||||
|
.Nm eprefix
|
||||||
|
.Nd colorful informational output
|
||||||
|
.Sh LIBRARY
|
||||||
|
Enhanced Information output library (libeinfo, -leinfo)
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In einfo.h
|
||||||
|
.Ft int Fn einfo "const char * restrict format" ...
|
||||||
|
.Ft int Fn ewarn "const char * restrict format" ...
|
||||||
|
.Ft int Fn eerror "const char * restrict format" ...
|
||||||
|
.Ft int Fn ebegin "const char * restrict format" ...
|
||||||
|
.Ft int Fn einfon "const char * restrict format" ...
|
||||||
|
.Ft int Fn ewarnn "const char * restrict format" ...
|
||||||
|
.Ft int Fn eerrorn "const char * restrict format" ...
|
||||||
|
.Ft int Fn ebeginn "const char * restrict format" ...
|
||||||
|
.Ft int Fn einfov "const char * restrict format" ...
|
||||||
|
.Ft int Fn ewarnv "const char * restrict format" ...
|
||||||
|
.Ft int Fn ebeginv "const char * restrict format" ...
|
||||||
|
.Ft int Fn einfovn "const char * restrict format" ...
|
||||||
|
.Ft int Fn ewarnvn "const char * restrict format" ...
|
||||||
|
.Ft int Fn ebeginvn "const char * restrict format" ...
|
||||||
|
.Ft int Fn ewarnx "const char * restrict format" ...
|
||||||
|
.Ft int Fn eerrorx "const char * restrict format" ...
|
||||||
|
.Ft int Fn eend "int retval" "const char * restrict format" ...
|
||||||
|
.Ft int Fn ewend "int retval" "const char * restrict format" ...
|
||||||
|
.Ft int Fn eendv "int retval" "const char * restrict format" ...
|
||||||
|
.Ft int Fn ewendv "int retval" "const char * restrict format" ...
|
||||||
|
.Ft void Fn ebracket "int col" "ECOLOR color" "const char * restrict msg"
|
||||||
|
.Ft void Fn eindent void
|
||||||
|
.Ft void Fn eoutdent void
|
||||||
|
.Ft void Fn eindentv void
|
||||||
|
.Ft void Fn eoutdentv void
|
||||||
|
.Ft void Fn eprefix "const char * prefix"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Fn einfo
|
||||||
|
family of functions provide a simple informational output that is colorised.
|
||||||
|
Basically
|
||||||
|
.Fn einfo ,
|
||||||
|
.Fn ewarn
|
||||||
|
and
|
||||||
|
.Fn eerror
|
||||||
|
behave exactly like
|
||||||
|
.Fn printf
|
||||||
|
but prefix the output with a colored *. The function called denotes the color
|
||||||
|
used with
|
||||||
|
.Fn einfo
|
||||||
|
being green,
|
||||||
|
.Fn ewarn
|
||||||
|
being yellow and
|
||||||
|
.Fn eerror
|
||||||
|
being red.
|
||||||
|
einfo goes to stdout and the others go to stderr.
|
||||||
|
The number of real characters printed is returned.
|
||||||
|
.Fn ebegin
|
||||||
|
is identical to
|
||||||
|
.Fn einfo
|
||||||
|
except that 3 dots are appended to the output.
|
||||||
|
.Pp
|
||||||
|
.Fn einfov ,
|
||||||
|
.Fn ewarnv
|
||||||
|
and
|
||||||
|
.Fn ebeginv
|
||||||
|
work the same way to
|
||||||
|
.Fn einfo ,
|
||||||
|
.Fn ewarn ,
|
||||||
|
and
|
||||||
|
.Fn ebegin
|
||||||
|
respectively, but only work when
|
||||||
|
.Va EINFO_VERBOSE
|
||||||
|
is true. You can also make the
|
||||||
|
.Fn einfo
|
||||||
|
and
|
||||||
|
.Fn ebegin
|
||||||
|
functions silent by setting
|
||||||
|
.Va EINFO_QUIET
|
||||||
|
to true.
|
||||||
|
.Pp
|
||||||
|
These functions are designed to output a whole line, so they also
|
||||||
|
append a newline to the string. To stop this behaviour, you can use the
|
||||||
|
functions
|
||||||
|
.Fn einfon ,
|
||||||
|
.Fn ewarnn ,
|
||||||
|
.Fn eerrorn ,
|
||||||
|
.Fn einfovn ,
|
||||||
|
.Fn ewarnvn ,
|
||||||
|
and
|
||||||
|
.Fn ebeginvn .
|
||||||
|
.Pp
|
||||||
|
.Fn eend ,
|
||||||
|
.Fn ewend ,
|
||||||
|
.Fn eendv
|
||||||
|
and
|
||||||
|
.Fn ewendv
|
||||||
|
are the counterparts to the above functions. If
|
||||||
|
.Fa retval
|
||||||
|
is zero then ok in green is printed in a bracket at the end of the prior
|
||||||
|
line. Otherwise we print the formatted string using
|
||||||
|
.Fn error
|
||||||
|
(or
|
||||||
|
.Fn ewarn
|
||||||
|
if
|
||||||
|
.Fn ewend
|
||||||
|
is called) !! in red (or yellow if
|
||||||
|
.Fn ewend
|
||||||
|
is called) is printed in a bracket at the end of the line.
|
||||||
|
The value of
|
||||||
|
.Fa retval
|
||||||
|
is returned.
|
||||||
|
.Pp
|
||||||
|
.Fn ebracket
|
||||||
|
does the same as
|
||||||
|
.Fn eend
|
||||||
|
but prints
|
||||||
|
.Fa msg
|
||||||
|
instead of ok or !! in the color
|
||||||
|
.Fa color
|
||||||
|
at the column
|
||||||
|
.Fa col .
|
||||||
|
.Pp
|
||||||
|
.Fn eindent
|
||||||
|
indents subsequent calls to the above functions by 3 characters.
|
||||||
|
.Fn eoutdent
|
||||||
|
removes an
|
||||||
|
.Fn eindent .
|
||||||
|
.Fn eindentv
|
||||||
|
and
|
||||||
|
.Fn eoutdentv
|
||||||
|
only work when
|
||||||
|
.Va EINFO_VERBOSE
|
||||||
|
is true.
|
||||||
|
.Pp
|
||||||
|
.Fn eprefix
|
||||||
|
prefixes the string
|
||||||
|
.Fa prefix
|
||||||
|
to the above functions.
|
||||||
|
.Sh IMPLEMENTATION NOTES
|
||||||
|
einfo can optionally be linked against the
|
||||||
|
.Lb libtermcap
|
||||||
|
so that we can correctly query the connected console for our color and
|
||||||
|
cursor escape codes.
|
||||||
|
If not, then we have a hard coded list of terminals we know about that support
|
||||||
|
the commonly used codes for color and cursor position.
|
||||||
|
.Sh ENVIRONMENT
|
||||||
|
.Va EINFO_QUIET
|
||||||
|
when set to true makes the
|
||||||
|
.Fn einfo
|
||||||
|
and
|
||||||
|
.Fn einfon
|
||||||
|
family of functions quiet, so nothing is printed.
|
||||||
|
.Pp
|
||||||
|
.Va EINFO_VERBOSE
|
||||||
|
when set to true makes the
|
||||||
|
.Fn einfov
|
||||||
|
and
|
||||||
|
.Fn einfovn
|
||||||
|
family of functions work, so they do print.
|
||||||
|
.Sh FILES
|
||||||
|
.Pa /etc/init.d/functions.sh
|
||||||
|
is provided by OpenRC, which allows shell scripts to use the above functions.
|
||||||
|
For historical reasons our verbose functions are prefixed with v instead of
|
||||||
|
suffixed. So einfov becomes veinfo, einfovn becomes veinfon.
|
||||||
|
Rinse and repeat for the other verbose functions.
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr printf 3 ,
|
||||||
|
.Sh AUTHORS
|
||||||
|
.An Roy Marples <roy@marples.name>
|
||||||
@@ -60,12 +60,12 @@ 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,
|
services that need us fail to stop then we exit with a suitable error,
|
||||||
otherwise call the supplied stop function if it exists.
|
otherwise call the supplied stop function if it exists.
|
||||||
.It Ar restart
|
.It Ar restart
|
||||||
Stops and starts the service, including dependencies. This cannot be
|
Stop and start the service, including dependencies. This cannot be
|
||||||
overridden. See the description of the RC_CMD variable below for the
|
overridden. See the description of the RC_CMD variable below for the
|
||||||
method to make your service behave differently when restart is being
|
method to make your service behave differently when restart is being
|
||||||
executed.
|
executed.
|
||||||
.It Ar status
|
.It Ar status
|
||||||
Shows the status of the service. The return code matches the status, with the
|
Show the status of the service. The return code matches the status, with the
|
||||||
exception of "started" returning 0 to match standard command behaviour.
|
exception of "started" returning 0 to match standard command behaviour.
|
||||||
.It Ar zap
|
.It Ar zap
|
||||||
Resets the service state to stopped and removes all saved data about the
|
Resets the service state to stopped and removes all saved data about the
|
||||||
@@ -88,8 +88,8 @@ Output from any non OpenRC commands is not affected.
|
|||||||
.It Fl v , -verbose
|
.It Fl v , -verbose
|
||||||
Turns on any extra informational output the service generates.
|
Turns on any extra informational output the service generates.
|
||||||
.It Fl Z , -dry-run
|
.It Fl Z , -dry-run
|
||||||
Shows which services would be stopped and/or started without actually stopping
|
Shows what services would be stopped and/or started without actually starting
|
||||||
or starting them.
|
or stopping them.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The following variables affect the service script:
|
The following variables affect the service script:
|
||||||
@@ -471,7 +471,7 @@ start_pre()
|
|||||||
# stop_post.
|
# stop_post.
|
||||||
fi
|
fi
|
||||||
# Ensure that our dirs are correct
|
# Ensure that our dirs are correct
|
||||||
checkpath --directory --owner foo:foo --mode 0775 \\
|
checkpath --dir --owner foo:foo --mode 0664 \\
|
||||||
/var/run/foo /var/cache/foo
|
/var/run/foo /var/cache/foo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
mk/os-GNU-kFreeBSD.mk
Normal file
9
mk/os-GNU-kFreeBSD.mk
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2008 Roy Marples <roy@marples.name>
|
||||||
|
# Released under the 2-clause BSD license.
|
||||||
|
|
||||||
|
# Generic definitions
|
||||||
|
|
||||||
|
CPPFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=700
|
||||||
|
LIBDL= -Wl,-Bdynamic -ldl
|
||||||
|
LIBKVM?=
|
||||||
|
include ${MK}/os-BSD.mk
|
||||||
2
mk/os.mk
2
mk/os.mk
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
# Generic definitions
|
# Generic definitions
|
||||||
|
|
||||||
_OS_SH= uname -s
|
_OS_SH= uname -s | tr '/' '-'
|
||||||
_OS:= $(shell ${_OS_SH})
|
_OS:= $(shell ${_OS_SH})
|
||||||
OS?= ${_OS}
|
OS?= ${_OS}
|
||||||
include ${MK}/os-${OS}.mk
|
include ${MK}/os-${OS}.mk
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
DIR= ${LIBDIR}/pkgconfig
|
DIR= ${LIBDIR}/pkgconfig
|
||||||
SRCS= openrc.pc.in
|
SRCS= einfo.pc.in openrc.pc.in
|
||||||
INC= openrc.pc
|
INC= einfo.pc openrc.pc
|
||||||
|
|
||||||
.DEFAULT:
|
.DEFAULT:
|
||||||
${SED} -n -e 's/^VERSION=[[:space:]]*\([^[:space:]]*\).*/#define VERSION "\1${GITVER}\"/p' ../../Makefile > version.h
|
${SED} -n -e 's/^VERSION=[[:space:]]*\([^[:space:]]*\).*/#define VERSION "\1${GITVER}\"/p' ../../Makefile > version.h
|
||||||
|
|||||||
9
pkgconfig/einfo.pc.in
Normal file
9
pkgconfig/einfo.pc.in
Normal 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
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
include ../mk/net.mk
|
include ../mk/net.mk
|
||||||
|
|
||||||
BOOT= bootmisc fsck hostname localmount \
|
BOOT= bootmisc fsck hostname localmount loopback \
|
||||||
root swap swapfiles sysctl urandom ${BOOT-${OS}}
|
root swap swapfiles sysctl urandom ${BOOT-${OS}}
|
||||||
DEFAULT= local netmount
|
DEFAULT= local netmount
|
||||||
SHUTDOWN= savecache ${SHUTDOWN-${OS}}
|
SHUTDOWN= savecache ${SHUTDOWN-${OS}}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
||||||
# Released under the 2-clause BSD license.
|
# Released under the 2-clause BSD license.
|
||||||
|
|
||||||
SUBDIR= test librc rc
|
SUBDIR= test libeinfo librc rc
|
||||||
|
|
||||||
ifeq (${MKTOOLS},yes)
|
ifeq (${MKTOOLS},yes)
|
||||||
SUBDIR+= tools
|
SUBDIR+= tools
|
||||||
|
|||||||
1
src/libeinfo/.gitignore
vendored
Normal file
1
src/libeinfo/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
libeinfo.so.1
|
||||||
12
src/libeinfo/Makefile
Normal file
12
src/libeinfo/Makefile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
LIB= einfo
|
||||||
|
SHLIB_MAJOR= 1
|
||||||
|
SRCS= libeinfo.c
|
||||||
|
INCS= einfo.h
|
||||||
|
VERSION_MAP= einfo.map
|
||||||
|
|
||||||
|
CPPFLAGS+= -I../includes
|
||||||
|
|
||||||
|
MK= ../../mk
|
||||||
|
include ${MK}/lib.mk
|
||||||
|
include ${MK}/cc.mk
|
||||||
|
include ${MK}/termcap.mk
|
||||||
@@ -37,6 +37,19 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/* Although OpenRC requires C99, linking to us should not. */
|
||||||
|
#ifdef restrict
|
||||||
|
# define EINFO_RESTRICT restrict
|
||||||
|
#else
|
||||||
|
# ifdef __restrict
|
||||||
|
# define EINFO_RESTRICT __restrict
|
||||||
|
# else
|
||||||
|
# define EINFO_RESTRICT
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
|
||||||
/*! @brief Color types to use */
|
/*! @brief Color types to use */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@@ -52,14 +65,14 @@ typedef enum
|
|||||||
const char *ecolor(ECOLOR);
|
const char *ecolor(ECOLOR);
|
||||||
|
|
||||||
/*! @brief Writes to syslog. */
|
/*! @brief Writes to syslog. */
|
||||||
void elog(int, const char *, ...) EINFO_PRINTF(2, 3);
|
void elog(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Display informational messages.
|
* @brief Display informational messages.
|
||||||
*
|
*
|
||||||
* The einfo family of functions display messages in a consistent manner
|
* The einfo family of functions display messages in a consistent manner
|
||||||
* Basically they prefix the message with " * ".
|
* across applications. Basically they prefix the message with
|
||||||
* If the terminal can handle color then we color the * based on
|
* " * ". If the terminal can handle color then we color the * based on
|
||||||
* the command used. Otherwise we are identical to the printf function.
|
* the command used. Otherwise we are identical to the printf function.
|
||||||
*
|
*
|
||||||
* - einfo - green
|
* - einfo - green
|
||||||
@@ -70,22 +83,22 @@ void elog(int, const char *, ...) EINFO_PRINTF(2, 3);
|
|||||||
* The v suffix means only print if EINFO_VERBOSE is yes.
|
* The v suffix means only print if EINFO_VERBOSE is yes.
|
||||||
*/
|
*/
|
||||||
/*@{*/
|
/*@{*/
|
||||||
int einfon(const char *, ...) EINFO_PRINTF(1, 2);
|
int einfon(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ewarnn(const char *, ...) EINFO_PRINTF(1, 2);
|
int ewarnn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int eerrorn(const char *, ...) EINFO_PRINTF(1, 2);
|
int eerrorn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int einfo(const char *, ...) EINFO_PRINTF(1, 2);
|
int einfo(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ewarn(const char *, ...) EINFO_PRINTF(1, 2);
|
int ewarn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
void ewarnx(const char *, ...) EINFO_XPRINTF(1, 2);
|
void ewarnx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
|
||||||
int eerror(const char *, ...) EINFO_PRINTF(1, 2);
|
int eerror(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
void eerrorx(const char *, ...) EINFO_XPRINTF(1, 2);
|
void eerrorx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
|
||||||
|
|
||||||
int einfovn(const char *, ...) EINFO_PRINTF(1, 2);
|
int einfovn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ewarnvn(const char * , ...) EINFO_PRINTF(1, 2);
|
int ewarnvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ebeginvn(const char *, ...) EINFO_PRINTF(1, 2);
|
int ebeginvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int eendvn(int, const char *, ...) EINFO_PRINTF(2, 3);
|
int eendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
||||||
int ewendvn(int, const char *, ...) EINFO_PRINTF(2, 3);
|
int ewendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
||||||
int einfov(const char *, ...) EINFO_PRINTF(1, 2);
|
int einfov(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ewarnv(const char *, ...) EINFO_PRINTF(1, 2);
|
int ewarnv(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/*! @ingroup ebegin
|
/*! @ingroup ebegin
|
||||||
@@ -93,8 +106,8 @@ int ewarnv(const char *, ...) EINFO_PRINTF(1, 2);
|
|||||||
*
|
*
|
||||||
* Similar to einfo, but we add ... to the end of the message */
|
* Similar to einfo, but we add ... to the end of the message */
|
||||||
/*@{*/
|
/*@{*/
|
||||||
int ebeginv(const char *, ...) EINFO_PRINTF(1, 2);
|
int ebeginv(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ebegin(const char *, ...) EINFO_PRINTF(1, 2);
|
int ebegin(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/*! @ingroup eend
|
/*! @ingroup eend
|
||||||
@@ -106,12 +119,12 @@ int ebegin(const char *, ...) EINFO_PRINTF(1, 2);
|
|||||||
*
|
*
|
||||||
* ebracket allows you to specifiy the position, color and message */
|
* ebracket allows you to specifiy the position, color and message */
|
||||||
/*@{*/
|
/*@{*/
|
||||||
int eend(int, const char *, ...) EINFO_PRINTF(2, 3);
|
int eend(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
||||||
int ewend(int, const char *, ...) EINFO_PRINTF(2, 3);
|
int ewend(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
||||||
void ebracket(int, ECOLOR, const char *);
|
void ebracket(int, ECOLOR, const char * EINFO_RESTRICT);
|
||||||
|
|
||||||
int eendv(int, const char *, ...) EINFO_PRINTF(2, 3);
|
int eendv(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
||||||
int ewendv(int, const char *, ...) EINFO_PRINTF(2, 3);
|
int ewendv(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/*! @ingroup eindent
|
/*! @ingroup eindent
|
||||||
@@ -125,6 +138,7 @@ void eindentv(void);
|
|||||||
void eoutdentv(void);
|
void eoutdentv(void);
|
||||||
|
|
||||||
/*! @brief Prefix each einfo line with something */
|
/*! @brief Prefix each einfo line with something */
|
||||||
void eprefix(const char *);
|
void eprefix(const char * EINFO_RESTRICT);
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
#endif
|
#endif
|
||||||
35
src/libeinfo/einfo.map
Normal file
35
src/libeinfo/einfo.map
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
EINFO_1.0 {
|
||||||
|
global:
|
||||||
|
ecolor;
|
||||||
|
elog;
|
||||||
|
einfon;
|
||||||
|
ewarnn;
|
||||||
|
eerrorn;
|
||||||
|
einfo;
|
||||||
|
ewarn;
|
||||||
|
ewarnx;
|
||||||
|
eerror;
|
||||||
|
eerrorx;
|
||||||
|
einfovn;
|
||||||
|
ewarnvn;
|
||||||
|
ebeginvn;
|
||||||
|
eendvn;
|
||||||
|
ewendvn;
|
||||||
|
einfov;
|
||||||
|
ewarnv;
|
||||||
|
ebeginv;
|
||||||
|
ebegin;
|
||||||
|
eend;
|
||||||
|
ewend;
|
||||||
|
ebracket;
|
||||||
|
eendv;
|
||||||
|
ewendv;
|
||||||
|
eindent;
|
||||||
|
eoutdent;
|
||||||
|
eindentv;
|
||||||
|
eoutdentv;
|
||||||
|
eprefix;
|
||||||
|
|
||||||
|
local:
|
||||||
|
*;
|
||||||
|
};
|
||||||
@@ -52,6 +52,34 @@ const char libeinfo_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
|
|||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
#include "hidden-visibility.h"
|
||||||
|
|
||||||
|
hidden_proto(ecolor)
|
||||||
|
hidden_proto(ebegin)
|
||||||
|
hidden_proto(ebeginv)
|
||||||
|
hidden_proto(ebracket)
|
||||||
|
hidden_proto(eend)
|
||||||
|
hidden_proto(eendv)
|
||||||
|
hidden_proto(eerror)
|
||||||
|
hidden_proto(eerrorn)
|
||||||
|
hidden_proto(eerrorx)
|
||||||
|
hidden_proto(eindent)
|
||||||
|
hidden_proto(eindentv)
|
||||||
|
hidden_proto(einfo)
|
||||||
|
hidden_proto(einfon)
|
||||||
|
hidden_proto(einfov)
|
||||||
|
hidden_proto(einfovn)
|
||||||
|
hidden_proto(elog)
|
||||||
|
hidden_proto(eoutdent)
|
||||||
|
hidden_proto(eoutdentv)
|
||||||
|
hidden_proto(eprefix)
|
||||||
|
hidden_proto(ewarn)
|
||||||
|
hidden_proto(ewarnn)
|
||||||
|
hidden_proto(ewarnv)
|
||||||
|
hidden_proto(ewarnvn)
|
||||||
|
hidden_proto(ewarnx)
|
||||||
|
hidden_proto(ewend)
|
||||||
|
hidden_proto(ewendv)
|
||||||
|
|
||||||
/* Incase we cannot work out how many columns from ioctl, supply a default */
|
/* Incase we cannot work out how many columns from ioctl, supply a default */
|
||||||
#define DEFAULT_COLS 80
|
#define DEFAULT_COLS 80
|
||||||
@@ -245,12 +273,6 @@ is_quiet(void)
|
|||||||
return yesno(getenv("EINFO_QUIET"));
|
return yesno(getenv("EINFO_QUIET"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
is_really_quiet(void)
|
|
||||||
{
|
|
||||||
return yesno(getenv("EERROR_QUIET"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
is_verbose(void)
|
is_verbose(void)
|
||||||
{
|
{
|
||||||
@@ -324,7 +346,7 @@ tgoto(const char *cap, int col, int line)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
colour_terminal(FILE *f)
|
colour_terminal(FILE * EINFO_RESTRICT f)
|
||||||
{
|
{
|
||||||
static int in_colour = -1;
|
static int in_colour = -1;
|
||||||
char *e, *ee, *end, *d, *p;
|
char *e, *ee, *end, *d, *p;
|
||||||
@@ -471,7 +493,7 @@ colour_terminal(FILE *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_term_columns(FILE *stream)
|
get_term_columns(FILE * EINFO_RESTRICT stream)
|
||||||
{
|
{
|
||||||
struct winsize ws;
|
struct winsize ws;
|
||||||
char *env = getenv("COLUMNS");
|
char *env = getenv("COLUMNS");
|
||||||
@@ -491,13 +513,14 @@ get_term_columns(FILE *stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eprefix(const char *prefix)
|
eprefix(const char *EINFO_RESTRICT prefix)
|
||||||
{
|
{
|
||||||
_eprefix = prefix;
|
_eprefix = prefix;
|
||||||
}
|
}
|
||||||
|
hidden_def(eprefix)
|
||||||
|
|
||||||
static void EINFO_PRINTF(2, 0)
|
static void EINFO_PRINTF(2, 0)
|
||||||
elogv(int level, const char *fmt, va_list ap)
|
elogv(int level, const char *EINFO_RESTRICT fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char *e = getenv("EINFO_LOG");
|
char *e = getenv("EINFO_LOG");
|
||||||
va_list apc;
|
va_list apc;
|
||||||
@@ -513,7 +536,7 @@ elogv(int level, const char *fmt, va_list ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
elog(int level, const char *fmt, ...)
|
elog(int level, const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -521,9 +544,10 @@ elog(int level, const char *fmt, ...)
|
|||||||
elogv(level, fmt, ap);
|
elogv(level, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
hidden_def(elog)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_eindent(FILE *stream)
|
_eindent(FILE * EINFO_RESTRICT stream)
|
||||||
{
|
{
|
||||||
char *env = getenv("EINFO_INDENT");
|
char *env = getenv("EINFO_INDENT");
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
@@ -547,7 +571,7 @@ _eindent(FILE *stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
_ecolor(FILE *f, ECOLOR color)
|
_ecolor(FILE * EINFO_RESTRICT f, ECOLOR color)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@@ -559,6 +583,7 @@ _ecolor(FILE *f, ECOLOR color)
|
|||||||
return ecolors_str[i];
|
return ecolors_str[i];
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
hidden_def(ecolor)
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
ecolor(ECOLOR color)
|
ecolor(ECOLOR color)
|
||||||
@@ -584,7 +609,7 @@ ecolor(ECOLOR color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int EINFO_PRINTF(3, 0)
|
static int EINFO_PRINTF(3, 0)
|
||||||
_einfo(FILE *f, ECOLOR color, const char *fmt, va_list va)
|
_einfo(FILE *f, ECOLOR color, const char *EINFO_RESTRICT fmt, va_list va)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
char *last = getenv("EINFO_LASTCMD");
|
char *last = getenv("EINFO_LASTCMD");
|
||||||
@@ -612,7 +637,7 @@ static int EINFO_PRINTF(3, 0)
|
|||||||
#define _eerrorvn(fmt, ap) _einfo(stderr, ECOLOR_BAD, fmt, ap)
|
#define _eerrorvn(fmt, ap) _einfo(stderr, ECOLOR_BAD, fmt, ap)
|
||||||
|
|
||||||
int
|
int
|
||||||
einfon(const char *fmt, ...)
|
einfon(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -625,9 +650,10 @@ einfon(const char *fmt, ...)
|
|||||||
LASTCMD("einfon");
|
LASTCMD("einfon");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(einfon)
|
||||||
|
|
||||||
int
|
int
|
||||||
ewarnn(const char *fmt, ...)
|
ewarnn(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -640,24 +666,24 @@ ewarnn(const char *fmt, ...)
|
|||||||
LASTCMD("ewarnn");
|
LASTCMD("ewarnn");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(ewarnn)
|
||||||
|
|
||||||
int
|
int
|
||||||
eerrorn(const char *fmt, ...)
|
eerrorn(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (!fmt || is_really_quiet())
|
|
||||||
return 0;
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
retval = _eerrorvn(fmt, ap);
|
retval = _eerrorvn(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
LASTCMD("errorn");
|
LASTCMD("errorn");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(eerrorn)
|
||||||
|
|
||||||
int
|
int
|
||||||
einfo(const char *fmt, ...)
|
einfo(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -671,14 +697,15 @@ einfo(const char *fmt, ...)
|
|||||||
LASTCMD("einfo");
|
LASTCMD("einfo");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(einfo)
|
||||||
|
|
||||||
int
|
int
|
||||||
ewarn(const char *fmt, ...)
|
ewarn(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (!fmt || is_quiet())
|
if (!fmt)
|
||||||
return 0;
|
return 0;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
elogv(LOG_WARNING, fmt, ap);
|
elogv(LOG_WARNING, fmt, ap);
|
||||||
@@ -688,9 +715,10 @@ ewarn(const char *fmt, ...)
|
|||||||
LASTCMD("ewarn");
|
LASTCMD("ewarn");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(ewarn)
|
||||||
|
|
||||||
void
|
void
|
||||||
ewarnx(const char *fmt, ...)
|
ewarnx(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -704,14 +732,15 @@ ewarnx(const char *fmt, ...)
|
|||||||
}
|
}
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
hidden_def(ewarnx)
|
||||||
|
|
||||||
int
|
int
|
||||||
eerror(const char *fmt, ...)
|
eerror(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (!fmt || is_really_quiet())
|
if (!fmt)
|
||||||
return 0;
|
return 0;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
elogv(LOG_ERR, fmt, ap);
|
elogv(LOG_ERR, fmt, ap);
|
||||||
@@ -721,13 +750,14 @@ eerror(const char *fmt, ...)
|
|||||||
LASTCMD("eerror");
|
LASTCMD("eerror");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(eerror)
|
||||||
|
|
||||||
void
|
void
|
||||||
eerrorx(const char *fmt, ...)
|
eerrorx(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (fmt && !is_really_quiet()) {
|
if (fmt) {
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
elogv(LOG_ERR, fmt, ap);
|
elogv(LOG_ERR, fmt, ap);
|
||||||
_eerrorvn(fmt, ap);
|
_eerrorvn(fmt, ap);
|
||||||
@@ -736,9 +766,10 @@ eerrorx(const char *fmt, ...)
|
|||||||
}
|
}
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
hidden_def(eerrorx)
|
||||||
|
|
||||||
int
|
int
|
||||||
ebegin(const char *fmt, ...)
|
ebegin(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -754,9 +785,10 @@ ebegin(const char *fmt, ...)
|
|||||||
LASTCMD("ebegin");
|
LASTCMD("ebegin");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(ebegin)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_eend(FILE *fp, int col, ECOLOR color, const char *msg)
|
_eend(FILE * EINFO_RESTRICT fp, int col, ECOLOR color, const char *msg)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int cols;
|
int cols;
|
||||||
@@ -792,7 +824,7 @@ _eend(FILE *fp, int col, ECOLOR color, const char *msg)
|
|||||||
|
|
||||||
static int EINFO_PRINTF(3, 0)
|
static int EINFO_PRINTF(3, 0)
|
||||||
_do_eend(const char *cmd, int retval,
|
_do_eend(const char *cmd, int retval,
|
||||||
const char *fmt, va_list ap)
|
const char *EINFO_RESTRICT fmt, va_list ap)
|
||||||
{
|
{
|
||||||
int col = 0;
|
int col = 0;
|
||||||
FILE *fp = stdout;
|
FILE *fp = stdout;
|
||||||
@@ -815,7 +847,7 @@ _do_eend(const char *cmd, int retval,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
eend(int retval, const char *fmt, ...)
|
eend(int retval, const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -827,9 +859,10 @@ eend(int retval, const char *fmt, ...)
|
|||||||
LASTCMD("eend");
|
LASTCMD("eend");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(eend)
|
||||||
|
|
||||||
int
|
int
|
||||||
ewend(int retval, const char *fmt, ...)
|
ewend(int retval, const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -841,12 +874,14 @@ ewend(int retval, const char *fmt, ...)
|
|||||||
LASTCMD("ewend");
|
LASTCMD("ewend");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(ewend)
|
||||||
|
|
||||||
void
|
void
|
||||||
ebracket(int col, ECOLOR color, const char *msg)
|
ebracket(int col, ECOLOR color, const char *msg)
|
||||||
{
|
{
|
||||||
_eend(stdout, col, color, msg);
|
_eend(stdout, col, color, msg);
|
||||||
}
|
}
|
||||||
|
hidden_def(ebracket)
|
||||||
|
|
||||||
void
|
void
|
||||||
eindent(void)
|
eindent(void)
|
||||||
@@ -867,6 +902,7 @@ eindent(void)
|
|||||||
snprintf(num, 10, "%08d", amount);
|
snprintf(num, 10, "%08d", amount);
|
||||||
setenv("EINFO_INDENT", num, 1);
|
setenv("EINFO_INDENT", num, 1);
|
||||||
}
|
}
|
||||||
|
hidden_def(eindent)
|
||||||
|
|
||||||
void eoutdent(void)
|
void eoutdent(void)
|
||||||
{
|
{
|
||||||
@@ -891,9 +927,10 @@ void eoutdent(void)
|
|||||||
}
|
}
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
}
|
}
|
||||||
|
hidden_def(eoutdent)
|
||||||
|
|
||||||
int
|
int
|
||||||
einfovn(const char *fmt, ...)
|
einfovn(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -906,9 +943,10 @@ einfovn(const char *fmt, ...)
|
|||||||
LASTCMD("einfovn");
|
LASTCMD("einfovn");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(einfovn)
|
||||||
|
|
||||||
int
|
int
|
||||||
ewarnvn(const char *fmt, ...)
|
ewarnvn(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -921,9 +959,10 @@ ewarnvn(const char *fmt, ...)
|
|||||||
LASTCMD("ewarnvn");
|
LASTCMD("ewarnvn");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(ewarnvn)
|
||||||
|
|
||||||
int
|
int
|
||||||
einfov(const char *fmt, ...)
|
einfov(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -937,9 +976,10 @@ einfov(const char *fmt, ...)
|
|||||||
LASTCMD("einfov");
|
LASTCMD("einfov");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(einfov)
|
||||||
|
|
||||||
int
|
int
|
||||||
ewarnv(const char *fmt, ...)
|
ewarnv(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -953,9 +993,10 @@ ewarnv(const char *fmt, ...)
|
|||||||
LASTCMD("ewarnv");
|
LASTCMD("ewarnv");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(ewarnv)
|
||||||
|
|
||||||
int
|
int
|
||||||
ebeginv(const char *fmt, ...)
|
ebeginv(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -972,9 +1013,10 @@ ebeginv(const char *fmt, ...)
|
|||||||
LASTCMD("ebeginv");
|
LASTCMD("ebeginv");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(ebeginv)
|
||||||
|
|
||||||
int
|
int
|
||||||
eendv(int retval, const char *fmt, ...)
|
eendv(int retval, const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -986,9 +1028,10 @@ eendv(int retval, const char *fmt, ...)
|
|||||||
LASTCMD("eendv");
|
LASTCMD("eendv");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(eendv)
|
||||||
|
|
||||||
int
|
int
|
||||||
ewendv(int retval, const char *fmt, ...)
|
ewendv(int retval, const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -1000,6 +1043,7 @@ ewendv(int retval, const char *fmt, ...)
|
|||||||
LASTCMD("ewendv");
|
LASTCMD("ewendv");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
hidden_def(ewendv)
|
||||||
|
|
||||||
void
|
void
|
||||||
eindentv(void)
|
eindentv(void)
|
||||||
@@ -1007,6 +1051,7 @@ eindentv(void)
|
|||||||
if (is_verbose())
|
if (is_verbose())
|
||||||
eindent();
|
eindent();
|
||||||
}
|
}
|
||||||
|
hidden_def(eindentv)
|
||||||
|
|
||||||
void
|
void
|
||||||
eoutdentv(void)
|
eoutdentv(void)
|
||||||
@@ -1014,3 +1059,4 @@ eoutdentv(void)
|
|||||||
if (is_verbose())
|
if (is_verbose())
|
||||||
eoutdent();
|
eoutdent();
|
||||||
}
|
}
|
||||||
|
hidden_def(eoutdentv)
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "librc.h"
|
#include "librc.h"
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__) || defined (__GLIBC__)
|
||||||
static bool
|
static bool
|
||||||
pid_is_exec(pid_t pid, const char *exec)
|
pid_is_exec(pid_t pid, const char *exec)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -323,42 +323,6 @@ rc_parse_service_state(RC_SERVICE state)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns a list of all the chained runlevels used by the
|
|
||||||
* specified runlevel in dependency order, including the
|
|
||||||
* specified runlevel. */
|
|
||||||
static void
|
|
||||||
get_runlevel_chain(const char *runlevel, RC_STRINGLIST *level_list)
|
|
||||||
{
|
|
||||||
char path[PATH_MAX];
|
|
||||||
RC_STRINGLIST *dirs;
|
|
||||||
RC_STRING *d, *dn;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we haven't been passed a runlevel or a level list, or
|
|
||||||
* if the passed runlevel doesn't exist then we're done already!
|
|
||||||
*/
|
|
||||||
if (!runlevel || !level_list || !rc_runlevel_exists(runlevel))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We want to add this runlevel to the list but if
|
|
||||||
* it is already in the list it needs to go at the
|
|
||||||
* end again.
|
|
||||||
*/
|
|
||||||
if (rc_stringlist_find(level_list, runlevel))
|
|
||||||
rc_stringlist_delete(level_list, runlevel);
|
|
||||||
rc_stringlist_add(level_list, runlevel);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We can now do exactly the above procedure for our chained
|
|
||||||
* runlevels.
|
|
||||||
*/
|
|
||||||
snprintf(path, sizeof(path), "%s/%s", RC_RUNLEVELDIR, runlevel);
|
|
||||||
dirs = ls_dir(path, LS_DIR);
|
|
||||||
TAILQ_FOREACH_SAFE(d, dirs, entries, dn)
|
|
||||||
get_runlevel_chain(d->value, level_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
rc_runlevel_starting(void)
|
rc_runlevel_starting(void)
|
||||||
{
|
{
|
||||||
@@ -460,10 +424,22 @@ librc_hidden_def(rc_runlevel_unstack)
|
|||||||
RC_STRINGLIST *
|
RC_STRINGLIST *
|
||||||
rc_runlevel_stacks(const char *runlevel)
|
rc_runlevel_stacks(const char *runlevel)
|
||||||
{
|
{
|
||||||
RC_STRINGLIST *stack;
|
char path[PATH_MAX];
|
||||||
stack = rc_stringlist_new();
|
RC_STRINGLIST *dirs;
|
||||||
get_runlevel_chain(runlevel, stack);
|
RC_STRING *d, *dn;
|
||||||
return stack;
|
|
||||||
|
if (!runlevel)
|
||||||
|
return false;
|
||||||
|
snprintf(path, sizeof(path), "%s/%s", RC_RUNLEVELDIR, runlevel);
|
||||||
|
dirs = ls_dir(path, LS_DIR);
|
||||||
|
TAILQ_FOREACH_SAFE(d, dirs, entries, dn) {
|
||||||
|
if (!rc_runlevel_exists(d->value)) {
|
||||||
|
TAILQ_REMOVE(dirs, d, entries);
|
||||||
|
free(d->value);
|
||||||
|
free(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dirs;
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_runlevel_stacks)
|
librc_hidden_def(rc_runlevel_stacks)
|
||||||
|
|
||||||
@@ -927,13 +903,17 @@ rc_services_in_runlevel_stacked(const char *runlevel)
|
|||||||
stacks = rc_runlevel_stacks(runlevel);
|
stacks = rc_runlevel_stacks(runlevel);
|
||||||
TAILQ_FOREACH(stack, stacks, entries) {
|
TAILQ_FOREACH(stack, stacks, entries) {
|
||||||
sl = rc_services_in_runlevel(stack->value);
|
sl = rc_services_in_runlevel(stack->value);
|
||||||
|
if (list != NULL) {
|
||||||
TAILQ_CONCAT(list, sl, entries);
|
TAILQ_CONCAT(list, sl, entries);
|
||||||
free(sl);
|
free(sl);
|
||||||
|
} else
|
||||||
|
list = sl;
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
librc_hidden_def(rc_services_in_runlevel_stacked)
|
librc_hidden_def(rc_services_in_runlevel_stacked)
|
||||||
|
|
||||||
|
|
||||||
RC_STRINGLIST *
|
RC_STRINGLIST *
|
||||||
rc_services_in_state(RC_SERVICE state)
|
rc_services_in_state(RC_SERVICE state)
|
||||||
{
|
{
|
||||||
|
|||||||
1
src/rc/.gitignore
vendored
1
src/rc/.gitignore
vendored
@@ -3,7 +3,6 @@ rc-status
|
|||||||
rc-service
|
rc-service
|
||||||
rc-update
|
rc-update
|
||||||
runscript
|
runscript
|
||||||
service
|
|
||||||
start-stop-daemon
|
start-stop-daemon
|
||||||
einfon
|
einfon
|
||||||
einfo
|
einfo
|
||||||
|
|||||||
@@ -1,21 +1,8 @@
|
|||||||
PROG= rc
|
PROG= rc
|
||||||
SRCS= \
|
SRCS= checkpath.c fstabinfo.c mountinfo.c start-stop-daemon.c \
|
||||||
checkpath.c \
|
rc-applets.c rc-depend.c rc-logger.c \
|
||||||
einfo.c \
|
rc-misc.c rc-plugin.c rc-service.c rc-status.c rc-update.c \
|
||||||
fstabinfo.c \
|
runscript.c rc.c swclock.c
|
||||||
mountinfo.c \
|
|
||||||
rc-applets.c \
|
|
||||||
rc-depend.c \
|
|
||||||
rc-logger.c \
|
|
||||||
rc-misc.c \
|
|
||||||
rc-plugin.c \
|
|
||||||
rc-service.c \
|
|
||||||
rc-status.c \
|
|
||||||
rc-update.c \
|
|
||||||
rc.c \
|
|
||||||
runscript.c \
|
|
||||||
start-stop-daemon.c \
|
|
||||||
swclock.c
|
|
||||||
|
|
||||||
CLEANFILES= version.h
|
CLEANFILES= version.h
|
||||||
|
|
||||||
@@ -43,9 +30,9 @@ RC_SBINLINKS= mark_service_starting mark_service_started \
|
|||||||
ALL_LINKS= ${BINLINKS} ${SBINLINKS} ${RC_BINLINKS} ${RC_SBINLINKS}
|
ALL_LINKS= ${BINLINKS} ${SBINLINKS} ${RC_BINLINKS} ${RC_SBINLINKS}
|
||||||
CLEANFILES+= ${ALL_LINKS}
|
CLEANFILES+= ${ALL_LINKS}
|
||||||
|
|
||||||
CPPFLAGS+= -I../includes -I../librc
|
CPPFLAGS+= -I../includes -I../librc -I../libeinfo
|
||||||
LDFLAGS+= -L../librc
|
LDFLAGS+= -L../librc -L../libeinfo
|
||||||
LDADD+= -lutil -lrc
|
LDADD+= -lutil -lrc -leinfo
|
||||||
|
|
||||||
include ../../Makefile.inc
|
include ../../Makefile.inc
|
||||||
MK= ../../mk
|
MK= ../../mk
|
||||||
|
|||||||
@@ -35,21 +35,6 @@
|
|||||||
# define _noreturn
|
# define _noreturn
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void set_quiet_options(void)
|
|
||||||
{
|
|
||||||
static int qcount = 0;
|
|
||||||
|
|
||||||
qcount ++;
|
|
||||||
switch (qcount) {
|
|
||||||
case 1:
|
|
||||||
setenv ("EINFO_QUIET", "YES", 1);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
setenv ("EERROR_QUIET", "YES", 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_noreturn static void
|
_noreturn static void
|
||||||
show_version(void)
|
show_version(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,13 +38,13 @@
|
|||||||
"Disable color output", \
|
"Disable color output", \
|
||||||
"Display software version", \
|
"Display software version", \
|
||||||
"Run verbosely", \
|
"Run verbosely", \
|
||||||
"Run quietly (repeat to suppress errors)"
|
"Run quietly (Does not affect errors)"
|
||||||
|
|
||||||
#define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1);
|
#define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1);
|
||||||
#define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
|
#define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
|
||||||
#define case_RC_COMMON_getopt_case_V if (argc == 2) show_version();
|
#define case_RC_COMMON_getopt_case_V if (argc == 2) show_version();
|
||||||
#define case_RC_COMMON_getopt_case_v setenv ("EINFO_VERBOSE", "YES", 1);
|
#define case_RC_COMMON_getopt_case_v setenv ("EINFO_VERBOSE", "YES", 1);
|
||||||
#define case_RC_COMMON_getopt_case_q set_quiet_options();
|
#define case_RC_COMMON_getopt_case_q setenv ("EINFO_QUIET", "YES", 1);
|
||||||
#define case_RC_COMMON_getopt_default usage (EXIT_FAILURE);
|
#define case_RC_COMMON_getopt_default usage (EXIT_FAILURE);
|
||||||
|
|
||||||
#define case_RC_COMMON_GETOPT \
|
#define case_RC_COMMON_GETOPT \
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
# include <sys/statvfs.h>
|
# include <sys/statvfs.h>
|
||||||
# define statfs statvfs
|
# define statfs statvfs
|
||||||
# define F_FLAGS f_flag
|
# define F_FLAGS f_flag
|
||||||
#elif defined (__linux__)
|
#elif defined (__linux__) || defined (__GLIBC__)
|
||||||
# include <mntent.h>
|
# include <mntent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ find_mounts(struct args *args)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined (__linux__)
|
#elif defined (__linux__) || defined (__GLIBC__)
|
||||||
static struct mntent *
|
static struct mntent *
|
||||||
getmntfile(const char *file)
|
getmntfile(const char *file)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || defined(__GLIBC__)
|
||||||
# include <pty.h>
|
# include <pty.h>
|
||||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
# include <util.h>
|
# include <util.h>
|
||||||
|
|||||||
@@ -171,26 +171,6 @@ print_services(const char *runlevel, RC_STRINGLIST *svcs)
|
|||||||
rc_stringlist_free(l);
|
rc_stringlist_free(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
print_stacked_services(const char *runlevel)
|
|
||||||
{
|
|
||||||
RC_STRINGLIST *stackedlevels, *servicelist;
|
|
||||||
RC_STRING *stackedlevel;
|
|
||||||
|
|
||||||
stackedlevels = rc_runlevel_stacks(runlevel);
|
|
||||||
TAILQ_FOREACH(stackedlevel, stackedlevels, entries) {
|
|
||||||
if (rc_stringlist_find(levels, stackedlevel->value) != NULL)
|
|
||||||
continue;
|
|
||||||
print_level("Stacked", stackedlevel->value);
|
|
||||||
servicelist = rc_services_in_runlevel(stackedlevel->value);
|
|
||||||
print_services(stackedlevel->value, servicelist);
|
|
||||||
rc_stringlist_free(servicelist);
|
|
||||||
print_stacked_services(stackedlevel->value);
|
|
||||||
}
|
|
||||||
rc_stringlist_free(stackedlevels);
|
|
||||||
stackedlevels = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#define usagestring "" \
|
#define usagestring "" \
|
||||||
"Usage: rc-status [options] <runlevel>...\n" \
|
"Usage: rc-status [options] <runlevel>...\n" \
|
||||||
@@ -219,8 +199,7 @@ static const char * const longopts_help[] = {
|
|||||||
int
|
int
|
||||||
rc_status(int argc, char **argv)
|
rc_status(int argc, char **argv)
|
||||||
{
|
{
|
||||||
RC_STRING *s, *l, *t, *level;
|
RC_STRING *s, *l, *t;
|
||||||
|
|
||||||
char *p, *runlevel = NULL;
|
char *p, *runlevel = NULL;
|
||||||
int opt, aflag = 0, retval = 0;
|
int opt, aflag = 0, retval = 0;
|
||||||
|
|
||||||
@@ -301,7 +280,16 @@ rc_status(int argc, char **argv)
|
|||||||
print_level(NULL, l->value);
|
print_level(NULL, l->value);
|
||||||
services = rc_services_in_runlevel(l->value);
|
services = rc_services_in_runlevel(l->value);
|
||||||
print_services(l->value, services);
|
print_services(l->value, services);
|
||||||
print_stacked_services(l->value);
|
nservices = rc_runlevel_stacks(l->value);
|
||||||
|
TAILQ_FOREACH(s, nservices, entries) {
|
||||||
|
if (rc_stringlist_find(levels, s->value) != NULL)
|
||||||
|
continue;
|
||||||
|
print_level("Stacked", s->value);
|
||||||
|
sservices = rc_services_in_runlevel(s->value);
|
||||||
|
print_services(s->value, sservices);
|
||||||
|
rc_stringlist_free(sservices);
|
||||||
|
}
|
||||||
|
sservices = NULL;
|
||||||
rc_stringlist_free(nservices);
|
rc_stringlist_free(nservices);
|
||||||
nservices = NULL;
|
nservices = NULL;
|
||||||
rc_stringlist_free(services);
|
rc_stringlist_free(services);
|
||||||
@@ -329,13 +317,15 @@ rc_status(int argc, char **argv)
|
|||||||
services = rc_services_in_runlevel(NULL);
|
services = rc_services_in_runlevel(NULL);
|
||||||
sservices = rc_stringlist_new();
|
sservices = rc_stringlist_new();
|
||||||
TAILQ_FOREACH(l, levels, entries) {
|
TAILQ_FOREACH(l, levels, entries) {
|
||||||
nservices = rc_services_in_runlevel_stacked(l->value);
|
nservices = rc_services_in_runlevel(l->value);
|
||||||
TAILQ_CONCAT(sservices, nservices, entries);
|
TAILQ_CONCAT(sservices, nservices, entries);
|
||||||
free(nservices);
|
free(nservices);
|
||||||
}
|
}
|
||||||
TAILQ_FOREACH_SAFE(s, services, entries, t) {
|
TAILQ_FOREACH_SAFE(s, services, entries, t) {
|
||||||
if ((rc_stringlist_find(sservices, s->value) ||
|
if (rc_stringlist_find(sservices, s->value) ||
|
||||||
(rc_service_state(s->value) & ( RC_SERVICE_STOPPED | RC_SERVICE_HOTPLUGGED)))) {
|
rc_service_state(s->value) &
|
||||||
|
(RC_SERVICE_STOPPED | RC_SERVICE_HOTPLUGGED))
|
||||||
|
{
|
||||||
TAILQ_REMOVE(services, s, entries);
|
TAILQ_REMOVE(services, s, entries);
|
||||||
free(s->value);
|
free(s->value);
|
||||||
free(s);
|
free(s);
|
||||||
@@ -347,23 +337,22 @@ rc_status(int argc, char **argv)
|
|||||||
alist = rc_stringlist_new();
|
alist = rc_stringlist_new();
|
||||||
l = rc_stringlist_add(alist, "");
|
l = rc_stringlist_add(alist, "");
|
||||||
p = l->value;
|
p = l->value;
|
||||||
TAILQ_FOREACH(level, levels, entries) {
|
if (!runlevel)
|
||||||
|
runlevel = rc_runlevel_get();
|
||||||
TAILQ_FOREACH_SAFE(s, services, entries, t) {
|
TAILQ_FOREACH_SAFE(s, services, entries, t) {
|
||||||
l->value = s->value;
|
l->value = s->value;
|
||||||
|
unsetenv("RC_SVCNAME");
|
||||||
setenv("RC_SVCNAME", l->value, 1);
|
setenv("RC_SVCNAME", l->value, 1);
|
||||||
tmp = rc_deptree_depends(deptree, needsme, alist, level->value, RC_DEP_TRACE);
|
tmp = rc_deptree_depends(deptree, needsme, alist, runlevel, RC_DEP_TRACE);
|
||||||
if (TAILQ_FIRST(tmp)) {
|
if (TAILQ_FIRST(tmp)) {
|
||||||
TAILQ_REMOVE(services, s, entries);
|
TAILQ_REMOVE(services, s, entries);
|
||||||
TAILQ_INSERT_TAIL(nservices, s, entries);
|
TAILQ_INSERT_TAIL(nservices, s, entries);
|
||||||
}
|
}
|
||||||
rc_stringlist_free(tmp);
|
rc_stringlist_free(tmp);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
l->value = p;
|
l->value = p;
|
||||||
/*
|
/* we are unsetting RC_SVCNAME because last loaded service
|
||||||
* we are unsetting RC_SVCNAME because last loaded service will not
|
wount be added to list */
|
||||||
* be added to the list
|
|
||||||
*/
|
|
||||||
unsetenv("RC_SVCNAME");
|
unsetenv("RC_SVCNAME");
|
||||||
print_level("Dynamic", "needed");
|
print_level("Dynamic", "needed");
|
||||||
print_services(NULL, nservices);
|
print_services(NULL, nservices);
|
||||||
|
|||||||
88
src/rc/rc.c
88
src/rc/rc.c
@@ -79,6 +79,12 @@ const char rc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
|
|||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
static char *runlevel;
|
static char *runlevel;
|
||||||
|
static RC_STRINGLIST *hotplugged_services;
|
||||||
|
static RC_STRINGLIST *stop_services;
|
||||||
|
static RC_STRINGLIST *start_services;
|
||||||
|
static RC_STRINGLIST *types_n;
|
||||||
|
static RC_STRINGLIST *types_nua;
|
||||||
|
static RC_DEPTREE *deptree;
|
||||||
static RC_HOOK hook_out;
|
static RC_HOOK hook_out;
|
||||||
|
|
||||||
struct termios *termios_orig = NULL;
|
struct termios *termios_orig = NULL;
|
||||||
@@ -518,9 +524,7 @@ runlevel_config(const char *service, const char *level)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_stop_services(const RC_STRINGLIST *types_n, const RC_STRINGLIST *start_services,
|
do_stop_services(const char *newlevel, bool parallel, bool going_down)
|
||||||
const RC_STRINGLIST *stop_services, const RC_DEPTREE *deptree,
|
|
||||||
const char *newlevel, bool parallel, bool going_down)
|
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
RC_STRING *service, *svc1, *svc2;
|
RC_STRING *service, *svc1, *svc2;
|
||||||
@@ -623,7 +627,7 @@ stop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_start_services(const RC_STRINGLIST *start_services, bool parallel)
|
do_start_services(bool parallel)
|
||||||
{
|
{
|
||||||
RC_STRING *service;
|
RC_STRING *service;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@@ -750,12 +754,6 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
const char *bootlevel = NULL;
|
const char *bootlevel = NULL;
|
||||||
char *newlevel = NULL;
|
char *newlevel = NULL;
|
||||||
static RC_STRINGLIST *hotplugged_services;
|
|
||||||
static RC_STRINGLIST *stop_services;
|
|
||||||
static RC_STRINGLIST *start_services;
|
|
||||||
static RC_STRINGLIST *types_n;
|
|
||||||
static RC_STRINGLIST *types_nua;
|
|
||||||
static RC_DEPTREE *deptree;
|
|
||||||
RC_STRINGLIST *deporder = NULL;
|
RC_STRINGLIST *deporder = NULL;
|
||||||
RC_STRINGLIST *tmplist;
|
RC_STRINGLIST *tmplist;
|
||||||
RC_STRING *service;
|
RC_STRING *service;
|
||||||
@@ -870,11 +868,7 @@ main(int argc, char **argv)
|
|||||||
snprintf(pidstr, sizeof(pidstr), "%d", getpid());
|
snprintf(pidstr, sizeof(pidstr), "%d", getpid());
|
||||||
setenv("RC_PID", pidstr, 1);
|
setenv("RC_PID", pidstr, 1);
|
||||||
|
|
||||||
/* Create a list of all services which should be started for the new or
|
/* Load current runlevel */
|
||||||
* current runlevel including those in boot, sysinit and hotplugged
|
|
||||||
* runlevels. Clearly, some of these will already be started so we
|
|
||||||
* won't actually be starting them all.
|
|
||||||
*/
|
|
||||||
bootlevel = getenv("RC_BOOTLEVEL");
|
bootlevel = getenv("RC_BOOTLEVEL");
|
||||||
runlevel = rc_runlevel_get();
|
runlevel = rc_runlevel_get();
|
||||||
|
|
||||||
@@ -978,13 +972,8 @@ main(int argc, char **argv)
|
|||||||
applet, RC_STOPPING, strerror(errno));
|
applet, RC_STOPPING, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a list of all services which we could stop (assuming
|
/* Build a list of all services to stop and then work out the
|
||||||
* they won't be active in the new or current runlevel) including
|
* correct order for stopping them */
|
||||||
* all those services which have been started, are inactive or
|
|
||||||
* are currently starting. Clearly, some of these will be listed
|
|
||||||
* in the new or current runlevel so we won't actually be stopping
|
|
||||||
* them all.
|
|
||||||
*/
|
|
||||||
stop_services = rc_services_in_state(RC_SERVICE_STARTED);
|
stop_services = rc_services_in_state(RC_SERVICE_STARTED);
|
||||||
tmplist = rc_services_in_state(RC_SERVICE_INACTIVE);
|
tmplist = rc_services_in_state(RC_SERVICE_INACTIVE);
|
||||||
TAILQ_CONCAT(stop_services, tmplist, entries);
|
TAILQ_CONCAT(stop_services, tmplist, entries);
|
||||||
@@ -1007,11 +996,7 @@ main(int argc, char **argv)
|
|||||||
stop_services = tmplist;
|
stop_services = tmplist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a list of all services which should be started for the new or
|
/* Load our list of start services */
|
||||||
* current runlevel including those in boot, sysinit and hotplugged
|
|
||||||
* runlevels. Clearly, some of these will already be started so we
|
|
||||||
* won't actually be starting them all.
|
|
||||||
*/
|
|
||||||
hotplugged_services = rc_services_in_state(RC_SERVICE_HOTPLUGGED);
|
hotplugged_services = rc_services_in_state(RC_SERVICE_HOTPLUGGED);
|
||||||
start_services = rc_services_in_runlevel_stacked(newlevel ?
|
start_services = rc_services_in_runlevel_stacked(newlevel ?
|
||||||
newlevel : runlevel);
|
newlevel : runlevel);
|
||||||
@@ -1021,11 +1006,9 @@ main(int argc, char **argv)
|
|||||||
tmplist = rc_services_in_runlevel(RC_LEVEL_SYSINIT);
|
tmplist = rc_services_in_runlevel(RC_LEVEL_SYSINIT);
|
||||||
TAILQ_CONCAT(start_services, tmplist, entries);
|
TAILQ_CONCAT(start_services, tmplist, entries);
|
||||||
free(tmplist);
|
free(tmplist);
|
||||||
/* If we are NOT headed for the single-user runlevel... */
|
|
||||||
if (strcmp(newlevel ? newlevel : runlevel,
|
if (strcmp(newlevel ? newlevel : runlevel,
|
||||||
RC_LEVEL_SINGLE) != 0)
|
RC_LEVEL_SINGLE) != 0)
|
||||||
{
|
{
|
||||||
/* If we are NOT headed for the boot runlevel... */
|
|
||||||
if (strcmp(newlevel ? newlevel : runlevel,
|
if (strcmp(newlevel ? newlevel : runlevel,
|
||||||
bootlevel) != 0)
|
bootlevel) != 0)
|
||||||
{
|
{
|
||||||
@@ -1046,7 +1029,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Now stop the services that shouldn't be running */
|
/* Now stop the services that shouldn't be running */
|
||||||
if (stop_services && !nostop)
|
if (stop_services && !nostop)
|
||||||
do_stop_services(types_n, start_services, stop_services, deptree, newlevel, parallel, going_down);
|
do_stop_services(newlevel, parallel, going_down);
|
||||||
|
|
||||||
/* Wait for our services to finish */
|
/* Wait for our services to finish */
|
||||||
wait_for_services();
|
wait_for_services();
|
||||||
@@ -1082,10 +1065,18 @@ main(int argc, char **argv)
|
|||||||
TAILQ_FOREACH(service, hotplugged_services, entries)
|
TAILQ_FOREACH(service, hotplugged_services, entries)
|
||||||
rc_service_mark(service->value, RC_SERVICE_HOTPLUGGED);
|
rc_service_mark(service->value, RC_SERVICE_HOTPLUGGED);
|
||||||
|
|
||||||
|
/* Order the services to start */
|
||||||
|
if (start_services) {
|
||||||
|
rc_stringlist_sort(&start_services);
|
||||||
|
deporder = rc_deptree_depends(deptree, types_nua,
|
||||||
|
start_services, runlevel,
|
||||||
|
depoptions | RC_DEP_START);
|
||||||
|
rc_stringlist_free(start_services);
|
||||||
|
start_services = deporder;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
/* If the "noinit" parameter was passed on the kernel command line then
|
/* mark any services skipped as started */
|
||||||
* mark the specified services as started so they will not be started
|
|
||||||
* by us. */
|
|
||||||
proc = p = rc_proc_getent("noinit");
|
proc = p = rc_proc_getent("noinit");
|
||||||
if (proc) {
|
if (proc) {
|
||||||
while ((token = strsep(&p, ",")))
|
while ((token = strsep(&p, ",")))
|
||||||
@@ -1094,38 +1085,19 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If we have a list of services to start then... */
|
|
||||||
if (start_services) {
|
if (start_services) {
|
||||||
/* Get a list of the chained runlevels which compose the target runlevel */
|
do_start_services(parallel);
|
||||||
RC_STRINGLIST *runlevel_chain = rc_runlevel_stacks(runlevel);
|
/* FIXME: If we skip the boot runlevel and go straight
|
||||||
|
* to default from sysinit, we should now re-evaluate our
|
||||||
/* Loop through them in reverse order. */
|
* start services + hotplugged services and call
|
||||||
RC_STRING *rlevel;
|
* do_start_services a second time. */
|
||||||
TAILQ_FOREACH_REVERSE(rlevel, runlevel_chain, rc_stringlist, entries)
|
|
||||||
{
|
|
||||||
/* Get a list of all the services in that runlevel */
|
|
||||||
RC_STRINGLIST *run_services = rc_services_in_runlevel(rlevel->value);
|
|
||||||
|
|
||||||
/* Start those services. */
|
|
||||||
rc_stringlist_sort(&run_services);
|
|
||||||
deporder = rc_deptree_depends(deptree, types_nua, run_services, rlevel->value, depoptions | RC_DEP_START);
|
|
||||||
rc_stringlist_free(run_services);
|
|
||||||
run_services = deporder;
|
|
||||||
do_start_services(run_services, parallel);
|
|
||||||
|
|
||||||
/* Wait for our services to finish */
|
/* Wait for our services to finish */
|
||||||
wait_for_services();
|
wait_for_services();
|
||||||
|
|
||||||
/* Free the list of services, we're done with it. */
|
|
||||||
rc_stringlist_free(run_services);
|
|
||||||
}
|
|
||||||
rc_stringlist_free(runlevel_chain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
/* If the "noinit" parameter was passed on the kernel command line then
|
/* mark any services skipped as stopped */
|
||||||
* mark the specified services as stopped so that our records reflect
|
|
||||||
* reality. */
|
|
||||||
proc = p = rc_proc_getent("noinit");
|
proc = p = rc_proc_getent("noinit");
|
||||||
if (proc) {
|
if (proc) {
|
||||||
while ((token = strsep(&p, ",")))
|
while ((token = strsep(&p, ",")))
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || defined(__GLIBC__)
|
||||||
# include <pty.h>
|
# include <pty.h>
|
||||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
# include <util.h>
|
# include <util.h>
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ parse_schedule(const char *string, int timeout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static pid_t
|
static pid_t
|
||||||
get_pid(const char *pidfile)
|
get_pid(const char *pidfile, bool quiet)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@@ -334,7 +334,8 @@ get_pid(const char *pidfile)
|
|||||||
/* return number of processed killed, -1 on error */
|
/* return number of processed killed, -1 on error */
|
||||||
static int
|
static int
|
||||||
do_stop(const char *exec, const char *const *argv,
|
do_stop(const char *exec, const char *const *argv,
|
||||||
pid_t pid, uid_t uid,int sig, bool test)
|
pid_t pid, uid_t uid,int sig,
|
||||||
|
bool quiet, bool verbose, bool test)
|
||||||
{
|
{
|
||||||
RC_PIDLIST *pids;
|
RC_PIDLIST *pids;
|
||||||
RC_PID *pi;
|
RC_PID *pi;
|
||||||
@@ -352,14 +353,18 @@ do_stop(const char *exec, const char *const *argv,
|
|||||||
|
|
||||||
LIST_FOREACH_SAFE(pi, pids, entries, np) {
|
LIST_FOREACH_SAFE(pi, pids, entries, np) {
|
||||||
if (test) {
|
if (test) {
|
||||||
|
if (!quiet)
|
||||||
einfo("Would send signal %d to PID %d", sig, pi->pid);
|
einfo("Would send signal %d to PID %d", sig, pi->pid);
|
||||||
nkilled++;
|
nkilled++;
|
||||||
} else {
|
} else {
|
||||||
ebeginv("Sending signal %d to PID %d", sig, pi->pid);
|
if (verbose)
|
||||||
|
ebegin("Sending signal %d to PID %d",
|
||||||
|
sig, pi->pid);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
killed = (kill(pi->pid, sig) == 0 ||
|
killed = (kill(pi->pid, sig) == 0 ||
|
||||||
errno == ESRCH ? true : false);
|
errno == ESRCH ? true : false);
|
||||||
eendv(killed ? 0 : 1,
|
if (verbose)
|
||||||
|
eend(killed ? 0 : 1,
|
||||||
"%s: failed to send signal %d to PID %d: %s",
|
"%s: failed to send signal %d to PID %d: %s",
|
||||||
applet, sig, pi->pid, strerror(errno));
|
applet, sig, pi->pid, strerror(errno));
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
@@ -379,7 +384,7 @@ do_stop(const char *exec, const char *const *argv,
|
|||||||
static int
|
static int
|
||||||
run_stop_schedule(const char *exec, const char *const *argv,
|
run_stop_schedule(const char *exec, const char *const *argv,
|
||||||
const char *pidfile, uid_t uid,
|
const char *pidfile, uid_t uid,
|
||||||
bool test, bool progress)
|
bool quiet, bool verbose, bool test, bool progress)
|
||||||
{
|
{
|
||||||
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
|
SCHEDULEITEM *item = TAILQ_FIRST(&schedule);
|
||||||
int nkilled = 0;
|
int nkilled = 0;
|
||||||
@@ -391,15 +396,15 @@ run_stop_schedule(const char *exec, const char *const *argv,
|
|||||||
const char *const *p;
|
const char *const *p;
|
||||||
bool progressed = false;
|
bool progressed = false;
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
if (exec)
|
if (exec)
|
||||||
einfov("Will stop %s", exec);
|
einfo ("Will stop %s", exec);
|
||||||
if (pidfile)
|
if (pidfile)
|
||||||
einfov("Will stop PID in pidfile `%s'", pidfile);
|
einfo("Will stop PID in pidfile `%s'", pidfile);
|
||||||
if (uid)
|
if (uid)
|
||||||
einfov("Will stop processes owned by UID %d", uid);
|
einfo("Will stop processes owned by UID %d", uid);
|
||||||
if (argv && *argv) {
|
if (argv && *argv) {
|
||||||
einfovn("Will stop processes of `");
|
einfon("Will stop processes of `");
|
||||||
if (rc_yesno(getenv("EINFO_VERBOSE"))) {
|
|
||||||
for (p = argv; p && *p; p++) {
|
for (p = argv; p && *p; p++) {
|
||||||
if (p != argv)
|
if (p != argv)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
@@ -410,7 +415,7 @@ run_stop_schedule(const char *exec, const char *const *argv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pidfile) {
|
if (pidfile) {
|
||||||
pid = get_pid(pidfile);
|
pid = get_pid(pidfile, false);
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -423,7 +428,8 @@ run_stop_schedule(const char *exec, const char *const *argv,
|
|||||||
|
|
||||||
case SC_SIGNAL:
|
case SC_SIGNAL:
|
||||||
nrunning = 0;
|
nrunning = 0;
|
||||||
nkilled = do_stop(exec, argv, pid, uid, item->value, test);
|
nkilled = do_stop(exec, argv, pid, uid, item->value,
|
||||||
|
quiet, verbose, test);
|
||||||
if (nkilled == 0) {
|
if (nkilled == 0) {
|
||||||
if (tkilled == 0) {
|
if (tkilled == 0) {
|
||||||
if (progressed)
|
if (progressed)
|
||||||
@@ -452,7 +458,8 @@ run_stop_schedule(const char *exec, const char *const *argv,
|
|||||||
nloops++)
|
nloops++)
|
||||||
{
|
{
|
||||||
if ((nrunning = do_stop(exec, argv,
|
if ((nrunning = do_stop(exec, argv,
|
||||||
pid, uid, 0, test)) == 0)
|
pid, uid, 0, true, false,
|
||||||
|
test)) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -669,6 +676,8 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
bool stop = false;
|
bool stop = false;
|
||||||
bool oknodo = false;
|
bool oknodo = false;
|
||||||
bool test = false;
|
bool test = false;
|
||||||
|
bool quiet;
|
||||||
|
bool verbose = false;
|
||||||
char *exec = NULL;
|
char *exec = NULL;
|
||||||
char *startas = NULL;
|
char *startas = NULL;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
@@ -905,6 +914,8 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
endpwent();
|
endpwent();
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
quiet = rc_yesno(getenv("EINFO_QUIET"));
|
||||||
|
verbose = rc_yesno(getenv("EINFO_VERBOSE"));
|
||||||
|
|
||||||
/* Allow start-stop-daemon --signal HUP --exec /usr/sbin/dnsmasq
|
/* Allow start-stop-daemon --signal HUP --exec /usr/sbin/dnsmasq
|
||||||
* instead of forcing --stop --oknodo as well */
|
* instead of forcing --stop --oknodo as well */
|
||||||
@@ -1048,7 +1059,7 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
parse_schedule(NULL, sig);
|
parse_schedule(NULL, sig);
|
||||||
i = run_stop_schedule(exec, (const char *const *)margv,
|
i = run_stop_schedule(exec, (const char *const *)margv,
|
||||||
pidfile, uid, test, progress);
|
pidfile, uid, quiet, verbose, test, progress);
|
||||||
|
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
/* We failed to stop something */
|
/* We failed to stop something */
|
||||||
@@ -1070,16 +1081,16 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pidfile)
|
if (pidfile)
|
||||||
pid = get_pid(pidfile);
|
pid = get_pid(pidfile, true);
|
||||||
else
|
else
|
||||||
pid = 0;
|
pid = 0;
|
||||||
|
|
||||||
if (do_stop(exec, (const char * const *)margv, pid, uid,
|
if (do_stop(exec, (const char * const *)margv, pid, uid,
|
||||||
0, test) > 0)
|
0, true, false, test) > 0)
|
||||||
eerrorx("%s: %s is already running", applet, exec);
|
eerrorx("%s: %s is already running", applet, exec);
|
||||||
|
|
||||||
if (test) {
|
if (test) {
|
||||||
if (rc_yesno(getenv("EINFO_QUIET")))
|
if (quiet)
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
einfon("Would start");
|
einfon("Would start");
|
||||||
@@ -1103,8 +1114,10 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
ebeginv("Detaching to start `%s'", exec);
|
if (verbose) {
|
||||||
eindentv();
|
ebegin("Detaching to start `%s'", exec);
|
||||||
|
eindent();
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove existing pidfile */
|
/* Remove existing pidfile */
|
||||||
if (pidfile)
|
if (pidfile)
|
||||||
@@ -1272,9 +1285,9 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* We don't redirect stdin as some daemons may need it */
|
/* We don't redirect stdin as some daemons may need it */
|
||||||
if (background || redirect_stdout || rc_yesno(getenv("EINFO_QUIET")))
|
if (background || quiet || redirect_stdout)
|
||||||
dup2(stdout_fd, STDOUT_FILENO);
|
dup2(stdout_fd, STDOUT_FILENO);
|
||||||
if (background || redirect_stderr || rc_yesno(getenv("EINFO_QUIET")))
|
if (background || redirect_stderr)
|
||||||
dup2(stderr_fd, STDERR_FILENO);
|
dup2(stderr_fd, STDERR_FILENO);
|
||||||
|
|
||||||
for (i = getdtablesize() - 1; i >= 3; --i)
|
for (i = getdtablesize() - 1; i >= 3; --i)
|
||||||
@@ -1305,10 +1318,9 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} while (!WIFEXITED(i) && !WIFSIGNALED(i));
|
} while (!WIFEXITED(i) && !WIFSIGNALED(i));
|
||||||
if (!WIFEXITED(i) || WEXITSTATUS(i) != 0) {
|
if (!WIFEXITED(i) || WEXITSTATUS(i) != 0)
|
||||||
eerror("%s: failed to start `%s'", applet, exec);
|
eerrorx("%s: failed to start `%s'", applet, exec);
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
pid = spid;
|
pid = spid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1342,7 +1354,7 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
alive = true;
|
alive = true;
|
||||||
} else {
|
} else {
|
||||||
if (pidfile) {
|
if (pidfile) {
|
||||||
pid = get_pid(pidfile);
|
pid = get_pid(pidfile, false);
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
eerrorx("%s: did not "
|
eerrorx("%s: did not "
|
||||||
"create a valid"
|
"create a valid"
|
||||||
@@ -1352,7 +1364,7 @@ start_stop_daemon(int argc, char **argv)
|
|||||||
} else
|
} else
|
||||||
pid = 0;
|
pid = 0;
|
||||||
if (do_stop(exec, (const char *const *)margv,
|
if (do_stop(exec, (const char *const *)margv,
|
||||||
pid, uid, 0, test) > 0)
|
pid, uid, 0, true, false, test) > 0)
|
||||||
alive = true;
|
alive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
src/test/einfo.data.list
Normal file
1
src/test/einfo.data.list
Normal file
@@ -0,0 +1 @@
|
|||||||
|
EINFO_1.0
|
||||||
52
src/test/einfo.funcs.list
Normal file
52
src/test/einfo.funcs.list
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
ebegin
|
||||||
|
ebegin@@EINFO_1.0
|
||||||
|
ebeginv
|
||||||
|
ebeginv@@EINFO_1.0
|
||||||
|
ebracket
|
||||||
|
ebracket@@EINFO_1.0
|
||||||
|
ecolor
|
||||||
|
ecolor@@EINFO_1.0
|
||||||
|
eend
|
||||||
|
eend@@EINFO_1.0
|
||||||
|
eendv
|
||||||
|
eendv@@EINFO_1.0
|
||||||
|
eerror
|
||||||
|
eerror@@EINFO_1.0
|
||||||
|
eerrorn
|
||||||
|
eerrorn@@EINFO_1.0
|
||||||
|
eerrorx
|
||||||
|
eerrorx@@EINFO_1.0
|
||||||
|
eindent
|
||||||
|
eindent@@EINFO_1.0
|
||||||
|
eindentv
|
||||||
|
eindentv@@EINFO_1.0
|
||||||
|
einfo
|
||||||
|
einfo@@EINFO_1.0
|
||||||
|
einfon
|
||||||
|
einfon@@EINFO_1.0
|
||||||
|
einfov
|
||||||
|
einfov@@EINFO_1.0
|
||||||
|
einfovn
|
||||||
|
einfovn@@EINFO_1.0
|
||||||
|
elog
|
||||||
|
elog@@EINFO_1.0
|
||||||
|
eoutdent
|
||||||
|
eoutdent@@EINFO_1.0
|
||||||
|
eoutdentv
|
||||||
|
eoutdentv@@EINFO_1.0
|
||||||
|
eprefix
|
||||||
|
eprefix@@EINFO_1.0
|
||||||
|
ewarn
|
||||||
|
ewarn@@EINFO_1.0
|
||||||
|
ewarnn
|
||||||
|
ewarnn@@EINFO_1.0
|
||||||
|
ewarnv
|
||||||
|
ewarnv@@EINFO_1.0
|
||||||
|
ewarnvn
|
||||||
|
ewarnvn@@EINFO_1.0
|
||||||
|
ewarnx
|
||||||
|
ewarnx@@EINFO_1.0
|
||||||
|
ewend
|
||||||
|
ewend@@EINFO_1.0
|
||||||
|
ewendv
|
||||||
|
ewendv@@EINFO_1.0
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
top_srcdir=${top_srcdir:-../..}
|
top_srcdir=${top_srcdir:-../..}
|
||||||
. ${top_srcdir}/test/setup_env.sh
|
. ${top_srcdir}/test/setup_env.sh
|
||||||
|
|
||||||
|
libeinfo_srcdir="${srcdir}/../libeinfo"
|
||||||
|
libeinfo_builddir="${builddir}/../libeinfo"
|
||||||
librc_srcdir="${srcdir}/../librc"
|
librc_srcdir="${srcdir}/../librc"
|
||||||
librc_builddir="${builddir}/../librc"
|
librc_builddir="${builddir}/../librc"
|
||||||
rc_srcdir="${srcdir}/../rc"
|
rc_srcdir="${srcdir}/../rc"
|
||||||
@@ -18,6 +20,22 @@ checkit() {
|
|||||||
|
|
||||||
ret=0
|
ret=0
|
||||||
|
|
||||||
|
ebegin "Checking exported symbols in libeinfo.so (data)"
|
||||||
|
checkit einfo.data $(
|
||||||
|
readelf -Ws ${libeinfo_builddir}/libeinfo.so \
|
||||||
|
| awk '$4 == "OBJECT" && $5 == "GLOBAL" && $7 != "UND" {print $NF}' \
|
||||||
|
| LC_ALL=C sort -u
|
||||||
|
)
|
||||||
|
|
||||||
|
ebegin "Checking exported symbols in libeinfo.so (functions)"
|
||||||
|
checkit einfo.funcs $(
|
||||||
|
readelf -Ws ${libeinfo_builddir}/libeinfo.so \
|
||||||
|
| awk '$4 == "FUNC" && $5 == "GLOBAL" && $7 != "UND" {print $NF}' \
|
||||||
|
| LC_ALL=C sort -u \
|
||||||
|
| egrep -v \
|
||||||
|
-e '^_(init|fini)$'
|
||||||
|
)
|
||||||
|
|
||||||
ebegin "Checking exported symbols in librc.so (data)"
|
ebegin "Checking exported symbols in librc.so (data)"
|
||||||
checkit rc.data $(
|
checkit rc.data $(
|
||||||
readelf -Ws ${librc_builddir}/librc.so \
|
readelf -Ws ${librc_builddir}/librc.so \
|
||||||
|
|||||||
Reference in New Issue
Block a user