Compare commits
209 Commits
openrc-0.2
...
openrc-0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84f6bf4bff | ||
|
|
5f76c1121a | ||
|
|
41c1e170d6 | ||
|
|
f53197818b | ||
|
|
bb41d2cc80 | ||
|
|
4291b9140e | ||
|
|
28d7fb9430 | ||
|
|
abe94bec6f | ||
|
|
c3e192a834 | ||
|
|
13d88731b7 | ||
|
|
ffc79a50c2 | ||
|
|
6748c0e04e | ||
|
|
27805de20a | ||
|
|
53693367df | ||
|
|
554d2fea19 | ||
|
|
a63303971a | ||
|
|
5610c8560c | ||
|
|
2c62d095c8 | ||
|
|
a72dc1194a | ||
|
|
dcc4aa131c | ||
|
|
6b3d8cf598 | ||
|
|
600d1f62fb | ||
|
|
2de401bca1 | ||
|
|
e368a4b4f8 | ||
|
|
354fb96ee9 | ||
|
|
312d6f3e57 | ||
|
|
39ea0cb84d | ||
|
|
17bf78a539 | ||
|
|
072328ff60 | ||
|
|
e0dfa472d1 | ||
|
|
ccc24d1086 | ||
|
|
c4c024fc9d | ||
|
|
223015920c | ||
|
|
aa02a5516a | ||
|
|
80a17eb596 | ||
|
|
39304745d4 | ||
|
|
93a3b2dd02 | ||
|
|
00d010fbe0 | ||
|
|
01de348ede | ||
|
|
fabee4dc2d | ||
|
|
1ab1e9328a | ||
|
|
a9f7d2d5e5 | ||
|
|
a3c8706618 | ||
|
|
1f227d62bf | ||
|
|
cdace75539 | ||
|
|
15678263d5 | ||
|
|
cea206014d | ||
|
|
46a74f244e | ||
|
|
c67233f15c | ||
|
|
b15c4758f8 | ||
|
|
289889ebf0 | ||
|
|
7183cb1b18 | ||
|
|
b83108cd2e | ||
|
|
1ca63447c9 | ||
|
|
c2781c209e | ||
|
|
5983add0f2 | ||
|
|
a566493eb8 | ||
|
|
bdd8b150cd | ||
|
|
53401cd35f | ||
|
|
7a6112d3b0 | ||
|
|
157db50df7 | ||
|
|
a88a177f99 | ||
|
|
d61f831896 | ||
|
|
28a65393ca | ||
|
|
aa57dd1ff6 | ||
|
|
e0968a1c2e | ||
|
|
2f5d2855ba | ||
|
|
db9bf18587 | ||
|
|
feac5ea1d5 | ||
|
|
64dbae7f61 | ||
|
|
11e4059b05 | ||
|
|
5510451bac | ||
|
|
11acce3c7d | ||
|
|
4f2bb5ceaf | ||
|
|
bf8f0da921 | ||
|
|
9b1cb4e246 | ||
|
|
2adc99a8f5 | ||
|
|
fc747f9894 | ||
|
|
76063daee5 | ||
|
|
dc891b0647 | ||
|
|
3525e602d6 | ||
|
|
79ebd89d19 | ||
|
|
ba8008fb05 | ||
|
|
5e2c3fb5fe | ||
|
|
e6aed12328 | ||
|
|
83ade5b701 | ||
|
|
587051ec67 | ||
|
|
f2ea7ca514 | ||
|
|
b41c864fc3 | ||
|
|
c409dd0570 | ||
|
|
aaaa0b50d8 | ||
|
|
ca6f289c80 | ||
|
|
f640ecaebb | ||
|
|
75eff5a86b | ||
|
|
eeadc618fb | ||
|
|
bb069e1618 | ||
|
|
3a592fa31b | ||
|
|
6b77cc624f | ||
|
|
328215e841 | ||
|
|
b03282b901 | ||
|
|
08081f7ef4 | ||
|
|
8ca8e00a89 | ||
|
|
1df3ab05b5 | ||
|
|
775df18a70 | ||
|
|
148caecc7e | ||
|
|
d0f7a63487 | ||
|
|
b7e598ad91 | ||
|
|
5c114d9430 | ||
|
|
f13ea77491 | ||
|
|
a89171ee9b | ||
|
|
6d5d655b52 | ||
|
|
0f51f3e863 | ||
|
|
be8f8d0ac0 | ||
|
|
d667da8e5c | ||
|
|
9894669742 | ||
|
|
b732df31ef | ||
|
|
762dc3d197 | ||
|
|
30fe99dead | ||
|
|
2d75eb7976 | ||
|
|
3663cf1e2a | ||
|
|
766ec96e3d | ||
|
|
a854fe6d61 | ||
|
|
619b0b4f37 | ||
|
|
c8248d05a0 | ||
|
|
5ae702339e | ||
|
|
d384502e57 | ||
|
|
bdaca0baf5 | ||
|
|
5188fd2592 | ||
|
|
5b800030f1 | ||
|
|
208443fa0e | ||
|
|
a818eebf7b | ||
|
|
10910876d1 | ||
|
|
35b4978152 | ||
|
|
cedd81801a | ||
|
|
e273b4e08e | ||
|
|
50cff8ebc8 | ||
|
|
aec83494d6 | ||
|
|
5ba6f0a628 | ||
|
|
5a59542629 | ||
|
|
52711bdca7 | ||
|
|
53902cefb8 | ||
|
|
75f991068d | ||
|
|
e499e58310 | ||
|
|
b08b6cd91b | ||
|
|
3c2b93fc9c | ||
|
|
b5d829789f | ||
|
|
1e3442f95d | ||
|
|
2bda1871a1 | ||
|
|
d3b111bd58 | ||
|
|
dbea63b76d | ||
|
|
6a5287dbb5 | ||
|
|
df8eeba2fb | ||
|
|
54fce42c6f | ||
|
|
54d7aa39dd | ||
|
|
dc5d63aa97 | ||
|
|
bab5d7767d | ||
|
|
799686e40d | ||
|
|
d83ae59cca | ||
|
|
18b4108755 | ||
|
|
e96347523f | ||
|
|
f0aacec02e | ||
|
|
57e1dd7389 | ||
|
|
c89b3763fb | ||
|
|
425abe40c5 | ||
|
|
725b9dc89c | ||
|
|
22d650c450 | ||
|
|
809ac86c69 | ||
|
|
b3310e8e10 | ||
|
|
29369c44c1 | ||
|
|
292fe3a568 | ||
|
|
99d5046a56 | ||
|
|
0e38dcc4d2 | ||
|
|
9176b77c23 | ||
|
|
fad61a7c4b | ||
|
|
0e114abf5d | ||
|
|
bc369085c7 | ||
|
|
6d8b36e09d | ||
|
|
8759735711 | ||
|
|
034b9b7a12 | ||
|
|
e82435c2f4 | ||
|
|
71dd280656 | ||
|
|
594d98eddc | ||
|
|
dcdfdb442f | ||
|
|
143239e143 | ||
|
|
5d38d4d6e9 | ||
|
|
c18c4fc4cc | ||
|
|
5ebe7f1349 | ||
|
|
6a227d0c45 | ||
|
|
403abe73de | ||
|
|
be82e950d7 | ||
|
|
3ca8387966 | ||
|
|
f5a9b42215 | ||
|
|
d370918f0c | ||
|
|
e995404e3b | ||
|
|
caa4704ce6 | ||
|
|
17d28fde42 | ||
|
|
b418f2e471 | ||
|
|
ee4e861796 | ||
|
|
11e33e81c8 | ||
|
|
5e8ed2aeca | ||
|
|
742310744d | ||
|
|
4e9b58b07d | ||
|
|
c564043f86 | ||
|
|
b3d1182a2f | ||
|
|
f6cb321f9f | ||
|
|
f85c6ca84c | ||
|
|
d09f9f47eb | ||
|
|
b271ac5af5 | ||
|
|
fccff6a4ed |
2
Makefile
2
Makefile
@@ -3,7 +3,7 @@
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
NAME= openrc
|
||||
VERSION= 0.2
|
||||
VERSION= 0.3.0
|
||||
PKG= ${NAME}-${VERSION}
|
||||
|
||||
SUBDIR= conf.d doc etc init.d man net sh src
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
DIR= ${CONFDIR}
|
||||
CONF= bootmisc fsck hostname local net urandom
|
||||
CONF= bootmisc fsck hostname local localmount net urandom
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/os.mk
|
||||
|
||||
@@ -1 +1 @@
|
||||
CONF+= moused powerd rarpd savecore syscons
|
||||
CONF+= ipfw moused powerd rarpd savecore syscons
|
||||
|
||||
@@ -1 +1 @@
|
||||
CONF+= moused powerd rarpd savecore
|
||||
CONF+= moused rarpd savecore
|
||||
|
||||
14
conf.d/ipfw
Normal file
14
conf.d/ipfw
Normal file
@@ -0,0 +1,14 @@
|
||||
# ipfw provides a stateful firewall.
|
||||
# This means we allow everything out, and if we have a connection we allow it
|
||||
# back in. This is very flexable and quite secure.
|
||||
|
||||
# For ease of use, we allow auth and ssh ports through as well.
|
||||
# To override the list of allowed ports
|
||||
#ipfw_ports_in="auth ssh"
|
||||
|
||||
# You may want to enable logging of denied connections
|
||||
#ipfw_log_deny="YES"
|
||||
|
||||
# This ports not logged
|
||||
#ipfw_ports_nolog="135-139,445 1026,1027 1433,1434"
|
||||
|
||||
3
conf.d/localmount
Normal file
3
conf.d/localmount
Normal file
@@ -0,0 +1,3 @@
|
||||
# Stop the unmounting of certain points.
|
||||
# This could be useful for some NFS related work.
|
||||
#no_umounts="/dir1:/var/dir2"
|
||||
@@ -5,6 +5,10 @@
|
||||
#modules_2_6="tun"
|
||||
#modules="ohci1394"
|
||||
|
||||
# You can give modules a different name when they load - the new name
|
||||
# will also be used to pick arguments below.
|
||||
#modules="dummy:dummy1"
|
||||
|
||||
# Give the modules some arguments if needed, per version if necessary.
|
||||
#module_ieee1394_args="debug"
|
||||
#module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394"
|
||||
|
||||
@@ -87,6 +87,10 @@
|
||||
# is how long we wait for carrier. The current default is 3 seconds
|
||||
#carrier_timeout_eth0=-1
|
||||
|
||||
# You may wish to disable the interface being brought down when stopping.
|
||||
# This is only of use for WakeOnLan.
|
||||
#ifdown_eth0="NO"
|
||||
|
||||
##############################################################################
|
||||
# OPTIONAL MODULES
|
||||
|
||||
|
||||
@@ -120,6 +120,10 @@
|
||||
# tables you may have to set a global metric as the due to a simple read of
|
||||
# the routing table taking over a minute at a time.
|
||||
|
||||
# You may wish to disable the interface being brought down when stopping.
|
||||
# This is only of use for WakeOnLan.
|
||||
#ifdown_eth0="NO"
|
||||
|
||||
##############################################################################
|
||||
# OPTIONAL MODULES
|
||||
|
||||
@@ -565,12 +569,18 @@
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Bonding
|
||||
# For link bonding/trunking emerge net-misc/ifenslave
|
||||
# For link bonding/trunking on 2.4 kernels, or kernels without sysfs
|
||||
# emerge net-misc/ifenslave
|
||||
|
||||
# To bond interfaces together
|
||||
#slaves_bond0="eth0 eth1 eth2"
|
||||
#config_bond0="null" # You may not want to assign an IP the the bond
|
||||
|
||||
# You can also configure the bond here, which must be done via sysfs on 2.6
|
||||
# kernels or newer. See the kernel bonding documention for a description of
|
||||
# these options.
|
||||
#arp_ip_target_bond0="+26.0.0.0"
|
||||
|
||||
# If any of the slaves require extra configuration - for example wireless or
|
||||
# ppp devices - we need to depend function on the bonded interfaces
|
||||
#rc_need_bond0="net.eth0 net.eth1"
|
||||
@@ -1006,7 +1016,7 @@
|
||||
|
||||
#postdown() {
|
||||
# # Enable Wake-On-LAN for every interface except for lo
|
||||
# # Probably a good idea to set RC_DOWN_INTERFACE="no" in /etc/conf.d/rc
|
||||
# # Probably a good idea to set ifdown="no" in /etc/conf.d/net
|
||||
# # as well ;)
|
||||
# [ "${IFACE}" != "lo" ] && ethtool -s "${IFACE}" wol g
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SED_EXTRA= -e 's:@TERM@:cons25:g'
|
||||
SRCS+= rc.conf.in rc.in rc.shutdown.in
|
||||
CONF+= devd.conf
|
||||
BIN+= rc.devd
|
||||
BIN+= rc rc.shutdown rc.devd
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
SED_EXTRA= -e 's:@TERM@:wsvt25:g'
|
||||
SRCS+= rc.conf.in rc.in rc.shutdown.in
|
||||
BIN+= rc rc.shutdown
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
# in parallel for a slight speed improvement. When running in parallel we
|
||||
# prefix the service output with it's name as the output will get
|
||||
# jumbled up.
|
||||
# WARNING: whilst we have improved parallel, it can still potentially lock
|
||||
# the boot process. Don't file bugs about this unless you can supply
|
||||
# patches that fix it without breaking other things!
|
||||
rc_parallel="NO"
|
||||
|
||||
# Set rc_interactive to "YES" and you'll be able to press the I key during
|
||||
@@ -49,6 +52,14 @@ rc_logger="NO"
|
||||
# variables through, add them here. Use a * to allow all variables through.
|
||||
# rc_env_allow="VAR1 VAR2"
|
||||
|
||||
# By default we assume that all daemons will start correctly.
|
||||
# However, some do not - a classic example is that they fork and return 0 AND
|
||||
# then child barfs on a configuration error. Or the daemon has a bug and the
|
||||
# child crashes. You can set the number of milliseconds start-stop-daemon
|
||||
# waits to check that the daemon is still running after starting here.
|
||||
# The default is 0 - no checking.
|
||||
# rc_start_wait=100
|
||||
|
||||
##############################################################################
|
||||
# MISC CONFIGURATION VARIABLES
|
||||
# There variables are shared between many init scripts
|
||||
|
||||
@@ -3,5 +3,8 @@ SRCS= avahi-dnsconfd.in avahid.in dbus.in hald.in named.in ntpd.in \
|
||||
openvpn.in polkitd.in sshd.in
|
||||
|
||||
MK= ../mk
|
||||
|
||||
SED_EXTRA+= -e 's:@VARBASE@:/var:g'
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
include Makefile.${OS}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
command=@PKG_PREFIX@/bin/dbus-daemon
|
||||
pidfile=@VARBASE@/run/dbus/dbus.pid
|
||||
pidfile=@VARBASE@/run/dbus/pid
|
||||
command_args="${dbusd_args---system}"
|
||||
name="Message Bus Daemon"
|
||||
|
||||
|
||||
@@ -4,12 +4,22 @@
|
||||
|
||||
command=/usr/sbin/named
|
||||
command_args=${named_args}
|
||||
pidfile=@VARBASE@/run/named/pid
|
||||
pidfile=@VARBASE@/run/named.pid
|
||||
name="Domain Name server"
|
||||
extra_started_commands="reload"
|
||||
|
||||
namedb=/etc/namedb
|
||||
named_uid=${named_uid:-bind}
|
||||
uid=named
|
||||
case "${RC_UNAME}" in
|
||||
FreeBSD)
|
||||
uid=bind
|
||||
pidfile=@VARBASE@/run/named/pid
|
||||
;;
|
||||
Linux)
|
||||
uid=bind
|
||||
;;
|
||||
esac
|
||||
named_uid=${named_uid:-${uid}}
|
||||
|
||||
depend()
|
||||
{
|
||||
|
||||
13
init.d/.gitignore
vendored
13
init.d/.gitignore
vendored
@@ -26,3 +26,16 @@ mixer
|
||||
nscd
|
||||
powerd
|
||||
syscons
|
||||
net.lo
|
||||
ttys
|
||||
swap-blk
|
||||
wscons
|
||||
consolefont
|
||||
hwclock
|
||||
keymaps
|
||||
modules
|
||||
mtab
|
||||
numlock
|
||||
procfs
|
||||
termencoding
|
||||
devdb
|
||||
|
||||
@@ -3,7 +3,14 @@ SRCS= bootmisc.in fsck.in halt.sh.in hostname.in local.in localmount.in \
|
||||
netmount.in root.in swap.in sysctl.in urandom.in
|
||||
BIN= ${OBJS}
|
||||
|
||||
INSTALLAFTER= _installafter
|
||||
CLEANFILES+= net.lo
|
||||
TARGETS+= net.lo
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/os.mk
|
||||
include Makefile.${OS}
|
||||
include ${MK}/scripts.mk
|
||||
|
||||
_installafter: realinstall
|
||||
${INSTALL} -m ${BINMODE} net.lo ${DESTDIR}/${INITDIR}/${NET_LO}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
NET_LO= net.lo0
|
||||
|
||||
# Generic BSD scripts
|
||||
SRCS+= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \
|
||||
rpcbind.in savecore.in syslogd.in
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
NET_LO= net.lo
|
||||
|
||||
SRCS+= hwclock.in consolefont.in keymaps.in modules.in mtab.in numlock.in \
|
||||
procfs.in
|
||||
procfs.in termencoding.in
|
||||
|
||||
.SUFFIXES: .Linux.in
|
||||
.Linux.in:
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
NET_LO= net.lo0
|
||||
|
||||
# Generic BSD scripts
|
||||
SRCS+= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \
|
||||
rpcbind.in savecore.in syslogd.in
|
||||
|
||||
# These are NetBSD specific
|
||||
SRCS+= swap-blk.in ttys.in wscons.in
|
||||
SRCS+= devdb.in swap-blk.in ttys.in wscons.in
|
||||
|
||||
.SUFFIXES: .BSD.in
|
||||
.BSD.in:
|
||||
|
||||
@@ -11,21 +11,25 @@ depend()
|
||||
keyword noprefix
|
||||
}
|
||||
|
||||
dir_writeable()
|
||||
{
|
||||
mkdir "$1"/.test.$$ 2>/dev/null && rmdir "$1"/.test.$$
|
||||
}
|
||||
|
||||
cleanup_tmp_dir()
|
||||
{
|
||||
local dir=$1
|
||||
local dir="$1"
|
||||
|
||||
mkdir -p "${dir}"
|
||||
if ! [ -d "${dir}" ]; then
|
||||
mkdir -p "${dir}" || return $?
|
||||
fi
|
||||
dir_writeable "${dir}" || return 1
|
||||
chmod +t "${dir}"
|
||||
cd "${dir}"
|
||||
if yesno ${wipe_tmp:-${WIPE_TMP:-yes}}; then
|
||||
ebegin "Wiping ${dir} directory"
|
||||
local startopts="-x . -depth" delete="-exec rm -rf -- {} ;"
|
||||
|
||||
if [ "${RC_UNAME}" = "Linux" ]; then
|
||||
startopts=". -xdev -depth"
|
||||
# busybox find / rm cannot handle --
|
||||
delete="-delete"
|
||||
fi
|
||||
local startopts="-x . -depth"
|
||||
[ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth"
|
||||
|
||||
# Faster than find
|
||||
rm -rf -- [b-ikm-pr-zA-Z0-9\.]*
|
||||
@@ -45,8 +49,7 @@ cleanup_tmp_dir()
|
||||
! -path "./journal/*" \
|
||||
! -path "./.private" \
|
||||
! -path "./.private/*" \
|
||||
${delete} \
|
||||
-type d -prune
|
||||
-exec rm -rf {} \;
|
||||
eend 0
|
||||
else
|
||||
ebegin "Cleaning ${dir} directory"
|
||||
@@ -60,12 +63,7 @@ cleanup_tmp_dir()
|
||||
|
||||
start()
|
||||
{
|
||||
if ! mkdir /.test.$$ 2>/dev/null; then
|
||||
ewarn "Skipping /var and /tmp initialization (ro root?)"
|
||||
return 0
|
||||
fi
|
||||
rmdir /.test.$$
|
||||
|
||||
local logw=false
|
||||
# Ensure that our basic dirs exist
|
||||
for x in /var/log /var/run /tmp; do
|
||||
if ! [ -d "${x}" ]; then
|
||||
@@ -76,51 +74,64 @@ start()
|
||||
fi
|
||||
done
|
||||
|
||||
ebegin "Creating user login records"
|
||||
cp /dev/null /var/run/utmp
|
||||
[ -e /var/log/wtmp ] || cp /dev/null /var/log/wtmp
|
||||
chmod 0644 /var/run/utmp /var/log/wtmp
|
||||
eend 0
|
||||
if dir_writeable /var/run; then
|
||||
ebegin "Creating user login records"
|
||||
cp /dev/null /var/run/utmp
|
||||
if dir_writeable /var/log; then
|
||||
logw=true
|
||||
[ -e /var/log/wtmp ] || cp /dev/null /var/log/wtmp
|
||||
chmod 0644 /var/run/utmp /var/log/wtmp
|
||||
fi
|
||||
eend 0
|
||||
|
||||
ebegin "Cleaning /var/run"
|
||||
for x in $(find /var/run ! -type d ! -name utmp ! -name random-seed \
|
||||
! -name ld-elf.so.hints ! -name ld.so.hints);
|
||||
do
|
||||
[ ! -f "${x}" ] && continue
|
||||
# Do not remove pidfiles of already running daemons
|
||||
case "${x}" in
|
||||
*.pid)
|
||||
start-stop-daemon --test --quiet --stop \
|
||||
--pidfile "${x}"
|
||||
[ $? -eq 0 ] && continue
|
||||
ebegin "Cleaning /var/run"
|
||||
for x in $(find /var/run ! -type d ! -name utmp \
|
||||
! -name random-seed ! -name dev.db \
|
||||
! -name ld-elf.so.hints ! -name ld.so.hints);
|
||||
do
|
||||
# Clean stale sockets
|
||||
if [ -S "${x}" ] && type fuser >/dev/null 2>&1; then
|
||||
fuser -s "${x}" || rm "${x}"
|
||||
fi
|
||||
[ ! -f "${x}" ] && continue
|
||||
# Do not remove pidfiles of already running daemons
|
||||
case "${x}" in
|
||||
*.pid)
|
||||
start-stop-daemon --test --quiet \
|
||||
--stop --pidfile "${x}" && continue
|
||||
;;
|
||||
esac
|
||||
rm -f -- "${x}"
|
||||
done
|
||||
eend 0
|
||||
esac
|
||||
rm -f -- "${x}"
|
||||
done
|
||||
eend 0
|
||||
fi
|
||||
|
||||
# Clean up /tmp directories
|
||||
local tmp=
|
||||
for tmp in ${wipe_tmp_dirs-/tmp}; do
|
||||
cleanup_tmp_dir "${tmp}"
|
||||
done
|
||||
chmod +t /tmp /var/tmp
|
||||
|
||||
# Make sure our X11 stuff have the correct permissions
|
||||
# Omit the chown as bootmisc is run before network is up
|
||||
# and users may be using lame LDAP auth #139411
|
||||
rm -rf /tmp/.ICE-unix /tmp/.X11-unix
|
||||
mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
|
||||
chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
|
||||
[ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix
|
||||
if dir_writeable /tmp; then
|
||||
# Make sure our X11 stuff have the correct permissions
|
||||
# Omit the chown as bootmisc is run before network is up
|
||||
# and users may be using lame LDAP auth #139411
|
||||
rm -rf /tmp/.ICE-unix /tmp/.X11-unix
|
||||
mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
|
||||
chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
|
||||
[ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix
|
||||
fi
|
||||
|
||||
# Create an 'after-boot' dmesg log
|
||||
if [ "${RC_SYS}" != "VSERVER" -a "${RC_SYS}" != "OPENVZ" ]; then
|
||||
dmesg > /var/log/dmesg
|
||||
chmod 640 /var/log/dmesg
|
||||
if ${logw} || dir_writeable /var/log; then
|
||||
# Create an 'after-boot' dmesg log
|
||||
if [ "${RC_SYS}" != "VSERVER" -a "${RC_SYS}" != "OPENVZ" ]; then
|
||||
dmesg > /var/log/dmesg
|
||||
chmod 640 /var/log/dmesg
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f /etc/nologin
|
||||
return 0
|
||||
}
|
||||
|
||||
stop()
|
||||
|
||||
@@ -6,8 +6,7 @@ description="Sets a font for the consoles."
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need keymaps # sets up terminal encoding scheme
|
||||
need localmount termencoding
|
||||
after hotplug
|
||||
keyword noopenvz noprefix nouml novserver noxenu
|
||||
}
|
||||
@@ -34,7 +33,7 @@ start()
|
||||
return 0
|
||||
fi
|
||||
|
||||
local x= param= sf_param= retval=0 ttydev=
|
||||
local x= param= sf_param= retval=0 ttydev=/dev/tty
|
||||
|
||||
# Get additional parameters
|
||||
if [ -n "${consoletranslation}" ]; then
|
||||
@@ -45,11 +44,8 @@ start()
|
||||
fi
|
||||
|
||||
# Set the console font
|
||||
ebegin "Setting user font"
|
||||
[ -d /dev/vc ] \
|
||||
&& ttydev=/dev/vc/ \
|
||||
|| ttydev=/dev/tty
|
||||
|
||||
ebegin "Setting console font [${consolefont}]"
|
||||
[ -d /dev/vc ] && ttydev=/dev/vc/
|
||||
x=1
|
||||
while [ ${x} -le ${ttyn} ]; do
|
||||
setfont ${consolefont} ${param} -C ${ttydev}${x} >/dev/null
|
||||
@@ -61,17 +57,17 @@ start()
|
||||
# Store the last font so we can use it ASAP on boot
|
||||
if [ ${retval} -eq 0 -a -w "${RC_LIBDIR}" ]; then
|
||||
mkdir -p "${RC_LIBDIR}"/console
|
||||
|
||||
for font in /usr/share/consolefonts/"${consolefont}".*; do
|
||||
:
|
||||
done
|
||||
cp "${font}" "${RC_LIBDIR}"/console
|
||||
echo "${font##*/}" > "${RC_LIBDIR}"/console/font
|
||||
if yesno ${unicode:-${UNICODE}}; then
|
||||
cp /dev/null "${RC_LIBDIR}"/console/unicode
|
||||
echo "" > "${RC_LIBDIR}"/console/unicode
|
||||
else
|
||||
rm -f "${RC_LIBDIR}"/console/unicode
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
return ${retval}
|
||||
|
||||
21
init.d/devdb.in
Normal file
21
init.d/devdb.in
Normal file
@@ -0,0 +1,21 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2008 Roy Marples <roy@marples.name>
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
description="Creates the dev database"
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
ebegin "Bulding the dev database"
|
||||
if [ /var/run/dev.db -nt /dev ]; then
|
||||
:
|
||||
else
|
||||
dev_mkdb
|
||||
fi
|
||||
eend $?
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
description="Check and repair filesystems according to /etc/fstab"
|
||||
_ISF="
|
||||
_IFS="
|
||||
"
|
||||
|
||||
depend()
|
||||
@@ -27,20 +27,32 @@ _reboot() {
|
||||
|
||||
start()
|
||||
{
|
||||
local reboot_opts= fsck_opts= p=
|
||||
local reboot_opts= fsck_opts= p= check_extra=
|
||||
|
||||
ebegin "Checking local filesystems"
|
||||
if [ -e /fastboot ]; then
|
||||
ewarn "Skipping fsck due to /fastboot"
|
||||
return 0
|
||||
fi
|
||||
if [ -e /forcefsck ] || get_bootparam forcefsck; then
|
||||
fsck_opts="${fsck_opts} -f"
|
||||
check_extra="(check forced)"
|
||||
fi
|
||||
|
||||
if [ -n "${fsck_passno}" ]; then
|
||||
check_extra="[passno ${fsck_passno}] ${check_extra}"
|
||||
fi
|
||||
ebegin "Checking local filesystems ${check_extra}"
|
||||
for p in ${fsck_passno}; do
|
||||
local IFS="${_IFS}"
|
||||
case "${p}" in
|
||||
[0-9]*) p="=${p}";;
|
||||
esac
|
||||
set -- "$@" "$(fstabinfo --passno "${p}")"
|
||||
set -- "$@" $(fstabinfo --passno "${p}")
|
||||
unset IFS
|
||||
done
|
||||
|
||||
if [ "${RC_UNAME}" = "Linux" ]; then
|
||||
fsck_opts="-C0 -T"
|
||||
fsck_opts="${fsck_opts} -C0 -T"
|
||||
if [ -z "${fsck_passno}" ]; then
|
||||
fsck_args=${fsck_args--A -p}
|
||||
if echo 2>/dev/null >/.test.$$; then
|
||||
@@ -51,7 +63,7 @@ start()
|
||||
reboot_opts="-f"
|
||||
fi
|
||||
|
||||
trap : QUIT
|
||||
trap : INT QUIT
|
||||
fsck ${fsck_args--p} ${fsck_opts} "$@"
|
||||
case $? in
|
||||
0) eend 0; return 0;;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
. @SYSCONFDIR@/init.d/functions.sh
|
||||
. "${RC_LIBDIR}"/sh/rc-functions.sh
|
||||
[ -r @SYSCONFDIR@/conf.d/localmount ] && . @SYSCONFDIR@/conf.d/localmount
|
||||
[ -r @SYSCONFDIR@/rc.conf ] && . @SYSCONFDIR@/rc.conf
|
||||
|
||||
# Support LiveCD foo
|
||||
@@ -28,6 +29,7 @@ sync; sync
|
||||
# 1) we don't need (and by default can't) umount anything (VServer) or
|
||||
# 2) the host utils take care of all umounting stuff (OpenVZ)
|
||||
if [ "${RC_SYS}" = "VSERVER" -o "${RC_SYS}" = "OPENVZ" ]; then
|
||||
[ "${RC_SYS}" = "OPENVZ" -a "$1" = "reboot" ] && echo "" > /reboot
|
||||
if [ -e @SYSCONFDIR@/init.d/"$1".sh ]; then
|
||||
. @SYSCONFDIR@/init.d/"$1".sh
|
||||
else
|
||||
@@ -37,7 +39,11 @@ fi
|
||||
|
||||
# If $svcdir is still mounted, preserve it if we can
|
||||
mnt=$(mountinfo --node "${RC_SVCDIR}")
|
||||
if [ -n "${mnt}" -a -w "${RC_LIBDIR}" ]; then
|
||||
if [ -n "${mnt}" ] && \
|
||||
rm -rf "${RC_LIBDIR}/tmp.$$" && \
|
||||
mkdir -p "${RC_LIBDIR}/tmp.$$" 2>/dev/null \
|
||||
; then
|
||||
rmdir "${RC_LIBDIR}/tmp.$$"
|
||||
f_opts="-m -c"
|
||||
[ "${RC_UNAME}" = "Linux" ] && f_opts="-c"
|
||||
if type fuser >/dev/null 2>&1; then
|
||||
@@ -74,13 +80,27 @@ if [ "${RC_UNAME}" = "Linux" ]; then
|
||||
# We need the do_unmount function
|
||||
. "${RC_LIBDIR}"/sh/rc-mount.sh
|
||||
eindent
|
||||
no_umounts_r="/dev|/dev/.*|${RC_SVCDIR}"
|
||||
# RC_NO_UMOUNTS is an env var that can be set by plugins
|
||||
OIFS=${IFS} SIFS=${IFS-y}
|
||||
IFS=$IFS:
|
||||
for x in ${no_umounts} ${RC_NO_UMOUNTS}; do
|
||||
no_umounts_r="${no_umounts_r}|${x}"
|
||||
done
|
||||
if [ "${SIFS}" = "y" ]; then
|
||||
IFS=$OIFS
|
||||
else
|
||||
unset IFS
|
||||
fi
|
||||
no_umounts_r="${no_umounts_r}|/proc|/proc/.*|/sys|/sys/.*"
|
||||
no_umounts_r="^(${no_umounts_r})$"
|
||||
fs=
|
||||
for x in ${net_fs_list}; do
|
||||
fs="${fs}${fs:+|}${x}"
|
||||
done
|
||||
[ -n "${fs}" ] && fs="^(${fs})$"
|
||||
do_unmount "mount -n -o remount,ro" \
|
||||
--skip-point-regex "^(/dev|/dev/.*|/proc|/proc/.*|/sys|/sys/.*)$" \
|
||||
--skip-point-regex "${no_umounts_r}" \
|
||||
${fs:+--skip-fstype-regex} ${fs} --nonetdev
|
||||
eoutdent
|
||||
eend $?
|
||||
|
||||
@@ -74,8 +74,12 @@ start()
|
||||
fi
|
||||
|
||||
ebegin "Setting system clock using the hardware clock [${utc}]"
|
||||
if [ -e /proc/modules -a ! -e /dev/rtc ]; then
|
||||
modprobe -q rtc || modprobe -q genrtc
|
||||
local rtc=
|
||||
for rtc in /dev/rtc /dev/rtc[0-9]*; do
|
||||
[ -e "${rtc}" ] && break
|
||||
done
|
||||
if [ ! -e "${rtc}" -a -e /proc/modules ]; then
|
||||
modprobe -q rtc-cmos || modprobe -q rtc || modprobe -q genrtc
|
||||
fi
|
||||
|
||||
if [ -e /etc/adjtime ] && yesno ${clock_adjfile}; then
|
||||
|
||||
@@ -20,6 +20,10 @@ ipfw() {
|
||||
/sbin/ipfw -f -q "$@"
|
||||
}
|
||||
|
||||
have_ip6() {
|
||||
sysctl net.ipv6 2>/dev/null
|
||||
}
|
||||
|
||||
init() {
|
||||
# Load the kernel module
|
||||
if ! sysctl net.inet.ip.fw.enable=1 >/dev/null 2>&1; then
|
||||
@@ -36,13 +40,15 @@ init() {
|
||||
ipfw add deny all from any to 127.0.0.0/8
|
||||
ipfw add deny ip from 127.0.0.0/8 to any
|
||||
|
||||
ipfw add pass ip6 from any to any via lo0
|
||||
ipfw add deny ip6 from any to ::1
|
||||
ipfw add deny ip6 from ::1 to any
|
||||
if have_ip6; then
|
||||
ipfw add pass ip6 from any to any via lo0
|
||||
ipfw add deny ip6 from any to ::1
|
||||
ipfw add deny ip6 from ::1 to any
|
||||
|
||||
ipfw add pass ip6 from :: to ff02::/16 proto ipv6-icmp
|
||||
ipfw add pass ip6 from fe80::/10 to fe80::/10 proto ipv6-icmp
|
||||
ipfw add pass ip6 from fe80::/10 to ff02::/16 proto ipv6-icmp
|
||||
ipfw add pass ip6 from :: to ff02::/16 proto ipv6-icmp
|
||||
ipfw add pass ip6 from fe80::/10 to fe80::/10 proto ipv6-icmp
|
||||
ipfw add pass ip6 from fe80::/10 to ff02::/16 proto ipv6-icmp
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
@@ -62,9 +68,11 @@ start() {
|
||||
ipfw add pass udp from me to any keep-state
|
||||
ipfw add pass icmp from me to any keep-state
|
||||
|
||||
ipfw add pass tcp from me6 to any setup keep-state
|
||||
ipfw add pass udp from me6 to any keep-state
|
||||
ipfw add pass icmp from me6 to any keep-state
|
||||
if have_ip6; then
|
||||
ipfw add pass tcp from me6 to any setup keep-state
|
||||
ipfw add pass udp from me6 to any keep-state
|
||||
ipfw add pass icmp from me6 to any keep-state
|
||||
fi
|
||||
|
||||
# Allow DHCP.
|
||||
ipfw add pass udp from 0.0.0.0 68 to 255.255.255.255 67 out
|
||||
@@ -77,11 +85,13 @@ start() {
|
||||
# Allow "mandatory" ICMP in.
|
||||
ipfw add pass icmp from any to any icmptype 3,4,11
|
||||
|
||||
# Allow ICMPv6 destination unreach
|
||||
ipfw add pass ip6 from any to any icmp6types 1 proto ipv6-icmp
|
||||
|
||||
# Allow NS/NA/toobig (don't filter it out)
|
||||
ipfw add pass ip6 from any to any icmp6types 2,135,136 proto ipv6-icmp
|
||||
if have_ip6; then
|
||||
# Allow ICMPv6 destination unreach
|
||||
ipfw add pass ip6 from any to any icmp6types 1 proto ipv6-icmp
|
||||
|
||||
# Allow NS/NA/toobig (don't filter it out)
|
||||
ipfw add pass ip6 from any to any icmp6types 2,135,136 proto ipv6-icmp
|
||||
fi
|
||||
|
||||
# Add permits for this workstations published services below
|
||||
# Only IPs and nets in firewall_allowservices is allowed in.
|
||||
|
||||
@@ -8,13 +8,13 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
|
||||
unicode=${unicode:-${UNICODE}}
|
||||
keymap=${keymap:-${KEYMAP}}
|
||||
extended_keymaps=${extended_keymaps:-${EXTENDED_KEYMAPS}}
|
||||
windowskeys=${windowskeys:-${SET_WINDOWSKEYS}}
|
||||
windowkeys=${windowkeys:-${SET_WINDOWSKEYS}}
|
||||
fix_euro=${fix_euro:-${FIX_EURO}}
|
||||
dumpkeys_charset=${dumpkeys_charset:-${DUMPKEYS_CHARSET}}
|
||||
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
need localmount termencoding
|
||||
keyword noopenvz noprefix nouml novserver noxenu
|
||||
}
|
||||
|
||||
@@ -25,43 +25,41 @@ start()
|
||||
return 1
|
||||
fi
|
||||
|
||||
local ttydev= n=
|
||||
[ -d /dev/vc ] \
|
||||
&& ttydev=/dev/vc/ \
|
||||
|| ttydev=/dev/tty
|
||||
local ttydev=/dev/tty n=
|
||||
[ -d /dev/vc ] && ttydev=/dev/vc/
|
||||
|
||||
# Force linux keycodes for PPC.
|
||||
if [ -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ]; then
|
||||
echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes
|
||||
fi
|
||||
|
||||
ebegin "Loading key mappings"
|
||||
local loadkeys_uni= wkeys=
|
||||
yesno ${unicode} && loadkeys_uni="--unicode"
|
||||
yesno ${windowskeys} && wkeys="windowkeys"
|
||||
ebegin "Loading key mappings [${keymap}]"
|
||||
local loadkeys_uni= wkeys= kmode="-a" msg="ASCII"
|
||||
if yesno ${unicode}; then
|
||||
loadkeys_uni="--unicode"
|
||||
kmode="-u"
|
||||
msg="UTF-8"
|
||||
fi
|
||||
yesno ${windowkeys} && wkeys="windowkeys"
|
||||
loadkeys -q ${loadkeys_uni} ${wkeys} ${keymap} ${extended_keymaps}
|
||||
eend $? "Error loading key mappings" || return $?
|
||||
|
||||
if yesno ${fix_euro}; then
|
||||
ebegin "Fixing font for euro symbol"
|
||||
# Fix some fonts displaying the Euro, #173528.
|
||||
echo "altgr keycode 18 = U+20AC" | loadkeys -q
|
||||
eend $?
|
||||
fi
|
||||
|
||||
# Set terminal encoding to either ASCII or UNICODE.
|
||||
# See utf-8(7) for more information.
|
||||
local termencoding="%@" termmsg="ASCII" kmode="-a"
|
||||
ebegin "Setting keyboard mode [${msg}]"
|
||||
if yesno ${unicode}; then
|
||||
dumpkeys ${dumpkeys_charset:+-c} \
|
||||
${dumpkeys_charset} | loadkeys --unicode
|
||||
termencoding="%G"
|
||||
termmsg="UTF-8"
|
||||
kmode="-u"
|
||||
fi
|
||||
|
||||
ebegin "Setting terminal encoding to" ${termmsg}
|
||||
n=1
|
||||
while [ ${n} -le "${ttyn}" ]; do
|
||||
printf "\033%s" "${termencoding}" >"${ttydev}${n}"
|
||||
kbd_mode "${kmode}" -C "${ttydev}${n}"
|
||||
n=$((${n} + 1))
|
||||
done
|
||||
|
||||
@@ -30,13 +30,13 @@ start()
|
||||
stop()
|
||||
{
|
||||
# We never unmount / or /dev or $RC_SVCDIR
|
||||
local x= no_umounts="/|/dev|/dev/.*|${RC_SVCDIR}"
|
||||
local x= no_umounts_r="/|/dev|/dev/.*|${RC_SVCDIR}"
|
||||
|
||||
# RC_NO_UMOUNTS is an env var that can be set by plugins
|
||||
OIFS=${IFS} SIFS=${IFS-y}
|
||||
IFS=$IFS:
|
||||
for x in ${no_umounts} ${RC_NO_UMOUNTS}; do
|
||||
no_umounts="${no_umounts}|${x}"
|
||||
no_umounts_r="${no_umounts_r}|${x}"
|
||||
done
|
||||
if [ "${SIFS}" = "y" ]; then
|
||||
IFS=$OIFS
|
||||
@@ -45,9 +45,9 @@ stop()
|
||||
fi
|
||||
|
||||
if [ "${RC_UNAME}" = "Linux" ]; then
|
||||
no_umounts="${no_umounts}|/proc|/proc/.*|/sys|/sys/.*"
|
||||
no_umounts_r="${no_umounts_r}|/proc|/proc/.*|/sys|/sys/.*"
|
||||
fi
|
||||
no_umounts="^(${no_umounts})$"
|
||||
no_umounts_r="^(${no_umounts_r})$"
|
||||
|
||||
# Flush all pending disk writes now
|
||||
sync; sync
|
||||
@@ -63,7 +63,7 @@ stop()
|
||||
# Umount loopback devices
|
||||
einfo "Unmounting loopback devices"
|
||||
eindent
|
||||
do_unmount "umount -d" --skip-point-regex "${no_umounts}" \
|
||||
do_unmount "umount -d" --skip-point-regex "${no_umounts_r}" \
|
||||
--node-regex "^/dev/loop"
|
||||
eoutdent
|
||||
|
||||
@@ -76,7 +76,7 @@ stop()
|
||||
fs="${fs}${fs:+|}${x}"
|
||||
done
|
||||
[ -n "${fs}" ] && fs="^(${fs})$"
|
||||
do_unmount "umount" --skip-point-regex "${no_umounts}" \
|
||||
do_unmount "umount" --skip-point-regex "${no_umounts_r}" \
|
||||
${fs:+--skip-fstype-regex} ${fs} --nonetdev
|
||||
eoutdent
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ start()
|
||||
x=${KV#*.*.}
|
||||
local KV_MICRO=${x%%-*}
|
||||
|
||||
local list= x= xx= y= args= cnt=0
|
||||
local list= x= xx= y= args= mpargs= cnt=0 a=
|
||||
for x in "${KV}" \
|
||||
${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \
|
||||
${KV_MAJOR}.${KV_MINOR} \
|
||||
@@ -34,17 +34,29 @@ start()
|
||||
[ -z "${list}" ] && list=${modules}
|
||||
|
||||
for x in ${list}; do
|
||||
ebegin "Loading module ${x}"
|
||||
a=${x#*:}
|
||||
if [ "${a}" = "${x}" ]; then
|
||||
unset mpargs
|
||||
ebegin "Loading module ${x}"
|
||||
else
|
||||
x=${x%%:*}
|
||||
mpargs="-o ${a}"
|
||||
ebegin "Loading module ${x} as ${a}"
|
||||
fi
|
||||
aa=$(shell_var "${a}")
|
||||
xx=$(shell_var "${x}")
|
||||
for y in "${KV}" \
|
||||
${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \
|
||||
${KV_MAJOR}.${KV_MINOR} \
|
||||
; do
|
||||
eval args=\$module_${aa}_args_$(shell_var "${y}")
|
||||
[ -n "${args}" ] && break
|
||||
eval args=\$module_${xx}_args_$(shell_var "${y}")
|
||||
[ -n "${args}" ] && break
|
||||
done
|
||||
[ -z "${args}" ] && eval args=\$module_${aa}_args
|
||||
[ -z "${args}" ] && eval args=\$module_${xx}_args
|
||||
eval modprobe -q "${x}" "${args}"
|
||||
eval modprobe -q "${mpargs}" "${x}" "${args}"
|
||||
eend $? "Failed to load ${x}" && cnt=$((${cnt} + 1))
|
||||
done
|
||||
einfo "Autoloaded ${cnt} module(s)"
|
||||
|
||||
@@ -28,7 +28,7 @@ depend()
|
||||
*) after net.lo net.lo0;;
|
||||
esac
|
||||
|
||||
if type depend_${IFVAR} >/dev/null 2>&1; then
|
||||
if [ "$(command -v "depend_${IFVAR}")" = "depend_${IFVAR}" ]; then
|
||||
depend_${IFVAR}
|
||||
fi
|
||||
|
||||
@@ -344,7 +344,7 @@ _load_modules()
|
||||
# Wrap our provides
|
||||
local f=
|
||||
for f in pre_start start post_start; do
|
||||
eval "${provides}_${f}() { type ${mod}_${f} >/dev/null 2>&1 || return 0; ${mod}_${f} \"\$@\"; }"
|
||||
eval "${provides}_${f}() { [ "$(command -v "${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }"
|
||||
done
|
||||
|
||||
eval module_${mod}_provides="${provides}"
|
||||
@@ -358,7 +358,7 @@ _load_modules()
|
||||
eval x=\$module_${mod}_provides
|
||||
[ -z "${x}" ] && continue
|
||||
for f in pre_start start post_start; do
|
||||
eval "${x}_${f}() { type ${mod}_${f} >/dev/null 2>&1 || return 0; ${mod}_${f} \"\$@\"; }"
|
||||
eval "${x}_${f}() { [ "$(command -v "${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }"
|
||||
done
|
||||
eval module_${x}_providedby="${mod}"
|
||||
;;
|
||||
@@ -462,7 +462,7 @@ start()
|
||||
# We up the iface twice if we have a preup to ensure it's up if
|
||||
# available in preup and afterwards incase the user inadvertently
|
||||
# brings it down
|
||||
if type preup >/dev/null 2>&1; then
|
||||
if [ "$(command -v preup)" = "preup" ]; then
|
||||
_up 2>/dev/null
|
||||
ebegin "Running preup"
|
||||
eindent
|
||||
@@ -473,7 +473,7 @@ start()
|
||||
_up 2>/dev/null
|
||||
|
||||
for module in ${MODULES}; do
|
||||
if type "${module}_pre_start" >/dev/null 2>&1; then
|
||||
if [ "$(command -v "${module}_pre_start")" = "${module}_pre_start" ]; then
|
||||
${module}_pre_start || exit $?
|
||||
fi
|
||||
done
|
||||
@@ -522,7 +522,7 @@ start()
|
||||
null) :;;
|
||||
[0-9]*|*:*) _add_address ${config};;
|
||||
*)
|
||||
if type "${config}_start" >/dev/null 2>&1; then
|
||||
if [ "$(command -v "${config}_start")" = "${config}_start" ]; then
|
||||
"${config}"_start
|
||||
else
|
||||
eerror "nothing provides \`${config}'"
|
||||
@@ -547,7 +547,7 @@ start()
|
||||
done
|
||||
|
||||
if ! ${oneworked}; then
|
||||
if type failup >/dev/null 2>&1; then
|
||||
if [ "$(command -v failup)" = "failup" ]; then
|
||||
ebegin "Running failup"
|
||||
eindent
|
||||
failup
|
||||
@@ -600,12 +600,12 @@ ${routes}"
|
||||
fi
|
||||
|
||||
for module in ${MODULES}; do
|
||||
if type "${module}_post_start" >/dev/null 2>&1; then
|
||||
if [ "$(command -v "${module}_post_start")" = "${module}_post_start" ]; then
|
||||
${module}_post_start || exit $?
|
||||
fi
|
||||
done
|
||||
|
||||
if type postup >/dev/null 2>&1; then
|
||||
if [ "$(command -v postup)" = "postup" ]; then
|
||||
ebegin "Running postup"
|
||||
eindent
|
||||
postup
|
||||
@@ -628,7 +628,7 @@ stop()
|
||||
_load_modules false
|
||||
fi
|
||||
|
||||
if type predown >/dev/null 2>&1; then
|
||||
if [ "$(command -v predown)" = "predown" ]; then
|
||||
ebegin "Running predown"
|
||||
eindent
|
||||
predown || return 1
|
||||
@@ -641,35 +641,40 @@ stop()
|
||||
fi
|
||||
|
||||
for module in ${MODULES}; do
|
||||
if type "${module}_pre_stop" >/dev/null 2>&1; then
|
||||
if [ "$(command -v "${module}_pre_stop")" = "${module}_pre_stop" ]; then
|
||||
${module}_pre_stop || exit $?
|
||||
fi
|
||||
done
|
||||
|
||||
for module in ${MODULES}; do
|
||||
if type "${module}_stop" >/dev/null 2>&1; then
|
||||
if [ "$(command -v "${module}_stop")" = "${module}_stop" ]; then
|
||||
${module}_stop
|
||||
fi
|
||||
done
|
||||
|
||||
# Only delete addresses for non PPP interfaces
|
||||
if ! type is_ppp >/dev/null 2>&1 || ! is_ppp; then
|
||||
if ! [ "$(command -v is_ppp)" = "is_ppp" ] || ! is_ppp; then
|
||||
_delete_addresses "${IFACE}"
|
||||
fi
|
||||
|
||||
for module in ${MODULES}; do
|
||||
if type "${module}_post_stop" >/dev/null 2>&1; then
|
||||
if [ "$(command -v "${module}_post_stop")" = "${module}_post_stop" ]; then
|
||||
${module}_post_stop
|
||||
fi
|
||||
done
|
||||
|
||||
! yesno ${IN_BACKGROUND} && \
|
||||
[ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ] && \
|
||||
_down 2>/dev/null
|
||||
# If not in background, and not loopback then bring the interface down
|
||||
# unless overridden.
|
||||
if ! yesno ${IN_BACKGROUND} && \
|
||||
[ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
|
||||
eval module=\$ifdown_${IFVAR}
|
||||
module=${module:-${ifdown:-YES}}
|
||||
yesno ${module} && _down 2>/dev/null
|
||||
fi
|
||||
|
||||
type resolvconf >/dev/null 2>&1 && resolvconf -d "${IFACE}" 2>/dev/null
|
||||
|
||||
if type postdown >/dev/null 2>&1; then
|
||||
if [ "$(command -v "postdown")" = "postdown" ]; then
|
||||
ebegin "Running postdown"
|
||||
eindent
|
||||
postdown
|
||||
@@ -23,18 +23,19 @@ depend()
|
||||
{
|
||||
# Only have portmap as a dependency if there is a nfs mount in fstab
|
||||
# that is set to mount at boot
|
||||
local pmap=""
|
||||
local pmap=
|
||||
if need_portmap; then
|
||||
pmap="${pmap} rpc.statd"
|
||||
pmap="rpc.statd"
|
||||
[ -x @SYSCONFDIR@/init.d/rpcbind ] \
|
||||
&& pmap="rpcbind" \
|
||||
|| pmap="portmap"
|
||||
&& pmap="${pmap} rpcbind" \
|
||||
|| pmap="${pmap} portmap"
|
||||
fi
|
||||
|
||||
config /etc/fstab
|
||||
need net ${pmap}
|
||||
use afc-client amd autofs dns nfs nfsmount portmap rpcbind rpc.statd
|
||||
keyword nojail noopenvz noprefix novserver
|
||||
use afc-client amd autofs openvpn
|
||||
use dns nfs nfsmount portmap rpcbind rpc.statd rpc.lockd
|
||||
keyword nojail noprefix novserver
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
@@ -26,7 +26,7 @@ start()
|
||||
local usbfs=$(grep -Fow usbfs /proc/filesystems ||
|
||||
grep -Fow usbdevfs /proc/filesystems)
|
||||
if [ -n "${usbfs}" ]; then
|
||||
ebegin "Mounting USB device filesystem (${usbfs})"
|
||||
ebegin "Mounting USB device filesystem [${usbfs}]"
|
||||
local usbgid="$(getent group usb | \
|
||||
sed -e 's/.*:.*:\(.*\):.*/\1/')"
|
||||
mount -t ${usbfs} \
|
||||
|
||||
@@ -13,7 +13,7 @@ depend()
|
||||
start()
|
||||
{
|
||||
if echo 2>/dev/null >/.test.$$; then
|
||||
rm -f /.test.$$
|
||||
rm -f /.test.$$ /fastboot /forcefsck
|
||||
return 0
|
||||
fi
|
||||
|
||||
@@ -22,5 +22,7 @@ start()
|
||||
Linux) mount -n -o remount,rw /;;
|
||||
*) mount -u -o rw /;;
|
||||
esac
|
||||
eend $? "Root filesystem could not be mounted read/write"
|
||||
if eend $? "Root filesystem could not be mounted read/write"; then
|
||||
rm -f /fastboot /forcefsck
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@ start() {
|
||||
|
||||
local v= f=
|
||||
for v in font8x16 font8x14 font8x8; do
|
||||
f=$(eval \$"${v}")
|
||||
eval f=\$${v}
|
||||
if [ -n "${f}" ]; then
|
||||
ebegin "Setting font ${f}"
|
||||
vidcontrol -f ${v##FONT} ${f}
|
||||
vidcontrol -f ${v##font} ${f}
|
||||
eend $?
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -6,7 +6,7 @@ depend()
|
||||
{
|
||||
use hostname
|
||||
before bootmisc logger
|
||||
keyword noprefix
|
||||
keyword noopenvz noprefix novserver
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
35
init.d/termencoding.in
Normal file
35
init.d/termencoding.in
Normal file
@@ -0,0 +1,35 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 2008 Roy Marples <roy@marples.name>
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
description="Configures terminal encoding."
|
||||
|
||||
ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
|
||||
unicode=${unicode:-${UNICODE}}
|
||||
|
||||
depend()
|
||||
{
|
||||
keyword noopenvz noprefix nouml novserver noxenu
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
local ttydev=/dev/tty n=
|
||||
[ -d /dev/vc ] && ttydev=/dev/vc/
|
||||
|
||||
# Set terminal encoding to either ASCII or UNICODE.
|
||||
# See utf-8(7) for more information.
|
||||
local termencoding="%@" termmsg="ASCII"
|
||||
if yesno ${unicode}; then
|
||||
termencoding="%G"
|
||||
termmsg="UTF-8"
|
||||
fi
|
||||
|
||||
ebegin "Setting terminal encoding [${termmsg}]"
|
||||
n=1
|
||||
while [ ${n} -le "${ttyn}" ]; do
|
||||
printf "\033%s" "${termencoding}" >"${ttydev}${n}"
|
||||
n=$((${n} + 1))
|
||||
done
|
||||
eend 0
|
||||
}
|
||||
@@ -202,4 +202,4 @@ Rinse and repeat for the other verbose functions.
|
||||
.Sh SEE ALSO
|
||||
.Xr printf 3 ,
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples <roy@marples.name>
|
||||
|
||||
@@ -61,4 +61,4 @@ does the same and also prints the full path of the service to stdout.
|
||||
.Xr rc 8 ,
|
||||
.Xr stdout 3
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd Feb 22, 2008
|
||||
.Dd Arp 9, 2008
|
||||
.Dt RC-STATUS 8 SMM
|
||||
.Os OpenRC
|
||||
.Sh NAME
|
||||
@@ -36,7 +36,8 @@
|
||||
.Nm
|
||||
gathers and displays information about the status of services
|
||||
in different runlevels. The default behavior is to show information
|
||||
about the current runlevel, but any runlevel can be quickly examined.
|
||||
about the current runlevel and any unassgined services that are not stopped,
|
||||
but any runlevel can be quickly examined.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width ".Fl test , test string"
|
||||
@@ -60,4 +61,4 @@ Show information only for the named
|
||||
.Xr rc 8 ,
|
||||
.Xr rc-update 8
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
@@ -77,4 +77,4 @@ Show all services.
|
||||
.Xr rc 8 ,
|
||||
.Xr rc-status 8
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
2
man/rc.8
2
man/rc.8
@@ -74,4 +74,4 @@ Changes to the single runlevel and then halts the host.
|
||||
.Xr rc-status 8 ,
|
||||
.Xr rc-update 8
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples <roy@marples.name>
|
||||
|
||||
@@ -70,4 +70,4 @@ is set to
|
||||
.Xr rc_stringlist_free 3 ,
|
||||
.Xr sh 1
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
@@ -110,4 +110,4 @@ when done.
|
||||
.Xr rc_stringlist_free 3 ,
|
||||
.Xr runscript 8
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
@@ -67,4 +67,4 @@ Each RC_PID should be freed in the list as well as the list itself when done.
|
||||
.Xr free 3 ,
|
||||
.Xr queue 3
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
@@ -48,4 +48,4 @@ Plugins can affect the parent environemnt by writing NULL separated strings to
|
||||
.Xr rc 8 ,
|
||||
.Xr runscript 8
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
@@ -63,4 +63,4 @@ Rinse and repeat for the other verbose functions.
|
||||
.Xr free 3
|
||||
.Xr rc_stringlist_free 3
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
@@ -31,11 +31,10 @@
|
||||
.Nm rc_service_mark , rc_service_extra_commands , rc_service_plugable ,
|
||||
.Nm rc_service_resolve , rc_service_schedule_start , rc_services_scheduled_by ,
|
||||
.Nm rc_service_schedule_clear , rc_service_state ,
|
||||
.Nm rc_service_start , rc_service_stop ,
|
||||
.Nm rc_service_started_daemon , rc_service_value_get , rc_service_value_set ,
|
||||
.Nm rc_services_in_runlevel , rc_services_in_state , rc_services_scheduled ,
|
||||
.Nm rc_service_daemons_crashed
|
||||
.Nd functions to start, stop and query OpenRC services
|
||||
.Nd functions to query OpenRC services
|
||||
.Sh LIBRARY
|
||||
Run Command library (librc, -lrc)
|
||||
.Sh SYNOPSIS
|
||||
@@ -66,8 +65,6 @@ Run Command library (librc, -lrc)
|
||||
.Ft "RC_STRINGLIST *" Fn rc_services_scheduled_by "const char *service"
|
||||
.Ft bool Fn rc_service_schedule_clear "const char *service"
|
||||
.Ft RC_SERVICE Fn rc_service_state "const char *service"
|
||||
.Ft pid_t Fn rc_service_start "const char *service"
|
||||
.Ft pid_t Fn rc_service_stop "const char *service"
|
||||
.Ft bool Fo rc_service_started_daemon
|
||||
.Fa "const char *service"
|
||||
.Fa "const char *exec"
|
||||
@@ -176,16 +173,6 @@ clears these scheduled services for
|
||||
.Fa service .
|
||||
The return value is a bitmask, where more than one state can apply.
|
||||
.Pp
|
||||
.Fn rc_service_start
|
||||
starts
|
||||
.Fa service ,
|
||||
returning the pid of new process.
|
||||
.Pp
|
||||
.Fn rc_service_stop
|
||||
stops
|
||||
.Fa service ,
|
||||
returning the pid of new process.
|
||||
.Pp
|
||||
.Fn rc_service_started_daemon
|
||||
checks to see if
|
||||
.Fa service
|
||||
@@ -240,4 +227,4 @@ normally holds the volatile state data for services on a RAM backed disk.
|
||||
.Xr rc_stringlist_free 3 ,
|
||||
.Xr start-stop-daemon 8
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
@@ -85,4 +85,4 @@ itself.
|
||||
.Xr queue 3 ,
|
||||
.Xr strcmp 3
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd Mar 19, 2008
|
||||
.Dd September 19, 2008
|
||||
.Dt RUNSCRIPT 8 SMM
|
||||
.Os OpenRC
|
||||
.Sh NAME
|
||||
@@ -173,8 +173,9 @@ If
|
||||
does not equal 0 then output the string using
|
||||
.Ic eerror
|
||||
and !! in square brackets
|
||||
at the end of the line. Otherwise output ok in square brackets at the end of
|
||||
the line. The value of
|
||||
at the end of the line.
|
||||
Otherwise output ok in square brackets at the end of the line.
|
||||
The value of
|
||||
.Ar retval
|
||||
is returned.
|
||||
.It Ic ewend Ar retval Op Ar string
|
||||
@@ -193,6 +194,14 @@ output when the environment variable
|
||||
.Va EINFO_VERBOSE
|
||||
is true.
|
||||
.Bl -tag -width indent
|
||||
.It Ic ewaitfile Ar timeout Ar file1 Ar file2 ...
|
||||
Wait for
|
||||
.Ar timeout
|
||||
seconds until all files exist.
|
||||
Returns 0 if all files exist, otherwise non zero.
|
||||
If
|
||||
.Ar timeout
|
||||
is less then 1 then we wait indefinitely.
|
||||
.It Ic is_newer_than Ar file1 Ar file2 ...
|
||||
If
|
||||
.Ar file1
|
||||
@@ -205,7 +214,7 @@ is a directory, then check all it's contents too.
|
||||
.It Ic is_older_than Ar file1 Ar file2 ...
|
||||
If
|
||||
.Ar file1
|
||||
is older than
|
||||
is newer than
|
||||
.Ar file2
|
||||
return 0, otherwise 1.
|
||||
If
|
||||
@@ -432,6 +441,16 @@ show()
|
||||
}
|
||||
|
||||
.Ed
|
||||
.Sh BUGS
|
||||
Because of the way we load our configuration files and the need to handle
|
||||
more than one service directory, you can only use symlinks in service
|
||||
directories to other services in the same directory.
|
||||
You cannot symlink to a service in a different directory even if it is
|
||||
another service directory.
|
||||
.Pp
|
||||
is_older_than should return 0 on success.
|
||||
Instead we return 1 to be compliant with Gentoo baselayout.
|
||||
Users are encouraged to use the is_newer_than function which returns correctly.
|
||||
.Sh SEE ALSO
|
||||
.Xr einfo 3 ,
|
||||
.Xr rc 8 ,
|
||||
@@ -442,4 +461,4 @@ show()
|
||||
.Xr start-stop-daemon 8 ,
|
||||
.Xr uname 1
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd Feb 24, 2008
|
||||
.Dd September 27, 2008
|
||||
.Dt START-STOP-DAEMON 8 SMM
|
||||
.Os OpenRC
|
||||
.Sh NAME
|
||||
@@ -44,6 +44,11 @@
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
provides a consistent method of starting, stopping and signalling daemons.
|
||||
If neither
|
||||
.Fl K , -stop
|
||||
nor
|
||||
.Fl s , -signal
|
||||
are provided, then we assume we are starting the daemon.
|
||||
If a daemon cannot background by itself, nor create a pidfile,
|
||||
.Nm
|
||||
can do it for the daemon in a secure fashion.
|
||||
@@ -67,16 +72,8 @@ Here are the options to specify the daemon and how it should start or stop:
|
||||
The
|
||||
.Ar daemon
|
||||
we start or stop.
|
||||
If the
|
||||
.Ar daemon
|
||||
is a script and you are not using the pidfile or process name options,
|
||||
then you should replace
|
||||
.Ar daemon
|
||||
with the interpreter and pass
|
||||
.Ar daemon
|
||||
as an argument. Below is an example:
|
||||
.Pp
|
||||
start-stop-daemon -Sx /usr/bin/perl -- /usr/bin/daemon.pl
|
||||
If this option is not specified, then the first non option argument
|
||||
is used.
|
||||
.It Fl p , -pidfile Ar pidfile
|
||||
When starting, we expect the daemon to create a valid
|
||||
.Ar pidfile
|
||||
@@ -97,10 +94,17 @@ name here also.
|
||||
.It Fl t , -test
|
||||
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
|
||||
P
|
||||
Print the action(s) that are taken just before doing them.
|
||||
.El
|
||||
.Pp
|
||||
These options are only used for starting daemons:
|
||||
.Bl -tag -width indent
|
||||
.It Fl a , -startas Ar name
|
||||
Change the process name of the daemon to
|
||||
.Ar name .
|
||||
This just changes the first argument passed to the daemon.
|
||||
.It Fl b , -background
|
||||
Force the daemon into the background. Some daemons don't create pidfiles, so a
|
||||
good trick is to get the daemon to run in the foreground, and use the this
|
||||
@@ -116,6 +120,8 @@ as the path to the daemon, chdir and pidfile, should be relative to the chroot.
|
||||
Set the environment variable VAR to VALUE.
|
||||
.It Fl g , -group Ar group
|
||||
Start the daemon as in the group.
|
||||
.It Fl k , -umask Ar mode
|
||||
Set the umask of the daemon.
|
||||
.It Fl m , -make-pidfile
|
||||
Saves the pid of the daemon in the file specified by the
|
||||
.Fl p , -pidfile
|
||||
@@ -145,6 +151,16 @@ stopping schedule.
|
||||
If not specified then a default value of SIGTERM/5 is
|
||||
assumed.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
.Va SSD_NICELEVEL
|
||||
can also set the scheduling priority of the daemon, but the command line
|
||||
option takes precedence.
|
||||
.Pp
|
||||
.Va SSD_STARTWAIT
|
||||
overrides the number of milliseconds set in
|
||||
.Pa /etc/rc.conf
|
||||
.Nm
|
||||
waits for to check the daemon is still running.
|
||||
.Sh NOTE
|
||||
.Nm
|
||||
uses
|
||||
@@ -159,6 +175,9 @@ to stop or signal.
|
||||
.Xr getopt 3 ,
|
||||
.Xr nice 2 ,
|
||||
.Xr rc_find_pids 3
|
||||
.Sh BUGS
|
||||
.Nm
|
||||
cannot stop an interperted daemon that no longer exists without a pidfile.
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
first appeared in Debian.
|
||||
@@ -166,4 +185,4 @@ first appeared in Debian.
|
||||
This is a complete re-implementation with the process finding code in the
|
||||
OpenRC library (librc, -lrc) so other programs can make use of it.
|
||||
.Sh AUTHORS
|
||||
.An "Roy Marples" Aq roy@marples.name
|
||||
.An Roy Marples" <roy@marples.name>
|
||||
|
||||
31
mk/cc.mk
31
mk/cc.mk
@@ -1,5 +1,4 @@
|
||||
# Copyright 2008 Roy Marples <roy@marples.name>
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
# Setup some good default CFLAGS
|
||||
CFLAGS?= -O2
|
||||
@@ -10,15 +9,25 @@ _CSTD_SH= if test -n "${CSTD}"; then echo "-std=${CSTD}"; else echo ""; fi
|
||||
_CSTD!= ${_CSTD_SH}
|
||||
CFLAGS+= ${_CSTD}$(shell ${_CSTD_SH})
|
||||
|
||||
# Try and use some good cc flags
|
||||
_CC_FLAGS= -pedantic -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
|
||||
-Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
|
||||
-Wbad-function-cast -Wnested-externs -Wcomment -Winline \
|
||||
-Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
|
||||
-Wdeclaration-after-statement -Wsequence-point -Wextra
|
||||
_CC_FLAGS_SH= for f in ${_CC_FLAGS}; do \
|
||||
if ${CC} $$f -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
||||
# Try and use some good cc flags if we're building from git
|
||||
# We don't use -pedantic as it will warn about our perfectly valid
|
||||
# use of %m in our logger.
|
||||
_CCFLAGS= -Wall -Wextra -Wimplicit -Wshadow -Wformat=2 \
|
||||
-Wmissing-prototypes -Wmissing-declarations \
|
||||
-Wmissing-noreturn -Wmissing-format-attribute \
|
||||
-Wnested-externs \
|
||||
-Winline -Wwrite-strings -Wcast-align -Wcast-qual \
|
||||
-Wpointer-arith \
|
||||
-Wdeclaration-after-statement -Wsequence-point
|
||||
|
||||
# We should be using -Wredundant-decls, but our library hidden proto stuff
|
||||
# gives loads of warnings. I don't fully understand it (the hidden proto,
|
||||
# not the warning) so we just silence the warning.
|
||||
|
||||
_CC_FLAGS_SH= for f in ${_CCFLAGS}; do \
|
||||
if echo "int main(void) { return 0;} " | \
|
||||
${CC} $$f -S -xc -o /dev/null - ; \
|
||||
then printf "%s" "$$f "; fi \
|
||||
done
|
||||
done;
|
||||
_CC_FLAGS!= ${_CC_FLAGS_SH}
|
||||
CFLAGS+= ${_CC_FLAGS}$(shell ${CC_FLAGS_SH})
|
||||
CFLAGS+= ${_CC_FLAGS}$(shell ${_CC_FLAGS_SH})
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
_RC_DEBUG_SH= case "${DEBUG}" in "") echo "";; *) echo "-DRC_DEBUG";; esac
|
||||
_RC_DEBUG!= ${_RC_DEBUG_SH}
|
||||
CFLAGS+= ${_RC_DEBUG}$(shell ${_RC_DEBUG_SH})
|
||||
CPPFLAGS+= ${_RC_DEBUG}$(shell ${_RC_DEBUG_SH})
|
||||
|
||||
# Should we enable this with a different flag?
|
||||
_LD_DEBUG_SH= case "${DEBUG}" in "") echo "";; *) echo "-Wl,--rpath=../librc -Wl,--rpath=../libeinfo";; esac
|
||||
|
||||
@@ -8,6 +8,6 @@ CLEANFILES+= .depend
|
||||
IGNOREFILES+= .depend
|
||||
|
||||
.depend: ${SRCS}
|
||||
${CC} ${CFLAGS} -MM ${SRCS} > .depend
|
||||
${CC} ${CPPFLAGS} -MM ${SRCS} > .depend
|
||||
|
||||
depend: .depend
|
||||
|
||||
@@ -17,7 +17,7 @@ CLEANFILES+= ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK}
|
||||
.SUFFIXES: .So
|
||||
|
||||
.c.So:
|
||||
${CC} ${PICFLAG} -DPIC ${CFLAGS} -c $< -o $@
|
||||
${CC} ${PICFLAG} -DPIC ${CPPFLAGS} ${CFLAGS} -c $< -o $@
|
||||
|
||||
all: depend ${_LIBS}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
LIBTERMCAP?= -lncurses
|
||||
CFLAGS+= -DHAVE_TERMCAP
|
||||
CPPFLAGS+= -DHAVE_TERMCAP
|
||||
LDADD+= ${LIBTERMCAP}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Copyright 2008 Roy Marples <roy@marples.name>
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
CFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=600
|
||||
CPPFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=600
|
||||
LIBDL= -Wl,-Bdynamic -ldl
|
||||
|
||||
11
mk/os.mk
11
mk/os.mk
@@ -10,14 +10,3 @@ include ${MK}/os-${OS}.mk
|
||||
|
||||
RC_LIB= /$(LIBNAME)/rc
|
||||
|
||||
_PREFIX_SH= if test -n "${PREFIX}" && test "${PREFIX}" != "/"; then echo "-DPREFIX=\\\"${PREFIX}\\\""; else echo ""; fi
|
||||
_PREFIX!= ${_PREFIX_SH}
|
||||
CFLAGS+= ${_PREFIX}$(shell ${_PREFIX_SH})
|
||||
|
||||
_PKG_PREFIX_SH= if test -n "${PKG_PREFIX}" && test "${PKG_PREFIX}" != "/" && test "${PKG_PREFIX}" != "${PREFIX}"; then echo "-DPKG_PREFIX=\\\"${PKG_PREFIX}\\\""; else echo ""; fi
|
||||
_PKG_PREFIX!= ${_PKG_PREFIX_SH}
|
||||
CFLAGS+= ${_PKG_PREFIX}$(shell ${_PKG_PREFIX_SH})
|
||||
|
||||
_LCL_PREFIX_SH= if test -n "${LOCAL_PREFIX}" && test "${LOCAL_PREFIX}" != "/" && test "${LOCAL_PREFIX}" != "${PREFIX}"; then echo "-DLOCAL_PREFIX=\\\"${LOCAL_PREFIX}\\\""; else echo ""; fi
|
||||
_LCL_PREFIX!= ${_LCL_PREFIX_SH}
|
||||
CFLAGS+= ${_LCL_PREFIX}$(shell ${_LCL_PREFIX_SH})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
LIBPAM?= -lpam
|
||||
CFLAGS+= -DHAVE_PAM
|
||||
CPPFLAGS+= -DHAVE_PAM
|
||||
LDADD+= ${LIBPAM}
|
||||
|
||||
PAMDIR?= /etc/pam.d
|
||||
|
||||
@@ -24,6 +24,9 @@ CLEANFILES+= ${OBJS} ${PROG}
|
||||
|
||||
all: depend ${PROG}
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
|
||||
|
||||
${PROG}: ${SCRIPTS} ${OBJS}
|
||||
${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ SED_REPLACE= -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 's:@SYSCONFDIR
|
||||
.in:
|
||||
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
|
||||
all: ${OBJS}
|
||||
all: ${OBJS} ${TARGETS}
|
||||
|
||||
realinstall: ${BIN} ${CONF} ${CONF_APPEND}
|
||||
realinstall: ${BIN} ${CONF} ${INC}
|
||||
@if test -n "${DIR}"; then \
|
||||
${ECHO} ${INSTALL} -d ${DESTDIR}/${DIR}; \
|
||||
${INSTALL} -d ${DESTDIR}/${DIR} || exit $$?; \
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
LIBTERMCAP?= -ltermcap
|
||||
CFLAGS+= -DHAVE_TERMCAP
|
||||
CPPFLAGS+= -DHAVE_TERMCAP
|
||||
LDADD+= ${LIBTERMCAP}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
bonding_depend()
|
||||
{
|
||||
before interface macchanger
|
||||
program /sbin/ifenslave
|
||||
}
|
||||
|
||||
_config_vars="$_config_vars slaves"
|
||||
@@ -16,7 +15,7 @@ _is_bond()
|
||||
|
||||
bonding_pre_start()
|
||||
{
|
||||
local s= slaves="$(_get_array "slaves_${IFVAR}")"
|
||||
local x= s= slaves="$(_get_array "slaves_${IFVAR}")"
|
||||
|
||||
[ -z "${slaves}" ] && return 0
|
||||
|
||||
@@ -40,6 +39,16 @@ bonding_pre_start()
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Configure the bond.
|
||||
# Nice and dynamic :)
|
||||
for x in /sys/class/net/"${IFACE}"/bonding/*; do
|
||||
[ -f "${x}" ] || continue
|
||||
eval s=\$${x##*/}_${IFVAR}
|
||||
if [ -n "${s}" ]; then
|
||||
echo "${s}" >"${x}"
|
||||
fi
|
||||
done
|
||||
|
||||
ebegin "Adding slaves to ${IFACE}"
|
||||
eindent
|
||||
einfo "${slaves}"
|
||||
@@ -53,7 +62,7 @@ bonding_pre_start()
|
||||
# Must force the slaves to a particular state before adding them
|
||||
for IFACE in ${slaves}; do
|
||||
_delete_addresses
|
||||
_up
|
||||
_down
|
||||
done
|
||||
)
|
||||
|
||||
@@ -62,7 +71,13 @@ bonding_pre_start()
|
||||
|
||||
# finally add in slaves
|
||||
eoutdent
|
||||
/sbin/ifenslave "${IFACE}" ${slaves} >/dev/null
|
||||
if [ -d /sys/class/net ]; then
|
||||
for s in ${slaves}; do
|
||||
echo "+${s}" >/sys/class/net/"${IFACE}"/bonding/slaves
|
||||
done
|
||||
else
|
||||
/sbin/ifenslave "${IFACE}" ${slaves} >/dev/null
|
||||
fi
|
||||
eend $?
|
||||
|
||||
return 0 #important
|
||||
@@ -84,7 +99,13 @@ bonding_stop()
|
||||
eindent
|
||||
einfo "${slaves}"
|
||||
eoutdent
|
||||
/sbin/ifenslave -d "${IFACE}" ${slaves}
|
||||
if [ -d /sys/class/net ]; then
|
||||
for s in ${slaves}; do
|
||||
echo -"${s}" > /sys/class/net/"${IFACE}"/bonding/slaves
|
||||
done
|
||||
else
|
||||
/sbin/ifenslave -d "${IFACE}" ${slaves}
|
||||
fi
|
||||
|
||||
# reset all slaves
|
||||
(
|
||||
|
||||
@@ -16,12 +16,15 @@ _is_bridge()
|
||||
|
||||
bridge_pre_start()
|
||||
{
|
||||
local ports= brif= iface="${IFACE}" e= x=
|
||||
local brif= iface="${IFACE}" e= x=
|
||||
local ports="$(_get_array "bridge_${IFVAR}")"
|
||||
local opts="$(_get_array "brctl_${IFVAR}")"
|
||||
|
||||
eval brif=\$bridge_add_${IFVAR}
|
||||
[ -z "${ports}" -a -z "${brif}" -a -z "${opts}" ] && return 0
|
||||
eval x=\${bridge_${IFVAR}-y\}
|
||||
if [ -z "${brif}" -a -z "${opts}" ]; then
|
||||
[ -n "${ports}" -o "${x}" != "y" ] || return 0
|
||||
fi
|
||||
|
||||
[ -n "${ports}" ] && bridge_post_stop
|
||||
|
||||
|
||||
@@ -15,20 +15,42 @@ _config_vars="$_config_vars dhcp dhcpcd"
|
||||
|
||||
dhcpcd_start()
|
||||
{
|
||||
local args= opt= opts= pidfile="/var/run/dhcpcd-${IFACE}.pid"
|
||||
|
||||
local args= opt= opts= pidfile="/var/run/dhcpcd-${IFACE}.pid" new=true
|
||||
eval args=\$dhcpcd_${IFVAR}
|
||||
[ -z "${args}" ] && args=${dhcpcd}
|
||||
|
||||
# Get our options
|
||||
eval opts=\$dhcp_${IFVAR}
|
||||
[ -z "${opts}" ] && opts=${dhcp}
|
||||
|
||||
case "$(dhcpcd --version)" in
|
||||
"dhcpcd "[123]*) new=false;;
|
||||
esac
|
||||
|
||||
# Map some generic options to dhcpcd
|
||||
for opt in ${opts}; do
|
||||
case "${opt}" in
|
||||
nodns) args="${args} -R";;
|
||||
nontp) args="${args} -N";;
|
||||
nonis) args="${args} -Y";;
|
||||
nodns)
|
||||
if ${new}; then
|
||||
args="${args} -C resolv.conf"
|
||||
else
|
||||
args="${args} -R"
|
||||
fi
|
||||
;;
|
||||
nontp)
|
||||
if ${new}; then
|
||||
args="${args} -C ntp.conf"
|
||||
else
|
||||
args="${args} -N"
|
||||
fi
|
||||
;;
|
||||
nonis)
|
||||
if ${new}; then
|
||||
args="${args} -C yp.conf"
|
||||
else
|
||||
args="${args} -Y"
|
||||
fi
|
||||
;;
|
||||
nogateway) args="${args} -G";;
|
||||
nosendhost) args="${args} -h ''";
|
||||
esac
|
||||
|
||||
@@ -151,9 +151,12 @@ _delete_addresses()
|
||||
{
|
||||
einfo "Removing addresses"
|
||||
eindent
|
||||
LC_ALL=C ifconfig "${IFACE}" | while read inet address rest; do
|
||||
LC_ALL=C ifconfig "${IFACE}" | while read inet address ali rest; do
|
||||
case "${inet}" in
|
||||
inet|inet6)
|
||||
if [ "${address}" = "alias" ]; then
|
||||
address="${ali}"
|
||||
fi
|
||||
case "${address}" in
|
||||
*"%${IFACE}"|::1) continue;;
|
||||
127.0.0.1) [ "${IFACE}" = "lo0" ] && continue;;
|
||||
|
||||
@@ -56,7 +56,7 @@ _set_flag()
|
||||
_get_mac_address()
|
||||
{
|
||||
local mac=$(LC_ALL=C ifconfig "${IFACE}" | \
|
||||
sed -n -e 's/.* HWaddr \(..:..:..:..:..:..\).*/\1/p')
|
||||
sed -n -e 's/.* \(HWaddr\|ether\) \(..:..:..:..:..:..\).*/\2/p')
|
||||
|
||||
case "${mac}" in
|
||||
00:00:00:00:00:00);;
|
||||
@@ -77,7 +77,7 @@ _set_mac_address()
|
||||
_get_inet_address()
|
||||
{
|
||||
set -- $(LC_ALL=C ifconfig "${IFACE}" |
|
||||
sed -n -e 's/.*inet addr:\([^ ]*\).*Mask:\([^ ]*\).*/\1 \2/p')
|
||||
sed -n -e 's/.*\(inet addr:\|inet \)\([^ ]*\).*\(Mask:\|netmask \)\([^ ]*\).*/\2 \4/p')
|
||||
[ -z "$1" ] && return 1
|
||||
|
||||
echo -n "$1"
|
||||
@@ -145,7 +145,7 @@ _add_address()
|
||||
# IPv4 is tricky - ifconfig requires an aliased device
|
||||
# for multiple addresses
|
||||
local iface="${IFACE}"
|
||||
if LC_ALL=C ifconfig "${iface}" | grep -Eq "\<inet addr:.*"; then
|
||||
if LC_ALL=C ifconfig "${iface}" | grep -Eq '\<inet (addr:)?.*'; then
|
||||
# Get the last alias made for the interface and add 1 to it
|
||||
i=$(ifconfig | sed '1!G;h;$!d' | grep -m 1 -o "^${iface}:[0-9]*" \
|
||||
| sed -n -e 's/'"${iface}"'://p')
|
||||
@@ -234,8 +234,12 @@ _delete_addresses()
|
||||
# Remove IPv6 addresses
|
||||
local addr=
|
||||
for addr in $(LC_ALL=C ifconfig "${IFACE}" | \
|
||||
sed -n -e 's/^.*inet6 addr: \([^ ]*\) Scope:[^L].*/\1/p'); do
|
||||
[ "${addr}" = "::1/128" -a "${IFACE}" = "lo" ] && continue
|
||||
sed -n -e 's/^.*\(inet6 addr:\|inet6\) \([^ ]*\) .*\(Scope:[^L]\|scopeid [^<]*<[^l]\).*/\2/p'); do
|
||||
if [ "${IFACE}" = "lo" ]; then
|
||||
case "${addr}" in
|
||||
"::1/128"|"/128") continue;;
|
||||
esac
|
||||
fi
|
||||
einfo "${addr}"
|
||||
ifconfig "${IFACE}" inet6 del "${addr}"
|
||||
done
|
||||
|
||||
@@ -54,7 +54,6 @@ ifwatchd_stop()
|
||||
ebegin "Stopping ifwatchd on" "${IFACE}"
|
||||
start-stop-daemon --stop --exec /usr/sbin/ifwatchd \
|
||||
-- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \
|
||||
-n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \
|
||||
&& return 0
|
||||
-n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}"
|
||||
eend $?
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ iproute2_depend()
|
||||
|
||||
_up()
|
||||
{
|
||||
ip link set up dev "${IFACE}"
|
||||
ip link set "${IFACE}" up
|
||||
}
|
||||
|
||||
_down()
|
||||
{
|
||||
ip link set down dev "${IFACE}"
|
||||
ip link set "${IFACE}" down
|
||||
}
|
||||
|
||||
_exists()
|
||||
@@ -78,7 +78,7 @@ _get_mac_address()
|
||||
|
||||
_set_mac_address()
|
||||
{
|
||||
ip link set address "$1" dev "${IFACE}"
|
||||
ip link set "${IFACE}" address "$1"
|
||||
}
|
||||
|
||||
_get_inet_addresses()
|
||||
@@ -126,7 +126,7 @@ _add_address()
|
||||
;;
|
||||
esac
|
||||
|
||||
ip addr add dev "${IFACE}" "$@"
|
||||
ip addr add "$@" dev "${IFACE}"
|
||||
}
|
||||
|
||||
_add_route()
|
||||
@@ -184,12 +184,12 @@ iproute2_pre_start()
|
||||
# MTU support
|
||||
local mtu=
|
||||
eval mtu=\$mtu_${IFVAR}
|
||||
[ -n "${mtu}" ] && ip link set mtu "${mtu}" dev "${IFACE}"
|
||||
[ -n "${mtu}" ] && ip link set "${IFACE}" mtu "${mtu}"
|
||||
|
||||
# TX Queue Length support
|
||||
local len=
|
||||
eval len=\$txqueuelen_${IFVAR}
|
||||
[ -n "${len}" ] && ip link set txqueuelen "${len}" dev "${IFACE}"
|
||||
[ -n "${len}" ] && ip link set "${IFACE}" txqueuelen "${len}"
|
||||
|
||||
local tunnel=
|
||||
eval tunnel=\$iptunnel_${IFVAR}
|
||||
@@ -208,6 +208,8 @@ iproute2_pre_start()
|
||||
|
||||
_iproute2_ipv6_tentative()
|
||||
{
|
||||
# Only check tentative when we have a carrier.
|
||||
LC_ALL=C ip link show dev "${IFACE}" | grep -q "NO-CARRIER" && return 1
|
||||
LC_ALL=C ip addr show dev "${IFACE}" | \
|
||||
grep -q "^[[:space:]]*inet6 .* tentative"
|
||||
}
|
||||
|
||||
@@ -414,8 +414,9 @@ iwconfig_connect_preferred()
|
||||
[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps")
|
||||
[ $# = 0 ] && return 1
|
||||
|
||||
local ssid= i=0 mode= mac= caps= freq= chan=
|
||||
local ssid= i= mode= mac= caps= freq= chan=
|
||||
for ssid; do
|
||||
i=0
|
||||
while [ ${i} -le ${APS} ] ; do
|
||||
eval e=\$SSID_${i}
|
||||
if [ "${e}" = "${ssid}" ] ; then
|
||||
@@ -484,7 +485,7 @@ iwconfig_defaults()
|
||||
|
||||
iwconfig_configure()
|
||||
{
|
||||
local x APS
|
||||
local x= APS=-1
|
||||
eval SSID=\$ssid_${IFVAR}
|
||||
|
||||
# Setup ad-hoc mode?
|
||||
|
||||
@@ -206,9 +206,13 @@ iwconfig_wait_for_association()
|
||||
# Use sysfs if we can
|
||||
if [ -e /sys/class/net/"${IFACE}"/carrier ]; then
|
||||
if [ "$(cat /sys/class/net/"${IFACE}"/carrier)" = "1" ]; then
|
||||
# Double check we have an ssid. This is mainly for buggy
|
||||
# prism54 drivers that always set their carrier on :/
|
||||
[ -n "$(iwgetid --raw "${IFACE}")" ] && return 0
|
||||
# Double check we have an ssid and a non-zero
|
||||
# mac address. This is mainly for buggy
|
||||
# prism54 drivers that always set their
|
||||
# carrier on or buggy madwifi drivers that
|
||||
# sometimes have carrier on and ssid set
|
||||
# without being associated. :/
|
||||
[ -n "$(iwgetid --raw "${IFACE}")" ] && [ "$(iwgetid --ap --raw "${IFACE}")" != "00:00:00:00:00:00" ] && return 0
|
||||
fi
|
||||
else
|
||||
local atest=
|
||||
@@ -429,7 +433,7 @@ iwconfig_scan()
|
||||
[ -z "${a}" ] && break
|
||||
eval b=\$QUALITY_${k}
|
||||
if [ -n "${b}" -a "${a}" -lt "${b}" ]; then
|
||||
for x in MAC SSID CHAN QUALITY ENC; do
|
||||
for x in MAC SSID MODE CHAN QUALITY ENC; do
|
||||
eval t=\$${x}_${i}
|
||||
eval ${x}_${i}=\$${x}_${k}
|
||||
eval ${x}_${k}=\$t
|
||||
@@ -453,7 +457,7 @@ iwconfig_scan()
|
||||
local u=${k}
|
||||
# We need to split this into two tests, otherwise bash errors
|
||||
[ -n "${a}" -a -n "${b}" ] && [ "${a}" -lt "${b}" ] && u=${i}
|
||||
unset MAC_${u} SSID_${u} CHAN_${u} QUALITY_${u} ENC_${u}
|
||||
unset MAC_${u} SSID_${u} MODE_${u} CHAN_${u} QUALITY_${u} ENC_${u}
|
||||
fi
|
||||
k=$((${k} + 1))
|
||||
done
|
||||
@@ -499,7 +503,7 @@ iwconfig_scan()
|
||||
for x; do
|
||||
if [ "${x}" = "${s}" ]; then
|
||||
ewarn "${s} has been blacklisted - not connecting"
|
||||
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i}
|
||||
unset SSID_${i} MAC_${i} ${MODE}_${i} CHAN_${i} QUALITY_${i} ENC_${i}
|
||||
fi
|
||||
done
|
||||
i=$((${i} + 1))
|
||||
@@ -525,7 +529,7 @@ iwconfig_force_preferred()
|
||||
i=$((${i} + 1))
|
||||
done
|
||||
if ! ${found_AP}; then
|
||||
SSID=${e}
|
||||
SSID=${ssid}
|
||||
iwconfig_associate && return 0
|
||||
fi
|
||||
done
|
||||
@@ -597,10 +601,8 @@ iwconfig_connect_not_preferred()
|
||||
|
||||
iwconfig_defaults()
|
||||
{
|
||||
local x=
|
||||
for x in txpower rate rts frag; do
|
||||
iwconfig "${IFACE}" "${x}" auto 2>/dev/null
|
||||
done
|
||||
# Turn on the radio
|
||||
iwconfig "${IFACE}" txpower on 2>/dev/null
|
||||
|
||||
# Release the AP forced
|
||||
# Must do ap and then ssid otherwise scanning borks
|
||||
@@ -610,7 +612,7 @@ iwconfig_defaults()
|
||||
|
||||
iwconfig_configure()
|
||||
{
|
||||
local x= APS=
|
||||
local x= APS=-1
|
||||
eval SSID=\$ssid_${IFVAR}
|
||||
|
||||
# Support old variable
|
||||
@@ -735,7 +737,7 @@ iwconfig_pre_start()
|
||||
# which reports NOT READY!
|
||||
x="$(iwconfig_get_type)"
|
||||
if [ "${x}" = "NOT READY!" ]; then
|
||||
eerror "Looks like there was a probem loading the firmware for ${IFACE}"
|
||||
eerror "Looks like there was a problem loading the firmware for ${IFACE}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ _system_ntp()
|
||||
local servers= buffer= x=
|
||||
|
||||
eval servers=\$ntp_servers_${IFVAR}
|
||||
[ -z ${servers} ] && servers=${ntp_servers}
|
||||
[ -z ${servers} ] && return 0
|
||||
[ -z "${servers}" ] && servers=${ntp_servers}
|
||||
[ -z "${servers}" ] && return 0
|
||||
|
||||
buffer="# Generated by net-scripts for interface ${IFACE}\n"
|
||||
buffer="${buffer}restrict default noquery notrust nomodify\n"
|
||||
|
||||
@@ -66,7 +66,7 @@ vlan_pre_start()
|
||||
vlan_post_start()
|
||||
{
|
||||
local vlans=
|
||||
eval vlans=\$vlans_${IFACE}
|
||||
eval vlans=\$vlans_${IFVAR}
|
||||
[ -z "${vlans}" ] && return 0
|
||||
|
||||
_check_vlan || return 1
|
||||
@@ -86,13 +86,13 @@ vlan_post_start()
|
||||
yesno ${s:-yes} || continue
|
||||
|
||||
# We need to work out the interface name of our new vlan id
|
||||
local ifname="$( \
|
||||
sed -n -e 's/^\([^[:space:]]*\) *| '"${vlan}"' *| .*'"${iface}"'$/\1/p' \
|
||||
local ifname="$(sed -n -e \
|
||||
's/^\([^[:space:]]*\) *| '"${vlan}"' *| .*'"${iface}"'$/\1/p' \
|
||||
/proc/net/vlan/config )"
|
||||
mark_service_started "net.${ifname}"
|
||||
(
|
||||
export RC_SVCNAME="net.${ifname}"
|
||||
start
|
||||
start
|
||||
) || mark_service_stopped "net.${ifname}"
|
||||
done
|
||||
|
||||
|
||||
@@ -78,11 +78,9 @@ wpa_supplicant_pre_start()
|
||||
service_set_value "SSID" ""
|
||||
ebegin "Starting wpa_supplicant on ${IFVAR}"
|
||||
|
||||
if [ -x /sbin/iwconfig ]; then
|
||||
local x=
|
||||
for x in txpower rate rts frag; do
|
||||
iwconfig "${IFACE}" "${x}" auto 2>/dev/null
|
||||
done
|
||||
if type iwconfig_defaults >/dev/null 2>&1; then
|
||||
iwconfig_defaults
|
||||
iwconfig_user_config
|
||||
fi
|
||||
|
||||
cfgfile=${opts##* -c}
|
||||
|
||||
@@ -6,6 +6,8 @@ LEVELDIR= ${DESTDIR}/${SYSCONFDIR}/runlevels
|
||||
BOOTDIR= ${LEVELDIR}/boot
|
||||
DEFAULTDIR= ${LEVELDIR}/default
|
||||
|
||||
INITDIR= ../init.d
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/sys.mk
|
||||
include ${MK}/os.mk
|
||||
@@ -19,7 +21,8 @@ install:
|
||||
${INSTALL} -d ${BOOTDIR} || exit $$?; \
|
||||
for x in ${BOOT}; do \
|
||||
if test -n "${PREFIX}"; then \
|
||||
grep -q "keyword .*noprefix" ${SYSCONFDIR}/init.d/"$$x" && continue; \
|
||||
test "$$x" = "net.lo" -o "$$x" = "net.lo0" && continue; \
|
||||
grep -q "keyword .*noprefix" ${INITDIR}/"$$x" && continue; \
|
||||
fi; \
|
||||
ln -snf ${PREFIX}/etc/init.d/"$$x" ${BOOTDIR}/"$$x" || exit $$?; \
|
||||
done \
|
||||
@@ -28,7 +31,7 @@ install:
|
||||
${INSTALL} -d ${DEFAULTDIR} || exit $$?; \
|
||||
for x in ${DEFAULT}; do \
|
||||
if test -n "${PREFIX}"; then \
|
||||
grep -q "keyword .*noprefix" ${SYSCONFDIR}/init.d/"$$x" && continue; \
|
||||
grep -q "keyword .*noprefix" ${INITDIR}/"$$x" && continue; \
|
||||
fi; \
|
||||
ln -snf ${PREFIX}/etc/init.d/"$$x" ${DEFAULTDIR}/"$$x" || exit $$?; done \
|
||||
fi
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
BOOT+= hwclock consolefont keymaps modules mtab net.lo procfs
|
||||
DEFAULT+= hdparm
|
||||
BOOT+= hwclock consolefont keymaps modules mtab net.lo procfs \
|
||||
termencoding
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
BOOT+= hostid net.lo0 newsyslog savecore syslogd
|
||||
|
||||
# NetBSD specific stuff
|
||||
BOOT+= swap-blk ttys wscons
|
||||
BOOT+= devdb swap-blk ttys wscons
|
||||
|
||||
4
sh/.gitignore
vendored
4
sh/.gitignore
vendored
@@ -3,4 +3,8 @@ gendepends.sh
|
||||
net.sh
|
||||
rc-functions.sh
|
||||
runscript.sh
|
||||
init-common-post.sh
|
||||
init-early.sh
|
||||
init.sh
|
||||
ifwatchd-carrier.sh
|
||||
ifwatchd-nocarrier.sh
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
DIR= ${PREFIX}/${RC_LIB}/sh
|
||||
SRCS= functions.sh.in gendepends.sh.in net.sh.in \
|
||||
SRCS= functions.sh.in gendepends.sh.in init-common-post.sh.in \
|
||||
rc-functions.sh.in runscript.sh.in
|
||||
INC= init-common-post.sh rc-mount.sh functions.sh rc-functions.sh
|
||||
BIN= gendepends.sh init.sh net.sh runscript.sh
|
||||
BIN= gendepends.sh init.sh runscript.sh
|
||||
|
||||
INSTALLAFTER= _installafter
|
||||
|
||||
@@ -13,8 +13,6 @@ include ${MK}/scripts.mk
|
||||
|
||||
_installafter:
|
||||
${INSTALL} -d ${DESTDIR}/${INITDIR}
|
||||
@# Provide an init script for the loopback interface
|
||||
ln -snf ${PREFIX}/${RC_LIB}/sh/net.sh ${DESTDIR}/${INITDIR}/${NET_LO} || exit $$?
|
||||
@# Put functions.sh into the init.d dir so 3rd party apps don't have to
|
||||
@# be multilib aware
|
||||
ln -snf ${PREFIX}/${RC_LIB}/sh/functions.sh ${DESTDIR}/${INITDIR} || exit $$?
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
SRCS+= init.sh.in
|
||||
|
||||
NET_LO= net.lo0
|
||||
|
||||
.SUFFIXES: .sh.BSD.in
|
||||
.sh.BSD.in.sh:
|
||||
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
NET_LO= net.lo
|
||||
SRCS+= init.sh.in init-early.sh.in
|
||||
BIN+= init-early.sh
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
SRCS+= init.sh.in
|
||||
|
||||
NET_LO= net.lo0
|
||||
SRCS+= ifwatchd-carrier.sh.in ifwatchd-nocarrier.sh.in
|
||||
BIN+= ifwatchd-carrier.sh ifwatchd-nocarrier.sh
|
||||
|
||||
|
||||
@@ -38,12 +38,17 @@ yesno()
|
||||
esac
|
||||
}
|
||||
|
||||
rc_runlevel() {
|
||||
rc-status --runlevel
|
||||
}
|
||||
|
||||
_sanitize_path()
|
||||
{
|
||||
local IFS=":" p= path=
|
||||
for p in ${PATH}; do
|
||||
case "${p}" in
|
||||
@PREFIX@/lib/rc/sbin|@PREFIX@/bin|@PREFIX@/sbin|/usr/bin|/usr/sbin);;
|
||||
@PREFIX@/@LIB@/rc/bin|@PREFIX@/@LIB@/rc/sbin);;
|
||||
@PREFIX@/bin|@PREFIX@/sbin|/usr/bin|/usr/sbin);;
|
||||
@PKG_PREFIX@/bin|@PKG_PREFIX@/sbin);;
|
||||
@LOCAL_PREFIX@/bin|@LOCAL_PREFIX@/sbin);;
|
||||
*) path="${path}${path:+:}${p}";;
|
||||
@@ -66,7 +71,7 @@ _PREFIX=@PREFIX@
|
||||
_PKG_PREFIX=@PKG_PREFIX@
|
||||
_LOCAL_PREFIX=@LOCAL_PREFIX@
|
||||
_LOCAL_PREFIX=${_LOCAL_PREFIX:-/usr/local}
|
||||
_PATH=@PREFIX@/lib/rc/bin
|
||||
_PATH=@PREFIX@/@LIB@/rc/bin
|
||||
case "${_PREFIX}" in
|
||||
"${_PKG_PREFIX}"|"${_LOCAL_PREFIX}") ;;
|
||||
*) _PATH="${_PATH}:${_PREFIX}/bin:${_PREFIX}/sbin";;
|
||||
@@ -79,8 +84,9 @@ fi
|
||||
if [ -n "${_LOCAL_PREFIX}" ]; then
|
||||
_PATH="${_PATH}:${_LOCAL_PREFIX}/bin:${_LOCAL_PREFIX}/sbin"
|
||||
fi
|
||||
export PATH="${_PATH}:$(_sanitize_path "${PATH}")"
|
||||
unset _sanitize_path _PREFIX _PKG_PREFIX _LOCAL_PREFIX _PATH
|
||||
_path="$(_sanitize_path "${PATH}")"
|
||||
export PATH="${_PATH}${_path:+:}${_path}"
|
||||
unset _sanitize_path _PREFIX _PKG_PREFIX _LOCAL_PREFIX _PATH _path
|
||||
|
||||
for arg; do
|
||||
case "${arg}" in
|
||||
@@ -99,7 +105,7 @@ else
|
||||
# the last ecmd
|
||||
for _e in ebegin eend error errorn einfo einfon ewarn ewarnn ewend \
|
||||
vebegin veend veinfo vewarn vewend; do
|
||||
eval "${_e}() { local _r; @PREFIX@/lib/rc/bin/${_e} \"\$@\"; _r=$?; \
|
||||
eval "${_e}() { local _r; @PREFIX@/@LIB@/rc/bin/${_e} \"\$@\"; _r=$?; \
|
||||
export EINFO_LASTCMD=${_e}; return \$_r; }"
|
||||
done
|
||||
unset _e
|
||||
|
||||
@@ -48,12 +48,14 @@ do
|
||||
|
||||
cd "${_dir}"
|
||||
for RC_SERVICE in *; do
|
||||
[ -x "${RC_SERVICE}" ] || continue
|
||||
[ -x "${RC_SERVICE}" -a -f "${RC_SERVICE}" ] || continue
|
||||
|
||||
# Only generate dependencies for runscripts
|
||||
read one two < "${RC_SERVICE}"
|
||||
[ "${one}" = "#!@PREFIX@/sbin/runscript" ] || continue
|
||||
unset one two
|
||||
read one two three < "${RC_SERVICE}"
|
||||
[ "${one}" = "#!@PREFIX@/sbin/runscript" ] || \
|
||||
[ "${one}" = "#!" -a "${two}" = "@PREFIX@/sbin/runscript" ] || \
|
||||
continue
|
||||
unset one two three
|
||||
|
||||
export RC_SVCNAME=${RC_SERVICE##*/}
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@ retval=0
|
||||
# mount $svcdir as something we can write to if it's not rw
|
||||
# On vservers, / is always rw at this point, so we need to clean out
|
||||
# the old service state data
|
||||
RC_SVCDIR=${RC_SVCDIR:-/@LIB@/rc/init.d}
|
||||
if [ "${RC_SVCDIR}" != "/" ] && mkdir "${RC_SVCDIR}/.test.$$" 2>/dev/null; then
|
||||
rmdir "${RC_SVCDIR}/.test.$$"
|
||||
for x in ${RC_SVCDIR:-/lib/rc/init.d}/*; do
|
||||
for x in ${RC_SVCDIR}/*; do
|
||||
[ -e "${x}" ] || continue
|
||||
case ${x##*/} in
|
||||
depconfig|deptree|ksoftlevel|rc.log);;
|
||||
@@ -96,6 +96,9 @@ if ${mountproc}; then
|
||||
fi
|
||||
unset mountproc
|
||||
|
||||
# Re-load RC_SYS if empty now we have /proc mounted
|
||||
[ -z "${RC_SYS}" ] && export RC_SYS="$(rc --sys)"
|
||||
|
||||
# Read off the kernel commandline to see if there's any special settings
|
||||
# especially check to see if we need to set the CDBOOT environment variable
|
||||
# Note: /proc MUST be mounted
|
||||
@@ -105,8 +108,7 @@ if [ -r /sbin/livecd-functions.sh ]; then
|
||||
fi
|
||||
|
||||
if [ "${RC_UNAME}" != "GNU/kFreeBSD" \
|
||||
-a "${RC_SYS}" != "VSERVER" \
|
||||
-a "${RC_SYS}" != "OPENVZ" ]
|
||||
-a "${RC_SYS}" != "VSERVER" ];
|
||||
then
|
||||
if grep -Eq "[[:space:]]+sysfs$" /proc/filesystems; then
|
||||
if [ -d /sys ]; then
|
||||
@@ -123,10 +125,14 @@ then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Default OpenVZ to static devices
|
||||
if [ "${RC_SYS}" = "OPENVZ" ]; then
|
||||
rc_devices=${rc_devices:-static}
|
||||
fi
|
||||
|
||||
# Try to figure out how the user wants /dev handled
|
||||
if [ "${rc_devices}" = "static" \
|
||||
-o "${RC_SYS}" = "VSERVER" \
|
||||
-o "${RC_SYS}" = "OPENVZ" \
|
||||
-o "${RC_UNAME}" = "GNU/kFreeBSD" ]
|
||||
then
|
||||
ebegin "Using existing device nodes in /dev"
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
|
||||
has_addon()
|
||||
{
|
||||
[ -e "${RC_LIBDIR}/addons/$1.sh" ] || [ -e /lib/rcscripts/addons/"$1".sh ]
|
||||
[ -e "${RC_LIBDIR}/addons/$1.sh" ] || [ -e /@LIB@/rcscripts/addons/"$1".sh ]
|
||||
}
|
||||
|
||||
import_addon()
|
||||
{
|
||||
if [ -e "${RC_LIBDIR}/addons/$1.sh" ]; then
|
||||
. "${RC_LIBDIR}/addons/$1.sh"
|
||||
elif [ -e /lib/rcscripts/addons/"$1".sh ]; then
|
||||
. /lib/rcscripts/addons/"$1".sh
|
||||
elif [ -e /@LIB@/rcscripts/addons/"$1".sh ]; then
|
||||
. /@LIB@/rcscripts/addons/"$1".sh
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
@@ -58,6 +58,7 @@ get_bootparam()
|
||||
|
||||
set -- $(cat /proc/cmdline)
|
||||
while [ -n "$1" ]; do
|
||||
[ "$1" = "${match}" ] && return 0
|
||||
case "$1" in
|
||||
gentoo=*)
|
||||
local params="${1##*=}"
|
||||
@@ -75,6 +76,6 @@ get_bootparam()
|
||||
|
||||
# Add our sbin to $PATH
|
||||
case "${PATH}" in
|
||||
@PREFIX@/lib/rc/sbin|@PREFIX@/lib/rc/sbin:*);;
|
||||
*) export PATH="@PREFIX@/lib/rc/sbin:${PATH}";;
|
||||
"${RC_LIBDIR}"/sbin|"${RC_LIBDIR}"/sbin:*);;
|
||||
*) export PATH="${RC_LIBDIR}/sbin:${PATH}";;
|
||||
esac
|
||||
|
||||
@@ -20,6 +20,7 @@ fi
|
||||
|
||||
# So daemons know where to recall us if needed
|
||||
export RC_SERVICE="$1"
|
||||
shift
|
||||
|
||||
# Compat
|
||||
export SVCNAME=${RC_SVCNAME}
|
||||
@@ -44,9 +45,49 @@ describe()
|
||||
done
|
||||
}
|
||||
|
||||
# Template start / stop functions
|
||||
start()
|
||||
{
|
||||
[ -n "${command}" ] || return 0
|
||||
local _background=
|
||||
ebegin "Starting ${name:-${RC_SVCNAME}}"
|
||||
if yesno "${command_background}"; then
|
||||
_background="--background --pidfile"
|
||||
fi
|
||||
if yesno "${start_inactive}"; then
|
||||
local _inactive=false
|
||||
service_inactive && _inactive=true
|
||||
mark_service_inactive
|
||||
fi
|
||||
start-stop-daemon --start \
|
||||
--exec ${command} \
|
||||
${procname:+--name} ${procname} \
|
||||
${pidfile:+--pidfile} ${pidfile} \
|
||||
${_background} ${start_stop_daemon_args} \
|
||||
-- ${command_args}
|
||||
eend $? "Failed to start ${RC_SVCNAME}" && return 0
|
||||
if yesno "${start_inactive}"; then
|
||||
if ! ${_inactive}; then
|
||||
mark_service_stopped
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
[ -n "${command}" -o -n "${procname}" -o -n "${pidfile}" ] || return 0
|
||||
ebegin "Stopping ${name:-${RC_SVCNAME}}"
|
||||
start-stop-daemon --stop \
|
||||
${command:+--exec} ${command} \
|
||||
${procname:+--name} ${procname} \
|
||||
${pidfile:+--pidfile} ${pidfile}
|
||||
eend $? "Failed to stop ${RC_SVCNAME}"
|
||||
}
|
||||
|
||||
yesno ${RC_DEBUG} && set -x
|
||||
|
||||
_conf_d=${1%/*}/../conf.d
|
||||
_conf_d=${RC_SERVICE%/*}/../conf.d
|
||||
# If we're net.eth0 or openvpn.work then load net or openvpn config
|
||||
_c=${RC_SVCNAME%%.*}
|
||||
if [ -n "${_c}" -a "${_c}" != "${RC_SVCNAME}" ]; then
|
||||
@@ -73,8 +114,7 @@ unset _conf_d
|
||||
[ -n "${rc_ulimit:-${RC_ULIMIT}}" ] && ulimit ${rc_ulimit:-${RC_ULIMIT}}
|
||||
|
||||
# Load our script
|
||||
. $1
|
||||
shift
|
||||
. "${RC_SERVICE}"
|
||||
|
||||
for _d in ${required_dirs}; do
|
||||
if [ ! -d ${_d} ]; then
|
||||
@@ -92,58 +132,12 @@ for _f in ${required_files}; do
|
||||
done
|
||||
unset _f
|
||||
|
||||
# If we have a default command then supply a default start function
|
||||
if [ -n "${command}" ]; then
|
||||
if ! type start >/dev/null 2>&1; then
|
||||
start() {
|
||||
local _background=
|
||||
ebegin "Starting ${name:-${RC_SVCNAME}}"
|
||||
if yesno "${command_background}"; then
|
||||
_background="--background --pidfile"
|
||||
fi
|
||||
if yesno "${start_inactive}"; then
|
||||
local _inactive=false
|
||||
service_inactive && _inactive=true
|
||||
mark_service_inactive
|
||||
fi
|
||||
start-stop-daemon --start \
|
||||
--exec ${command} \
|
||||
${procname:+--name} ${procname} \
|
||||
${pidfile:+--pidfile} ${pidfile} \
|
||||
${_background} ${start_stop_daemon_args} \
|
||||
-- ${command_args}
|
||||
eend $? "Failed to start ${RC_SVCNAME}" && return 0
|
||||
if yesno "${start_inactive}"; then
|
||||
if ! ${_inactive}; then
|
||||
mark_service_stopped
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
# If we have a default command, procname or pidfile then supply a default stop
|
||||
# function
|
||||
if [ -n "${command}" -o -n "${procname}" -o -n "${pidfile}" ]; then
|
||||
if ! type stop >/dev/null 2>&1; then
|
||||
stop() {
|
||||
ebegin "Stopping ${name:-${RC_SVCNAME}}"
|
||||
start-stop-daemon --stop \
|
||||
${command:+--exec} ${command} \
|
||||
${procname:+--name} ${procname} \
|
||||
${pidfile:+--pidfile} ${pidfile}
|
||||
eend $? "Failed to stop ${RC_SVCNAME}"
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
# See if we have the required function and run it
|
||||
for _cmd in describe start stop ${extra_commands:-${opts}} \
|
||||
${extra_started_commands}; do
|
||||
if [ "${_cmd}" = "$1" ]; then
|
||||
if type "$1" >/dev/null 2>&1; then
|
||||
if [ "$(command -v "$1")" = "$1" ]; then
|
||||
# If we're in the background, we may wish to
|
||||
# fake some commands. We do this so we can
|
||||
# "start" ourselves from inactive which then
|
||||
@@ -168,11 +162,11 @@ while [ -n "$1" ]; do
|
||||
fi
|
||||
done
|
||||
unset _cmd
|
||||
if type "$1"_pre >/dev/null 2>&1; then
|
||||
if [ "$(command -v "$1_pre")" = "$1_pre" ]; then
|
||||
"$1"_pre || exit $?
|
||||
fi
|
||||
"$1" || exit $?
|
||||
if type "$1"_post >/dev/null 2>&1; then
|
||||
if [ "$(command -v "$1_post")" = "$1_post" ]; then
|
||||
"$1"_post || exit $?
|
||||
fi
|
||||
shift
|
||||
|
||||
@@ -9,17 +9,17 @@ tret=0
|
||||
ebegin "Testing yesno()"
|
||||
for f in yes YES Yes true TRUE True 1 ; do
|
||||
if ! yesno ${f} ; then
|
||||
((tret+=1))
|
||||
tret=$((${tret} + 1))
|
||||
echo "!${f}!"
|
||||
fi
|
||||
done
|
||||
for f in no NO No false FALSE False 0 ; do
|
||||
if yesno ${f} ; then
|
||||
((tret+=1))
|
||||
tret=$(({$tret} + 1))
|
||||
echo "!${f}!"
|
||||
fi
|
||||
done
|
||||
eend ${tret}
|
||||
((ret+=tret))
|
||||
ret=$((${ret} + ${tret}))
|
||||
|
||||
exit ${ret}
|
||||
|
||||
@@ -37,45 +37,10 @@
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef LIB
|
||||
# define LIB "lib"
|
||||
#endif
|
||||
|
||||
#ifdef PREFIX
|
||||
# define RC_PREFIX PREFIX
|
||||
#else
|
||||
# define RC_PREFIX
|
||||
#endif
|
||||
|
||||
#ifndef SYSCONFDIR
|
||||
# define SYSCONFDIR RC_PREFIX "/etc"
|
||||
#endif
|
||||
|
||||
#define RC_LEVEL_BOOT "boot"
|
||||
#define RC_LEVEL_DEFAULT "default"
|
||||
|
||||
#define RC_LIBDIR RC_PREFIX "/" LIB "/rc"
|
||||
#define RC_SVCDIR RC_LIBDIR "/init.d"
|
||||
#define RC_DEPTREE_CACHE RC_SVCDIR "/deptree"
|
||||
#define RC_RUNLEVELDIR SYSCONFDIR "/runlevels"
|
||||
#define RC_INITDIR SYSCONFDIR "/init.d"
|
||||
#define RC_CONFDIR SYSCONFDIR "/conf.d"
|
||||
|
||||
/* PKG_PREFIX is where packages are installed if different from the base OS
|
||||
* On Gentoo this is normally unset, on FreeBSD /usr/local and on NetBSD
|
||||
* /usr/pkg. */
|
||||
#ifdef PKG_PREFIX
|
||||
# define RC_PKG_INITDIR PKG_PREFIX "/etc/init.d"
|
||||
# define RC_PKG_CONFDIR PKG_PREFIX "/etc/conf.d"
|
||||
#endif
|
||||
|
||||
/* LOCAL_PREFIX is for user written stuff, which the base OS and package
|
||||
* manger don't touch. */
|
||||
#ifdef LOCAL_PREFIX
|
||||
# define RC_LOCAL_INITDIR LOCAL_PREFIX "/etc/init.d"
|
||||
# define RC_LOCAL_CONFDIR LOCAL_PREFIX "/etc/conf.d"
|
||||
#endif
|
||||
|
||||
#define RC_KRUNLEVEL RC_SVCDIR "/krunlevel"
|
||||
#define RC_STARTING RC_SVCDIR "/rc.starting"
|
||||
#define RC_STOPPING RC_SVCDIR "/rc.stopping"
|
||||
@@ -85,31 +50,22 @@
|
||||
#define RC_SVCDIR_STARTED RC_SVCDIR "/started"
|
||||
#define RC_SVCDIR_COLDPLUGGED RC_SVCDIR "/coldplugged"
|
||||
|
||||
#define RC_PLUGINDIR RC_LIBDIR "/plugins"
|
||||
|
||||
#define ERRX fprintf (stderr, "out of memory\n"); exit (1)
|
||||
|
||||
#define UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
||||
|
||||
#ifdef lint
|
||||
# define _unused
|
||||
#endif
|
||||
#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
|
||||
# define _dead __attribute__((__noreturn__))
|
||||
# define _unused __attribute__((__unused__))
|
||||
#else
|
||||
# define _dead
|
||||
# define _unused
|
||||
#endif
|
||||
|
||||
|
||||
/* Some libc implemntations don't have these */
|
||||
#ifndef STAILQ_CONCAT
|
||||
#define STAILQ_CONCAT(head1, head2) do { \
|
||||
if (!STAILQ_EMPTY((head2))) { \
|
||||
*(head1)->stqh_last = (head2)->stqh_first; \
|
||||
(head1)->stqh_last = (head2)->stqh_last; \
|
||||
STAILQ_INIT((head2)); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef TAILQ_CONCAT
|
||||
#define TAILQ_CONCAT(head1, head2, field) do { \
|
||||
if (!TAILQ_EMPTY(head2)) { \
|
||||
@@ -121,13 +77,6 @@
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_FOREACH_SAFE
|
||||
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = STAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
#endif
|
||||
|
||||
#ifndef TAILQ_FOREACH_SAFE
|
||||
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = TAILQ_FIRST((head)); \
|
||||
@@ -196,6 +145,10 @@ void env_filter(void);
|
||||
void env_config(void);
|
||||
bool service_plugable(const char *service);
|
||||
int signal_setup(int sig, void (*handler)(int));
|
||||
pid_t exec_service(const char *, const char *);
|
||||
|
||||
#define service_start(service) exec_service(service, "start");
|
||||
#define service_stop(service) exec_service(service, "stop");
|
||||
|
||||
/* basename_c never modifies the argument. As such, if there is a trailing
|
||||
* slash then an empty string is returned. */
|
||||
@@ -208,4 +161,5 @@ _unused static const char *basename_c(const char *path)
|
||||
return (path);
|
||||
}
|
||||
|
||||
int parse_mode(mode_t *, char *);
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@ SRCS= libeinfo.c
|
||||
INCS= einfo.h
|
||||
VERSION_MAP= einfo.map
|
||||
|
||||
CFLAGS+= -I../includes
|
||||
CPPFLAGS+= -I../includes
|
||||
|
||||
MK= ../../mk
|
||||
include ${MK}/lib.mk
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*! @brief Color types to use */
|
||||
typedef enum
|
||||
{
|
||||
@@ -141,4 +143,5 @@ void eoutdentv(void);
|
||||
/*! @brief Prefix each einfo line with something */
|
||||
void eprefix(const char * __EINFO_RESTRICT);
|
||||
|
||||
__END_DECLS
|
||||
#endif
|
||||
|
||||
@@ -199,7 +199,8 @@ static const char *const color_terms[] = {
|
||||
/* strlcat and strlcpy are nice, shame glibc does not define them */
|
||||
#ifdef __GLIBC__
|
||||
# if ! defined (__UCLIBC__) && ! defined (__dietlibc__)
|
||||
static size_t strlcat(char *dst, const char *src, size_t size)
|
||||
static size_t
|
||||
strlcat(char *dst, const char *src, size_t size)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
@@ -226,18 +227,19 @@ static size_t strlcat(char *dst, const char *src, size_t size)
|
||||
return dst_n + (s - src);
|
||||
}
|
||||
|
||||
static size_t strlcpy(char *dst, const char *src, size_t size)
|
||||
static size_t
|
||||
strlcpy(char *dst, const char *src, size_t size)
|
||||
{
|
||||
const char *s = src;
|
||||
size_t n = size;
|
||||
|
||||
if (n && --n)
|
||||
do {
|
||||
if (! (*dst++ = *src++))
|
||||
if (!(*dst++ = *src++))
|
||||
break;
|
||||
} while (--n);
|
||||
|
||||
if (! n) {
|
||||
if (!n) {
|
||||
if (size)
|
||||
*dst = '\0';
|
||||
while (*src++);
|
||||
@@ -248,9 +250,10 @@ static size_t strlcpy(char *dst, const char *src, size_t size)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static bool yesno(const char *value)
|
||||
static bool
|
||||
yesno(const char *value)
|
||||
{
|
||||
if (! value) {
|
||||
if (!value) {
|
||||
errno = ENOENT;
|
||||
return false;
|
||||
}
|
||||
@@ -272,7 +275,8 @@ static bool yesno(const char *value)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool noyes(const char *value)
|
||||
static bool
|
||||
noyes(const char *value)
|
||||
{
|
||||
int serrno = errno;
|
||||
bool retval;
|
||||
@@ -280,26 +284,29 @@ static bool noyes(const char *value)
|
||||
errno = 0;
|
||||
retval = yesno(value);
|
||||
if (errno == 0) {
|
||||
retval = ! retval;
|
||||
retval = !retval;
|
||||
errno = serrno;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static bool is_quiet(void)
|
||||
static bool
|
||||
is_quiet(void)
|
||||
{
|
||||
return yesno(getenv("EINFO_QUIET"));
|
||||
}
|
||||
|
||||
static bool is_verbose(void)
|
||||
static bool
|
||||
is_verbose(void)
|
||||
{
|
||||
return yesno(getenv ("EINFO_VERBOSE"));
|
||||
}
|
||||
|
||||
/* Fake tgoto call - very crapy, but works for our needs */
|
||||
#ifndef HAVE_TERMCAP
|
||||
static char *tgoto(const char *cap, int a, int b)
|
||||
static char *
|
||||
tgoto(const char *cap, int a, int b)
|
||||
{
|
||||
static char buf[20];
|
||||
|
||||
@@ -308,22 +315,22 @@ static char *tgoto(const char *cap, int a, int b)
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool colour_terminal(FILE * __EINFO_RESTRICT f)
|
||||
static bool
|
||||
colour_terminal(FILE * __EINFO_RESTRICT f)
|
||||
{
|
||||
static int in_colour = -1;
|
||||
char *e;
|
||||
char *e, *ee, *end, *d, *p;
|
||||
int c;
|
||||
const char *_af = NULL;
|
||||
const char *_ce = NULL;
|
||||
const char *_ch = NULL;
|
||||
const char *_md = NULL;
|
||||
const char *_me = NULL;
|
||||
const char *_up = NULL;
|
||||
const char *_af = NULL, *_ce = NULL, *_ch = NULL;
|
||||
const char *_md = NULL, *_me = NULL, *_up = NULL;
|
||||
const char *bold;
|
||||
char tmp[100];
|
||||
char *p;
|
||||
unsigned int i = 0;
|
||||
#ifdef HAVE_TERMCAP
|
||||
char *bp;
|
||||
#endif
|
||||
|
||||
if (f && ! isatty(fileno(f)))
|
||||
if (f && !isatty(fileno(f)))
|
||||
return false;
|
||||
|
||||
if (noyes(getenv("EINFO_COLOR")))
|
||||
@@ -335,26 +342,23 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f)
|
||||
return true;
|
||||
|
||||
term_is_cons25 = false;
|
||||
|
||||
if (! term) {
|
||||
if (!term) {
|
||||
term = getenv("TERM");
|
||||
if (! term)
|
||||
if (!term)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcmp(term, "cons25") == 0)
|
||||
term_is_cons25 = true;
|
||||
|
||||
#ifdef HAVE_TERMCAP
|
||||
/* Check termcap to see if we can do colour or not */
|
||||
if (tgetent(termcapbuf, term) == 1) {
|
||||
char *bp = tcapbuf;
|
||||
|
||||
bp = tcapbuf;
|
||||
_af = tgetstr("AF", &bp);
|
||||
_ce = tgetstr("ce", &bp);
|
||||
_ch = tgetstr("ch", &bp);
|
||||
/* Our ch use also works with RI .... for now */
|
||||
if (! _ch)
|
||||
if (!_ch)
|
||||
_ch = tgetstr("RI", &bp);
|
||||
_md = tgetstr("md", &bp);
|
||||
_me = tgetstr("me", &bp);
|
||||
@@ -377,29 +381,29 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f)
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (! _af)
|
||||
if (!_af)
|
||||
_af = AF;
|
||||
if (! _ce)
|
||||
if (!_ce)
|
||||
_ce = CE;
|
||||
if (! _ch)
|
||||
if (!_ch)
|
||||
_ch = CH;
|
||||
if (! _md)
|
||||
if (!_md)
|
||||
_md = MD;
|
||||
if (! _me)
|
||||
if (!_me)
|
||||
_me = ME;
|
||||
if (! _up)
|
||||
if (!_up)
|
||||
_up = UP;
|
||||
#ifdef HAVE_TERMCAP
|
||||
}
|
||||
|
||||
if (! _af || ! _ce || ! _me || !_md || ! _up) {
|
||||
if (!_af || !_ce || !_me || !_md || !_up) {
|
||||
in_colour = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Many termcap databases don't have ch or RI even though they
|
||||
* do work */
|
||||
if (! _ch)
|
||||
if (!_ch)
|
||||
_ch = CH;
|
||||
#endif
|
||||
|
||||
@@ -407,33 +411,28 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f)
|
||||
p = ebuffer;
|
||||
for (i = 0; i < sizeof(ecolors) / sizeof(ecolors[0]); i++) {
|
||||
tmp[0] = '\0';
|
||||
|
||||
if (ecolors[i].name) {
|
||||
const char *bold = _md;
|
||||
bold = _md;
|
||||
c = ecolors[i].def;
|
||||
|
||||
/* See if the user wants to override the colour
|
||||
* We use a :col;bold: format like 2;1: for bold green
|
||||
* and 1;0: for a normal red */
|
||||
if ((e = getenv("EINFO_COLOR"))) {
|
||||
char *ee = strstr(e, ecolors[i].name);
|
||||
|
||||
ee = strstr(e, ecolors[i].name);
|
||||
if (ee)
|
||||
ee += strlen(ecolors[i].name);
|
||||
|
||||
if (ee && *ee == '=') {
|
||||
char *d = strdup(ee + 1);
|
||||
d = strdup(ee + 1);
|
||||
if (d) {
|
||||
char *end = strchr(d, ':');
|
||||
end = strchr(d, ':');
|
||||
if (end)
|
||||
*end = '\0';
|
||||
|
||||
c = atoi(d);
|
||||
|
||||
end = strchr(d, ';');
|
||||
if (end && *++end == '0')
|
||||
bold = _me;
|
||||
|
||||
free(d);
|
||||
}
|
||||
}
|
||||
@@ -460,7 +459,8 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int get_term_columns(FILE * __EINFO_RESTRICT stream)
|
||||
static int
|
||||
get_term_columns(FILE * __EINFO_RESTRICT stream)
|
||||
{
|
||||
struct winsize ws;
|
||||
char *env = getenv("COLUMNS");
|
||||
@@ -469,7 +469,7 @@ static int get_term_columns(FILE * __EINFO_RESTRICT stream)
|
||||
|
||||
if (env) {
|
||||
i = strtoimax(env, &p, 10);
|
||||
if (! *p)
|
||||
if (!*p)
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -479,13 +479,15 @@ static int get_term_columns(FILE * __EINFO_RESTRICT stream)
|
||||
return DEFAULT_COLS;
|
||||
}
|
||||
|
||||
void eprefix(const char *__EINFO_RESTRICT prefix)
|
||||
void
|
||||
eprefix(const char *__EINFO_RESTRICT prefix)
|
||||
{
|
||||
_eprefix = prefix;
|
||||
}
|
||||
hidden_def(eprefix)
|
||||
|
||||
static void elogv(int level, const char *__EINFO_RESTRICT fmt, va_list ap)
|
||||
static void
|
||||
elogv(int level, const char *__EINFO_RESTRICT fmt, va_list ap)
|
||||
{
|
||||
char *e = getenv("EINFO_LOG");
|
||||
va_list apc;
|
||||
@@ -500,7 +502,8 @@ static void elogv(int level, const char *__EINFO_RESTRICT fmt, va_list ap)
|
||||
}
|
||||
}
|
||||
|
||||
void elog(int level, const char *__EINFO_RESTRICT fmt, ...)
|
||||
void
|
||||
elog(int level, const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -510,7 +513,8 @@ void elog(int level, const char *__EINFO_RESTRICT fmt, ...)
|
||||
}
|
||||
hidden_def(elog)
|
||||
|
||||
static int _eindent(FILE * __EINFO_RESTRICT stream)
|
||||
static int
|
||||
_eindent(FILE * __EINFO_RESTRICT stream)
|
||||
{
|
||||
char *env = getenv("EINFO_INDENT");
|
||||
int amount = 0;
|
||||
@@ -525,7 +529,7 @@ static int _eindent(FILE * __EINFO_RESTRICT stream)
|
||||
amount = INDENT_MAX;
|
||||
|
||||
if (amount > 0)
|
||||
memset(indent, ' ', (size_t) amount);
|
||||
memset(indent, ' ', (size_t)amount);
|
||||
}
|
||||
|
||||
/* Terminate it */
|
||||
@@ -533,32 +537,32 @@ static int _eindent(FILE * __EINFO_RESTRICT stream)
|
||||
return fprintf(stream, "%s", indent);
|
||||
}
|
||||
|
||||
static const char *_ecolor(FILE * __EINFO_RESTRICT f, ECOLOR color)
|
||||
static const char *
|
||||
_ecolor(FILE * __EINFO_RESTRICT f, ECOLOR color)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (! colour_terminal(f))
|
||||
if (!colour_terminal(f))
|
||||
return "";
|
||||
|
||||
for (i = 0; i < sizeof(ecolors) / sizeof(ecolors[0]); i++) {
|
||||
for (i = 0; i < sizeof(ecolors) / sizeof(ecolors[0]); i++)
|
||||
if (ecolors[i].color == color)
|
||||
return ecolors_str[i];
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
hidden_def(ecolor)
|
||||
|
||||
const char *ecolor(ECOLOR color)
|
||||
const char *
|
||||
ecolor(ECOLOR color)
|
||||
{
|
||||
FILE *f = stdout;
|
||||
|
||||
/* Try and guess a valid tty */
|
||||
if (! isatty(fileno(f))) {
|
||||
if (!isatty(fileno(f))) {
|
||||
f = stderr;
|
||||
if (! isatty(fileno(f))) {
|
||||
if (!isatty(fileno(f))) {
|
||||
f = stdin;
|
||||
if (! isatty(fileno(f)))
|
||||
if (!isatty(fileno(f)))
|
||||
f = NULL;
|
||||
}
|
||||
}
|
||||
@@ -571,87 +575,69 @@ const char *ecolor(ECOLOR color)
|
||||
setenv("EINFO_LASTCMD", _cmd, 1); \
|
||||
}
|
||||
|
||||
#define EINFOVN(_file, _color) \
|
||||
{ \
|
||||
char *_e = getenv("EINFO_LASTCMD"); \
|
||||
if (_e && ! colour_terminal(_file) && strcmp(_e, "ewarn") != 0 && \
|
||||
_e[strlen (_e) - 1] == 'n') \
|
||||
fprintf(_file, "\n"); \
|
||||
if (_eprefix) \
|
||||
fprintf(_file, "%s%s%s|", _ecolor(_file, _color), _eprefix, _ecolor(_file, ECOLOR_NORMAL)); \
|
||||
fprintf(_file, " %s*%s ", _ecolor(_file, _color), _ecolor(_file, ECOLOR_NORMAL)); \
|
||||
retval += _eindent(_file); \
|
||||
{ \
|
||||
va_list _ap; \
|
||||
va_copy(_ap, ap); \
|
||||
retval += vfprintf(_file, fmt, _ap) + 3; \
|
||||
va_end(_ap); \
|
||||
} \
|
||||
if (colour_terminal(_file)) \
|
||||
fprintf(_file, "%s", flush); \
|
||||
}
|
||||
static int
|
||||
_einfo(FILE *f, ECOLOR color, const char *__EINFO_RESTRICT fmt, va_list va)
|
||||
|
||||
static int _einfovn(const char *__EINFO_RESTRICT fmt, va_list ap)
|
||||
{
|
||||
int retval = 0;
|
||||
char *last = getenv("EINFO_LASTCMD");
|
||||
va_list ap;
|
||||
|
||||
EINFOVN(stdout, ECOLOR_GOOD);
|
||||
if (last &&
|
||||
!colour_terminal(f) &&
|
||||
strcmp(last, "ewarn") != 0 &&
|
||||
last[strlen(last) - 1] == 'n')
|
||||
fprintf(f, "\n");
|
||||
if (_eprefix)
|
||||
fprintf(f, "%s%s%s|", _ecolor(f, color), _eprefix, _ecolor(f, ECOLOR_NORMAL));
|
||||
fprintf(f, " %s*%s ", _ecolor(f, color), _ecolor(f, ECOLOR_NORMAL));
|
||||
retval += _eindent(f);
|
||||
va_copy(ap, va);
|
||||
retval += vfprintf(f, fmt, ap) + 3;
|
||||
va_end(ap); \
|
||||
if (colour_terminal(f))
|
||||
fprintf(f, "%s", flush);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int _ewarnvn(const char *__EINFO_RESTRICT fmt, va_list ap)
|
||||
{
|
||||
int retval = 0;
|
||||
#define _einfovn(fmt, ap) _einfo(stdout, ECOLOR_GOOD, fmt, ap)
|
||||
#define _ewarnvn(fmt, ap) _einfo(stderr, ECOLOR_WARN, fmt, ap)
|
||||
#define _eerrorvn(fmt, ap) _einfo(stderr, ECOLOR_BAD, fmt, ap)
|
||||
|
||||
EINFOVN(stderr, ECOLOR_WARN);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int _eerrorvn(const char *__EINFO_RESTRICT fmt, va_list ap)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
EINFOVN(stderr, ECOLOR_BAD);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int einfon(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
einfon(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt || is_quiet())
|
||||
if (!fmt || is_quiet())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
retval = _einfovn(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("einfon");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(einfon)
|
||||
|
||||
int ewarnn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
ewarnn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt || is_quiet())
|
||||
if (!fmt || is_quiet())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
retval = _ewarnvn(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("ewarnn");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(ewarnn)
|
||||
|
||||
int eerrorn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
eerrorn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
@@ -659,58 +645,53 @@ int eerrorn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
retval = _eerrorvn(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("errorn");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(eerrorn)
|
||||
|
||||
int einfo(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
einfo(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt || is_quiet())
|
||||
if (!fmt || is_quiet())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
retval = _einfovn(fmt, ap);
|
||||
retval += printf("\n");
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("einfo");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(einfo)
|
||||
|
||||
int ewarn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
ewarn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt || is_quiet())
|
||||
if (!fmt || is_quiet())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
elogv(LOG_WARNING, fmt, ap);
|
||||
retval = _ewarnvn(fmt, ap);
|
||||
retval += fprintf(stderr, "\n");
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("ewarn");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(ewarn)
|
||||
|
||||
void ewarnx(const char *__EINFO_RESTRICT fmt, ...)
|
||||
void
|
||||
ewarnx(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (fmt && ! is_quiet()) {
|
||||
if (fmt && !is_quiet()) {
|
||||
va_start(ap, fmt);
|
||||
elogv(LOG_WARNING, fmt, ap);
|
||||
retval = _ewarnvn(fmt, ap);
|
||||
@@ -721,27 +702,26 @@ void ewarnx(const char *__EINFO_RESTRICT fmt, ...)
|
||||
}
|
||||
hidden_def(ewarnx)
|
||||
|
||||
int eerror(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
eerror(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt)
|
||||
if (!fmt)
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
elogv(LOG_ERR, fmt, ap);
|
||||
retval = _eerrorvn(fmt, ap);
|
||||
va_end(ap);
|
||||
retval += fprintf(stderr, "\n");
|
||||
|
||||
LASTCMD("eerror");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(eerror)
|
||||
|
||||
void eerrorx(const char *__EINFO_RESTRICT fmt, ...)
|
||||
void
|
||||
eerrorx(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -752,46 +732,43 @@ void eerrorx(const char *__EINFO_RESTRICT fmt, ...)
|
||||
va_end(ap);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
hidden_def(eerrorx)
|
||||
|
||||
int ebegin(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
ebegin(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt || is_quiet())
|
||||
if (!fmt || is_quiet())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
retval = _einfovn(fmt, ap);
|
||||
va_end(ap);
|
||||
retval += printf(" ...");
|
||||
if (colour_terminal(stdout))
|
||||
retval += printf("\n");
|
||||
|
||||
LASTCMD("ebegin");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(ebegin)
|
||||
|
||||
static void _eend(FILE * __EINFO_RESTRICT fp, int col, ECOLOR color,
|
||||
const char *msg)
|
||||
static void
|
||||
_eend(FILE * __EINFO_RESTRICT fp, int col, ECOLOR color, const char *msg)
|
||||
{
|
||||
int i;
|
||||
int cols;
|
||||
|
||||
if (! msg)
|
||||
if (!msg)
|
||||
return;
|
||||
|
||||
cols = get_term_columns(fp) - (strlen(msg) + 3);
|
||||
|
||||
/* cons25 is special - we need to remove one char, otherwise things
|
||||
* do not align properly at all. */
|
||||
if (! term) {
|
||||
if (!term) {
|
||||
term = getenv("TERM");
|
||||
if (term && strcmp(term, "cons25") == 0)
|
||||
term_is_cons25 = true;
|
||||
@@ -816,7 +793,8 @@ static void _eend(FILE * __EINFO_RESTRICT fp, int col, ECOLOR color,
|
||||
}
|
||||
}
|
||||
|
||||
static int _do_eend(const char *cmd, int retval, const char *__EINFO_RESTRICT fmt, va_list ap)
|
||||
static int
|
||||
_do_eend(const char *cmd, int retval, const char *__EINFO_RESTRICT fmt, va_list ap)
|
||||
{
|
||||
int col = 0;
|
||||
FILE *fp = stdout;
|
||||
@@ -832,54 +810,51 @@ static int _do_eend(const char *cmd, int retval, const char *__EINFO_RESTRICT fm
|
||||
col += fprintf(fp, "\n");
|
||||
va_end(apc);
|
||||
}
|
||||
|
||||
_eend(fp, col,
|
||||
retval == 0 ? ECOLOR_GOOD : ECOLOR_BAD,
|
||||
retval == 0 ? OK : NOT_OK);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int eend(int retval, const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
eend(int retval, const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (is_quiet())
|
||||
return retval;
|
||||
|
||||
va_start(ap, fmt);
|
||||
_do_eend("eend", retval, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("eend");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(eend)
|
||||
|
||||
int ewend(int retval, const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
ewend(int retval, const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (is_quiet())
|
||||
return retval;
|
||||
|
||||
va_start(ap, fmt);
|
||||
_do_eend("ewend", retval, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("ewend");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(ewend)
|
||||
|
||||
void ebracket(int col, ECOLOR color, const char *msg)
|
||||
void
|
||||
ebracket(int col, ECOLOR color, const char *msg)
|
||||
{
|
||||
_eend(stdout, col, color, msg);
|
||||
}
|
||||
hidden_def(ebracket)
|
||||
|
||||
void eindent(void)
|
||||
void
|
||||
eindent(void)
|
||||
{
|
||||
char *env = getenv("EINFO_INDENT");
|
||||
int amount = 0;
|
||||
@@ -891,11 +866,9 @@ void eindent(void)
|
||||
if (errno != 0)
|
||||
amount = 0;
|
||||
}
|
||||
|
||||
amount += INDENT_WIDTH;
|
||||
if (amount > INDENT_MAX)
|
||||
amount = INDENT_MAX;
|
||||
|
||||
snprintf(num, 10, "%08d", amount);
|
||||
setenv("EINFO_INDENT", num, 1);
|
||||
}
|
||||
@@ -908,16 +881,14 @@ void eoutdent(void)
|
||||
char num[10];
|
||||
int serrno = errno;
|
||||
|
||||
if (! env)
|
||||
if (!env)
|
||||
return;
|
||||
|
||||
errno = 0;
|
||||
amount = strtoimax(env, NULL, 0);
|
||||
if (errno != 0)
|
||||
amount = 0;
|
||||
else
|
||||
amount -= INDENT_WIDTH;
|
||||
|
||||
if (amount <= 0)
|
||||
unsetenv("EINFO_INDENT");
|
||||
else {
|
||||
@@ -928,86 +899,79 @@ void eoutdent(void)
|
||||
}
|
||||
hidden_def(eoutdent)
|
||||
|
||||
int einfovn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
einfovn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt || ! is_verbose())
|
||||
if (!fmt || !is_verbose())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
retval = _einfovn(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("einfovn");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(einfovn)
|
||||
|
||||
int ewarnvn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
ewarnvn(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt || ! is_verbose())
|
||||
if (!fmt || !is_verbose())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
retval = _ewarnvn(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("ewarnvn");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(ewarnvn)
|
||||
|
||||
int einfov(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
einfov(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt || ! is_verbose())
|
||||
if (!fmt || !is_verbose())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
retval = _einfovn(fmt, ap);
|
||||
retval += printf("\n");
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("einfov");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(einfov)
|
||||
|
||||
int ewarnv(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
ewarnv(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt || ! is_verbose())
|
||||
if (!fmt || !is_verbose())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
retval = _ewarnvn(fmt, ap);
|
||||
retval += printf("\n");
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("ewarnv");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(ewarnv)
|
||||
|
||||
int ebeginv(const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
ebeginv(const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (! fmt || ! is_verbose())
|
||||
if (!fmt || !is_verbose())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@@ -1016,55 +980,51 @@ int ebeginv(const char *__EINFO_RESTRICT fmt, ...)
|
||||
if (colour_terminal(stdout))
|
||||
retval += printf("\n");
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("ebeginv");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(ebeginv)
|
||||
|
||||
int eendv(int retval, const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
eendv(int retval, const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (! is_verbose())
|
||||
if (!is_verbose())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
_do_eend("eendv", retval, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("eendv");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(eendv)
|
||||
|
||||
int ewendv(int retval, const char *__EINFO_RESTRICT fmt, ...)
|
||||
int
|
||||
ewendv(int retval, const char *__EINFO_RESTRICT fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (! is_verbose())
|
||||
if (!is_verbose())
|
||||
return 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
_do_eend("ewendv", retval, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
LASTCMD("ewendv");
|
||||
|
||||
return retval;
|
||||
}
|
||||
hidden_def(ewendv)
|
||||
|
||||
void eindentv(void)
|
||||
void
|
||||
eindentv(void)
|
||||
{
|
||||
if (is_verbose())
|
||||
eindent ();
|
||||
eindent();
|
||||
}
|
||||
hidden_def(eindentv)
|
||||
|
||||
void eoutdentv(void)
|
||||
void
|
||||
eoutdentv(void)
|
||||
{
|
||||
if (is_verbose())
|
||||
eoutdent();
|
||||
|
||||
1
src/librc/.gitignore
vendored
1
src/librc/.gitignore
vendored
@@ -13,3 +13,4 @@ librc.a
|
||||
librc.so.1
|
||||
librc.so
|
||||
.depend
|
||||
rc.h
|
||||
|
||||
@@ -5,13 +5,38 @@ SRCS= librc.c librc-daemon.c librc-depend.c librc-misc.c \
|
||||
INCS= rc.h
|
||||
VERSION_MAP= rc.map
|
||||
|
||||
CFLAGS+= -DLIB=\"${LIBNAME}\"
|
||||
CFLAGS+= -DSYSCONFDIR=\"${SYSCONFDIR}\"
|
||||
LDADD+= ${LIBKVM}
|
||||
|
||||
CFLAGS+= -I../includes
|
||||
CPPFLAGS+= -I../includes
|
||||
|
||||
MK= ../../mk
|
||||
include ${MK}/lib.mk
|
||||
include ${MK}/cc.mk
|
||||
include ${MK}/debug.mk
|
||||
|
||||
# Massage our header file for our dirs
|
||||
SED_CMD= -e 's:@PREFIX@:${PREFIX}:g'
|
||||
SED_CMD+= -e 's:@LIB@:${LIBNAME}:g'
|
||||
SED_CMD+= -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
|
||||
_PKG_PREFIX_SH= if test -n "${PKG_PREFIX}" && test "${PKG_PREFIX}" != "/" && test "${PKG_PREFIX}" != "${PREFIX}"; then \
|
||||
echo "-e 's:@PKG_PREFIX@:${PKG_PREFIX}:g'"; \
|
||||
else \
|
||||
echo "-e 's:.*@PKG_PREFIX@.*:\#undef RC_PKG_PREFIX:g'"; \
|
||||
fi
|
||||
_PKG_PREFIX!= ${_PKG_PREFIX_SH}
|
||||
SED_CMD+= ${_PKG_PREFIX}$(shell ${_PKG_PREFIX_SH})
|
||||
|
||||
_LCL_PREFIX_SH= if test -n "${LOCAL_PREFIX}" && test "${LOCAL_PREFIX}" != "/" && test "${LOCAL_PREFIX}" != "${PREFIX}"; then \
|
||||
echo "-e 's:@LOCAL_PREFIX@:${LOCAL_PREFIX}:g'"; \
|
||||
else \
|
||||
echo "-e 's:@LOCAL_PREFIX@::g'"; \
|
||||
fi
|
||||
_LCL_PREFIX!= ${_LCL_PREFIX_SH}
|
||||
SED_CMD+= ${_LCL_PREFIX}$(shell ${_LCL_PREFIX_SH})
|
||||
|
||||
.SUFFIXES: .h.in .h
|
||||
.h.in.h:
|
||||
${SED} ${SED_CMD} $< > $@
|
||||
${SRCS}: rc.h
|
||||
|
||||
CLEANFILES+= rc.h
|
||||
|
||||
@@ -40,11 +40,11 @@ static size_t strlcpy(char *dst, const char *src, size_t size)
|
||||
|
||||
if (n && --n)
|
||||
do {
|
||||
if (! (*dst++ = *src++))
|
||||
if (!(*dst++ = *src++))
|
||||
break;
|
||||
} while (--n);
|
||||
|
||||
if (! n) {
|
||||
if (!n) {
|
||||
if (size)
|
||||
*dst = '\0';
|
||||
while (*src++);
|
||||
@@ -56,82 +56,60 @@ static size_t strlcpy(char *dst, const char *src, size_t size)
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
static bool pid_is_cmd(pid_t pid, const char *cmd)
|
||||
|
||||
static bool pid_is_exec(pid_t pid, const char *exec)
|
||||
{
|
||||
char buffer[32];
|
||||
FILE *fp;
|
||||
int c;
|
||||
bool retval = false;
|
||||
|
||||
exec = basename_c(exec);
|
||||
snprintf(buffer, sizeof(buffer), "/proc/%d/stat", pid);
|
||||
if ((fp = fopen(buffer, "r")) == NULL)
|
||||
return false;
|
||||
|
||||
while ((c = getc(fp)) != EOF && c != '(')
|
||||
;
|
||||
|
||||
if (c != '(') {
|
||||
if ((fp = fopen(buffer, "r"))) {
|
||||
while ((c = getc(fp)) != EOF && c != '(')
|
||||
;
|
||||
if (c == '(') {
|
||||
while ((c = getc(fp)) != EOF && c == *exec)
|
||||
exec++;
|
||||
if (c == ')' && *exec == '\0')
|
||||
retval = true;
|
||||
}
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
|
||||
while ((c = getc(fp)) != EOF && c == *cmd)
|
||||
cmd++;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return (c == ')' && *cmd == '\0') ? true : false;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static bool pid_is_exec(pid_t pid, const char *const *argv)
|
||||
static bool pid_is_argv(pid_t pid, const char *const *argv)
|
||||
{
|
||||
char cmdline[32];
|
||||
int fd;
|
||||
char buffer[PATH_MAX];
|
||||
char *p;
|
||||
int fd = -1;
|
||||
int r;
|
||||
|
||||
/* Check it's the right binary */
|
||||
snprintf (cmdline, sizeof (cmdline), "/proc/%u/exe", pid);
|
||||
memset (buffer, 0, sizeof (buffer));
|
||||
if (readlink(cmdline, buffer, sizeof(buffer)) != -1) {
|
||||
if (strcmp(*argv, buffer) == 0)
|
||||
return true;
|
||||
|
||||
/* We should cater for deleted binaries too */
|
||||
if (strlen(buffer) > 10) {
|
||||
p = buffer + (strlen(buffer) - 10);
|
||||
if (strcmp(p, " (deleted)") == 0) {
|
||||
*p = 0;
|
||||
if (strcmp(buffer, *argv) == 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
ssize_t bytes;
|
||||
|
||||
snprintf(cmdline, sizeof(cmdline), "/proc/%u/cmdline", pid);
|
||||
if ((fd = open(cmdline, O_RDONLY)) < 0)
|
||||
return false;
|
||||
|
||||
r = read(fd, buffer, sizeof(buffer));
|
||||
bytes = read(fd, buffer, sizeof(buffer));
|
||||
close(fd);
|
||||
if (bytes == -1)
|
||||
return false;
|
||||
|
||||
if (r == -1)
|
||||
return 0;
|
||||
|
||||
buffer[r] = 0;
|
||||
buffer[bytes] = '\0';
|
||||
p = buffer;
|
||||
while (*argv) {
|
||||
if (strcmp(*argv, p) != 0)
|
||||
return false;
|
||||
argv++;
|
||||
p += strlen(p) + 1;
|
||||
if ((unsigned) (p - buffer) > sizeof (buffer))
|
||||
if ((unsigned)(p - buffer) > sizeof(buffer))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd,
|
||||
RC_PIDLIST *rc_find_pids(const char *exec, const char *const *argv,
|
||||
uid_t uid, pid_t pid)
|
||||
{
|
||||
DIR *procdir;
|
||||
@@ -166,27 +144,21 @@ RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd,
|
||||
while ((entry = readdir(procdir)) != NULL) {
|
||||
if (sscanf(entry->d_name, "%d", &p) != 1)
|
||||
continue;
|
||||
|
||||
if (runscript_pid != 0 && runscript_pid == p)
|
||||
continue;
|
||||
|
||||
if (pid != 0 && pid != p)
|
||||
continue;
|
||||
|
||||
if (uid) {
|
||||
snprintf(buffer, sizeof(buffer), "/proc/%d", p);
|
||||
if (stat(buffer, &sb) != 0 || sb.st_uid != uid)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cmd && ! pid_is_cmd(p, cmd))
|
||||
if (exec && !pid_is_exec(p, exec))
|
||||
continue;
|
||||
|
||||
if (argv && ! cmd && !
|
||||
pid_is_exec(p, (const char *const *)argv))
|
||||
if (argv &&
|
||||
!pid_is_argv(p, (const char *const *)argv))
|
||||
continue;
|
||||
|
||||
if (! pids) {
|
||||
if (!pids) {
|
||||
pids = xmalloc(sizeof(*pids));
|
||||
LIST_INIT(pids);
|
||||
}
|
||||
@@ -195,7 +167,6 @@ RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd,
|
||||
LIST_INSERT_HEAD(pids, pi, entries);
|
||||
}
|
||||
closedir(procdir);
|
||||
|
||||
return pids;
|
||||
}
|
||||
librc_hidden_def(rc_find_pids)
|
||||
@@ -224,7 +195,7 @@ librc_hidden_def(rc_find_pids)
|
||||
# define _KVM_FLAGS O_RDONLY
|
||||
# endif
|
||||
|
||||
RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd,
|
||||
RC_PIDLIST *rc_find_pids(const char *exec, const char *const *argv,
|
||||
uid_t uid, pid_t pid)
|
||||
{
|
||||
static kvm_t *kd = NULL;
|
||||
@@ -258,39 +229,34 @@ RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (exec)
|
||||
exec = basename_c(exec);
|
||||
for (i = 0; i < processes; i++) {
|
||||
p = _GET_KINFO_PID(kp[i]);
|
||||
if (pid != 0 && pid != p)
|
||||
continue;
|
||||
|
||||
if (uid != 0 && uid != _GET_KINFO_UID(kp[i]))
|
||||
continue;
|
||||
|
||||
if (cmd) {
|
||||
if (! _GET_KINFO_COMM(kp[i]) ||
|
||||
strcmp(cmd, _GET_KINFO_COMM(kp[i])) != 0)
|
||||
if (exec) {
|
||||
if (!_GET_KINFO_COMM(kp[i]) ||
|
||||
strcmp(exec, _GET_KINFO_COMM(kp[i])) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (argv && *argv && ! cmd) {
|
||||
if (argv && *argv) {
|
||||
pargv = _KVM_GETARGV(kd, &kp[i], pargc);
|
||||
if (! pargv || ! *pargv)
|
||||
if (!pargv || !*pargv)
|
||||
continue;
|
||||
|
||||
arg = argv;
|
||||
match = 1;
|
||||
|
||||
while (*arg && *pargv)
|
||||
if (strcmp(*arg++, *pargv++) != 0) {
|
||||
match = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (! match)
|
||||
if (!match)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! pids) {
|
||||
if (!pids) {
|
||||
pids = xmalloc(sizeof(*pids));
|
||||
LIST_INIT(pids);
|
||||
}
|
||||
@@ -320,7 +286,7 @@ static bool _match_daemon(const char *path, const char *file,
|
||||
snprintf(ffile, sizeof(ffile), "%s/%s", path, file);
|
||||
fp = fopen(ffile, "r");
|
||||
|
||||
if (! fp)
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
while ((rc_getline(&line, &len, fp))) {
|
||||
@@ -329,7 +295,7 @@ static bool _match_daemon(const char *path, const char *file,
|
||||
TAILQ_REMOVE(match, m, entries);
|
||||
break;
|
||||
}
|
||||
if (! TAILQ_FIRST(match))
|
||||
if (!TAILQ_FIRST(match))
|
||||
break;
|
||||
}
|
||||
fclose(fp);
|
||||
@@ -339,14 +305,22 @@ static bool _match_daemon(const char *path, const char *file,
|
||||
return true;
|
||||
}
|
||||
|
||||
static RC_STRINGLIST *_match_list(const char* const* argv,
|
||||
const char *name, const char *pidfile)
|
||||
static RC_STRINGLIST *_match_list(const char *exec, const char* const* argv,
|
||||
const char *pidfile)
|
||||
{
|
||||
RC_STRINGLIST *match = rc_stringlist_new();
|
||||
int i = 0;
|
||||
size_t l;
|
||||
char *m;
|
||||
|
||||
if (exec) {
|
||||
l = strlen(exec) + 6;
|
||||
m = xmalloc(sizeof(char) * l);
|
||||
snprintf(m, l, "exec=%s", exec);
|
||||
rc_stringlist_add(match, m);
|
||||
free(m);
|
||||
}
|
||||
|
||||
while (argv && argv[i]) {
|
||||
l = strlen(*argv) + strlen("argv_=") + 16;
|
||||
m = xmalloc(sizeof(char) * l);
|
||||
@@ -355,14 +329,6 @@ static RC_STRINGLIST *_match_list(const char* const* argv,
|
||||
free(m);
|
||||
}
|
||||
|
||||
if (name) {
|
||||
l = strlen(name) + 6;
|
||||
m = xmalloc(sizeof (char) * l);
|
||||
snprintf(m, l, "name=%s", name);
|
||||
rc_stringlist_add(match, m);
|
||||
free(m);
|
||||
}
|
||||
|
||||
if (pidfile) {
|
||||
l = strlen(pidfile) + 9;
|
||||
m = xmalloc(sizeof (char) * l);
|
||||
@@ -374,8 +340,9 @@ static RC_STRINGLIST *_match_list(const char* const* argv,
|
||||
return match;
|
||||
}
|
||||
|
||||
bool rc_service_daemon_set(const char *service, const char *const *argv,
|
||||
const char *name, const char *pidfile, bool started)
|
||||
bool rc_service_daemon_set(const char *service, const char *exec,
|
||||
const char *const *argv,
|
||||
const char *pidfile, bool started)
|
||||
{
|
||||
char dirpath[PATH_MAX];
|
||||
char file[PATH_MAX];
|
||||
@@ -388,7 +355,7 @@ bool rc_service_daemon_set(const char *service, const char *const *argv,
|
||||
int i = 0;
|
||||
FILE *fp;
|
||||
|
||||
if (!(argv && *argv) && ! name && ! pidfile) {
|
||||
if (!exec && !pidfile) {
|
||||
errno = EINVAL;
|
||||
return false;
|
||||
}
|
||||
@@ -398,7 +365,7 @@ bool rc_service_daemon_set(const char *service, const char *const *argv,
|
||||
|
||||
/* Regardless, erase any existing daemon info */
|
||||
if ((dp = opendir(dirpath))) {
|
||||
match = _match_list(argv, name, pidfile);
|
||||
match = _match_list(exec, argv, pidfile);
|
||||
while ((d = readdir(dp))) {
|
||||
if (d->d_name[0] == '.')
|
||||
continue;
|
||||
@@ -407,7 +374,7 @@ bool rc_service_daemon_set(const char *service, const char *const *argv,
|
||||
dirpath, d->d_name);
|
||||
nfiles++;
|
||||
|
||||
if (! *oldfile) {
|
||||
if (!*oldfile) {
|
||||
if (_match_daemon(dirpath, d->d_name, match)) {
|
||||
unlink(file);
|
||||
strlcpy(oldfile, file, sizeof(oldfile));
|
||||
@@ -428,13 +395,13 @@ bool rc_service_daemon_set(const char *service, const char *const *argv,
|
||||
snprintf(file, sizeof(file), "%s/%03d",
|
||||
dirpath, nfiles + 1);
|
||||
if ((fp = fopen(file, "w"))) {
|
||||
fprintf(fp, "exec=");
|
||||
if (exec)
|
||||
fprintf(fp, "%s", exec);
|
||||
while (argv && argv[i]) {
|
||||
fprintf(fp, "argv_%d=%s\n", i, argv[i]);
|
||||
fprintf(fp, "\nargv_%d=%s", i, argv[i]);
|
||||
i++;
|
||||
}
|
||||
fprintf(fp, "name=");
|
||||
if (name)
|
||||
fprintf(fp, "%s", name);
|
||||
fprintf(fp, "\npidfile=");
|
||||
if (pidfile)
|
||||
fprintf(fp, "%s", pidfile);
|
||||
@@ -450,7 +417,8 @@ bool rc_service_daemon_set(const char *service, const char *const *argv,
|
||||
}
|
||||
librc_hidden_def(rc_service_daemon_set)
|
||||
|
||||
bool rc_service_started_daemon(const char *service, const char *const *argv,
|
||||
bool rc_service_started_daemon(const char *service,
|
||||
const char *exec, const char *const *argv,
|
||||
int indx)
|
||||
{
|
||||
char dirpath[PATH_MAX];
|
||||
@@ -460,12 +428,12 @@ bool rc_service_started_daemon(const char *service, const char *const *argv,
|
||||
DIR *dp;
|
||||
struct dirent *d;
|
||||
|
||||
if (!service || !(argv && *argv))
|
||||
if (!service || !exec)
|
||||
return false;
|
||||
|
||||
snprintf(dirpath, sizeof(dirpath), RC_SVCDIR "/daemons/%s",
|
||||
basename_c(service));
|
||||
match = _match_list(argv, NULL, NULL);
|
||||
match = _match_list(exec, argv, NULL);
|
||||
|
||||
if (indx > 0) {
|
||||
snprintf(file, sizeof(file), "%03d", indx);
|
||||
@@ -515,7 +483,7 @@ bool rc_service_daemons_crashed(const char *service)
|
||||
path += snprintf(dirpath, sizeof(dirpath), RC_SVCDIR "/daemons/%s",
|
||||
basename_c(service));
|
||||
|
||||
if (! (dp = opendir(dirpath)))
|
||||
if (!(dp = opendir(dirpath)))
|
||||
return false;
|
||||
|
||||
while ((d = readdir(dp))) {
|
||||
@@ -525,25 +493,25 @@ bool rc_service_daemons_crashed(const char *service)
|
||||
snprintf(path, sizeof(dirpath) - (path - dirpath), "/%s",
|
||||
d->d_name);
|
||||
fp = fopen(dirpath, "r");
|
||||
if (! fp)
|
||||
if (!fp)
|
||||
break;
|
||||
|
||||
while ((rc_getline(&line, &len, fp))) {
|
||||
p = line;
|
||||
if ((token = strsep(&p, "=")) == NULL || ! p)
|
||||
if ((token = strsep(&p, "=")) == NULL || !p)
|
||||
continue;
|
||||
|
||||
if (! *p)
|
||||
if (!*p)
|
||||
continue;
|
||||
|
||||
if (strncmp(token, "argv_", 5) == 0) {
|
||||
if (! list)
|
||||
list = rc_stringlist_new();
|
||||
rc_stringlist_add(list, p);
|
||||
} else if (strcmp(token, "exec") == 0) {
|
||||
if (strcmp(token, "exec") == 0) {
|
||||
if (exec)
|
||||
free(exec);
|
||||
exec = xstrdup(p);
|
||||
} else if (strncmp(token, "argv_", 5) == 0) {
|
||||
if (!list)
|
||||
list = rc_stringlist_new();
|
||||
rc_stringlist_add(list, p);
|
||||
} else if (strcmp(token, "name") == 0) {
|
||||
if (name)
|
||||
free(name);
|
||||
@@ -561,20 +529,21 @@ bool rc_service_daemons_crashed(const char *service)
|
||||
if ((fp = fopen(pidfile, "r"))) {
|
||||
if (fscanf(fp, "%d", &pid) == 1)
|
||||
retval = false;
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
free(pidfile);
|
||||
pidfile = NULL;
|
||||
|
||||
/* We have the pid, so no need to match on name */
|
||||
free (name);
|
||||
/* We have the pid, so no need to match on exec or name */
|
||||
free(exec);
|
||||
exec = NULL;
|
||||
free(name);
|
||||
name = NULL;
|
||||
} else {
|
||||
if (exec) {
|
||||
if (! list)
|
||||
if (!list)
|
||||
list = rc_stringlist_new();
|
||||
if (! TAILQ_FIRST(list))
|
||||
if (!TAILQ_FIRST(list))
|
||||
rc_stringlist_add(list, exec);
|
||||
|
||||
free(exec);
|
||||
@@ -594,9 +563,10 @@ bool rc_service_daemons_crashed(const char *service)
|
||||
}
|
||||
}
|
||||
|
||||
if (! retval) {
|
||||
if ((pids = rc_find_pids((const char *const *)argv,
|
||||
name, 0, pid)))
|
||||
if (!retval) {
|
||||
if ((pids = rc_find_pids(exec,
|
||||
(const char *const *)argv,
|
||||
0, pid)))
|
||||
{
|
||||
p1 = LIST_FIRST(pids);
|
||||
while (p1) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,38 +31,35 @@
|
||||
|
||||
#include "librc.h"
|
||||
|
||||
bool rc_yesno (const char *value)
|
||||
bool rc_yesno(const char *value)
|
||||
{
|
||||
if (! value) {
|
||||
if (!value) {
|
||||
errno = ENOENT;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcasecmp (value, "yes") == 0 ||
|
||||
strcasecmp (value, "y") == 0 ||
|
||||
strcasecmp (value, "true") == 0 ||
|
||||
strcasecmp (value, "1") == 0)
|
||||
if (strcasecmp(value, "yes") == 0 ||
|
||||
strcasecmp(value, "y") == 0 ||
|
||||
strcasecmp(value, "true") == 0 ||
|
||||
strcasecmp(value, "1") == 0)
|
||||
return true;
|
||||
|
||||
if (strcasecmp (value, "no") != 0 &&
|
||||
strcasecmp (value, "n") != 0 &&
|
||||
strcasecmp (value, "false") != 0 &&
|
||||
strcasecmp (value, "0") != 0)
|
||||
if (strcasecmp(value, "no") != 0 &&
|
||||
strcasecmp(value, "n") != 0 &&
|
||||
strcasecmp(value, "false") != 0 &&
|
||||
strcasecmp(value, "0") != 0)
|
||||
errno = EINVAL;
|
||||
|
||||
return false;
|
||||
}
|
||||
librc_hidden_def(rc_yesno)
|
||||
|
||||
ssize_t rc_getline (char **line, size_t *len, FILE *fp)
|
||||
ssize_t rc_getline(char **line, size_t *len, FILE *fp)
|
||||
{
|
||||
char *p;
|
||||
size_t last = 0;
|
||||
|
||||
if (feof(fp))
|
||||
return 0;
|
||||
|
||||
do {
|
||||
while(!feof(fp)) {
|
||||
if (*line == NULL || last != 0) {
|
||||
*len += BUFSIZ;
|
||||
*line = xrealloc(*line, *len);
|
||||
@@ -71,12 +68,11 @@ ssize_t rc_getline (char **line, size_t *len, FILE *fp)
|
||||
memset(p, 0, BUFSIZ);
|
||||
fgets(p, BUFSIZ, fp);
|
||||
last += strlen(p);
|
||||
} while (! feof(fp) && (*line)[last - 1] != '\n');
|
||||
|
||||
/* Trim the trailing newline */
|
||||
if (**line && (*line)[last - 1] == '\n')
|
||||
(*line)[last - 1] = '\0';
|
||||
|
||||
if (last && (*line)[last - 1] == '\n') {
|
||||
(*line)[last - 1] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return last;
|
||||
}
|
||||
librc_hidden_def(rc_getline)
|
||||
@@ -108,7 +104,7 @@ RC_STRINGLIST *rc_config_list(const char *file)
|
||||
if (token[strlen(token) - 1] == '\n')
|
||||
token[strlen(token) - 1] = 0;
|
||||
|
||||
if (! list)
|
||||
if (!list)
|
||||
list = rc_stringlist_new();
|
||||
rc_stringlist_add(list, token);
|
||||
}
|
||||
@@ -135,17 +131,21 @@ RC_STRINGLIST *rc_config_load(const char *file)
|
||||
char *p;
|
||||
|
||||
list = rc_config_list(file);
|
||||
if (! list)
|
||||
if (!list)
|
||||
return NULL;
|
||||
|
||||
config = rc_stringlist_new();
|
||||
TAILQ_FOREACH(line, list, entries) {
|
||||
/* Get entry */
|
||||
p = line->value;
|
||||
if (! p)
|
||||
continue;
|
||||
if (strncmp(p, "export ", 7) == 0)
|
||||
p += 7;
|
||||
if (! (token = strsep(&p, "=")))
|
||||
continue;
|
||||
|
||||
entry = xstrdup (token);
|
||||
entry = xstrdup(token);
|
||||
/* Preserve shell coloring */
|
||||
if (*p == '$')
|
||||
token = line->value;
|
||||
@@ -157,15 +157,15 @@ RC_STRINGLIST *rc_config_load(const char *file)
|
||||
|
||||
/* Drop a newline if that's all we have */
|
||||
if (token) {
|
||||
i = strlen (token) - 1;
|
||||
i = strlen(token) - 1;
|
||||
if (token[i] == '\n')
|
||||
token[i] = 0;
|
||||
|
||||
i = strlen (entry) + strlen (token) + 2;
|
||||
i = strlen(entry) + strlen(token) + 2;
|
||||
newline = xmalloc(sizeof(char) * i);
|
||||
snprintf(newline, i, "%s=%s", entry, token);
|
||||
} else {
|
||||
i = strlen (entry) + 2;
|
||||
i = strlen(entry) + 2;
|
||||
newline = xmalloc(sizeof(char) * i);
|
||||
snprintf(newline, i, "%s=", entry);
|
||||
}
|
||||
@@ -176,7 +176,7 @@ RC_STRINGLIST *rc_config_load(const char *file)
|
||||
TAILQ_FOREACH(cline, config, entries) {
|
||||
p = strchr(cline->value, '=');
|
||||
if (p && strncmp(entry, cline->value,
|
||||
(size_t) (p - cline->value)) == 0)
|
||||
(size_t)(p - cline->value)) == 0)
|
||||
{
|
||||
/* We have a match now - to save time we directly replace it */
|
||||
free(cline->value);
|
||||
@@ -186,7 +186,7 @@ RC_STRINGLIST *rc_config_load(const char *file)
|
||||
}
|
||||
}
|
||||
|
||||
if (! replaced) {
|
||||
if (!replaced) {
|
||||
rc_stringlist_add(config, newline);
|
||||
free(newline);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,33 @@ bool rc_stringlist_delete(RC_STRINGLIST *list, const char *value)
|
||||
}
|
||||
librc_hidden_def(rc_stringlist_delete)
|
||||
|
||||
RC_STRING *rc_stringlist_find(RC_STRINGLIST *list, const char *value)
|
||||
{
|
||||
RC_STRING *s;
|
||||
|
||||
if (list) {
|
||||
TAILQ_FOREACH(s, list, entries)
|
||||
if (strcmp(s->value, value) == 0)
|
||||
return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
librc_hidden_def(rc_stringlist_find)
|
||||
|
||||
RC_STRINGLIST *rc_stringlist_split(const char *value, const char *sep)
|
||||
{
|
||||
RC_STRINGLIST *list = rc_stringlist_new();
|
||||
char *d = xstrdup(value);
|
||||
char *p = d, *token;
|
||||
|
||||
while ((token = strsep(&p, sep)))
|
||||
rc_stringlist_add(list, token);
|
||||
free(d);
|
||||
|
||||
return list;
|
||||
}
|
||||
librc_hidden_def(rc_stringlist_split)
|
||||
|
||||
void rc_stringlist_sort(RC_STRINGLIST **list)
|
||||
{
|
||||
RC_STRINGLIST *l = *list;
|
||||
|
||||
@@ -35,7 +35,6 @@ const char librc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
#define RC_RUNLEVEL RC_SVCDIR "/softlevel"
|
||||
|
||||
@@ -214,6 +213,13 @@ const char *rc_sys(void)
|
||||
return RC_SYS_JAIL;
|
||||
#endif
|
||||
|
||||
#ifdef __NetBSD__
|
||||
if (exists("/kern/xen/privcmd"))
|
||||
return RC_SYS_XEN0;
|
||||
if (exists("/kern/xen"))
|
||||
return RC_SYS_XENU;
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
if (exists("/proc/xen")) {
|
||||
if (file_regex("/proc/xen/capabilities", "control_d"))
|
||||
@@ -224,9 +230,11 @@ const char *rc_sys(void)
|
||||
else if (file_regex("/proc/self/status",
|
||||
"(s_context|VxID):[[:space:]]*[1-9]"))
|
||||
return RC_SYS_VSERVER;
|
||||
else if (exists("/proc/vz/veinfo") && !exists("/proc/vz/version"))
|
||||
return RC_SYS_OPENVZ;
|
||||
else if (file_regex("/proc/self/status",
|
||||
"envID:[[:space:]]*[1-9]"))
|
||||
return RC_SYS_OPENVZ;
|
||||
return RC_SYS_OPENVZ; /* old test */
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
@@ -494,7 +502,7 @@ bool rc_service_mark(const char *service, const RC_SERVICE state)
|
||||
base = basename_c(service);
|
||||
|
||||
if (state != RC_SERVICE_STOPPED) {
|
||||
if (! exists(init)) {
|
||||
if (!exists(init)) {
|
||||
free(init);
|
||||
return false;
|
||||
}
|
||||
@@ -540,7 +548,10 @@ bool rc_service_mark(const char *service, const RC_SERVICE state)
|
||||
symlink(init, was);
|
||||
skip_wasinactive = true;
|
||||
}
|
||||
unlink(file);
|
||||
if (unlink(file) == -1) {
|
||||
free(init);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -673,95 +684,6 @@ bool rc_service_value_set(const char *service, const char *option,
|
||||
}
|
||||
librc_hidden_def(rc_service_value_set)
|
||||
|
||||
static pid_t _exec_service(const char *service, const char *arg)
|
||||
{
|
||||
char *file;
|
||||
char fifo[PATH_MAX];
|
||||
pid_t pid = -1;
|
||||
sigset_t full;
|
||||
sigset_t old;
|
||||
struct sigaction sa;
|
||||
|
||||
file = rc_service_resolve(service);
|
||||
if (! exists(file)) {
|
||||
rc_service_mark(service, RC_SERVICE_STOPPED);
|
||||
free(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We create a fifo so that other services can wait until we complete */
|
||||
snprintf(fifo, sizeof(fifo), RC_SVCDIR "/exclusive/%s",
|
||||
basename_c(service));
|
||||
if (mkfifo(fifo, 0600) != 0 && errno != EEXIST) {
|
||||
free(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We need to block signals until we have forked */
|
||||
memset(&sa, 0, sizeof (sa));
|
||||
sa.sa_handler = SIG_DFL;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sigfillset(&full);
|
||||
sigprocmask(SIG_SETMASK, &full, &old);
|
||||
|
||||
if ((pid = fork()) == 0) {
|
||||
/* Restore default handlers */
|
||||
sigaction(SIGCHLD, &sa, NULL);
|
||||
sigaction(SIGHUP, &sa, NULL);
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
sigaction(SIGQUIT, &sa, NULL);
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
sigaction(SIGUSR1, &sa, NULL);
|
||||
sigaction(SIGWINCH, &sa, NULL);
|
||||
|
||||
/* Unmask signals */
|
||||
sigprocmask(SIG_SETMASK, &old, NULL);
|
||||
|
||||
/* Safe to run now */
|
||||
execl(file, file, arg, (char *) NULL);
|
||||
fprintf(stderr, "unable to exec `%s': %s\n",
|
||||
file, strerror(errno));
|
||||
unlink(fifo);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (pid == -1)
|
||||
fprintf(stderr, "fork: %s\n",strerror (errno));
|
||||
|
||||
sigprocmask(SIG_SETMASK, &old, NULL);
|
||||
|
||||
free(file);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
pid_t rc_service_stop(const char *service)
|
||||
{
|
||||
RC_SERVICE state = rc_service_state(service);
|
||||
|
||||
if (state & RC_SERVICE_FAILED)
|
||||
return -1;
|
||||
|
||||
if (state & RC_SERVICE_STOPPED)
|
||||
return 0;
|
||||
|
||||
return _exec_service(service, "stop");
|
||||
}
|
||||
librc_hidden_def(rc_service_stop)
|
||||
|
||||
pid_t rc_service_start(const char *service)
|
||||
{
|
||||
RC_SERVICE state = rc_service_state(service);
|
||||
|
||||
if (state & RC_SERVICE_FAILED)
|
||||
return -1;
|
||||
|
||||
if (! state & RC_SERVICE_STOPPED)
|
||||
return 0;
|
||||
|
||||
return _exec_service(service, "start");
|
||||
}
|
||||
librc_hidden_def(rc_service_start)
|
||||
|
||||
bool rc_service_schedule_start(const char *service,
|
||||
const char *service_to_start)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user