Compare commits
37 Commits
openrc-0.9
...
openrc-0.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
467f91d870 | ||
|
|
cc45abb77b | ||
|
|
40576a32d3 | ||
|
|
483db945e1 | ||
|
|
17a1529416 | ||
|
|
815952a65a | ||
|
|
76fec58633 | ||
|
|
d8bbeb184f | ||
|
|
453d13296d | ||
|
|
c21c1f1e59 | ||
|
|
c7cc685458 | ||
|
|
ef1ff1b4f2 | ||
|
|
0510c473d4 | ||
|
|
9a3d6c7600 | ||
|
|
a5ba2f3264 | ||
|
|
62f4438376 | ||
|
|
0bbb764f70 | ||
|
|
20df56f0b2 | ||
|
|
66e99b6d63 | ||
|
|
260b61e9d8 | ||
|
|
5b1aaf8cc8 | ||
|
|
5994e55937 | ||
|
|
3f2e9c4e1f | ||
|
|
476034dd95 | ||
|
|
37294b4e82 | ||
|
|
16661d02e9 | ||
|
|
f46626dcfc | ||
|
|
5a3599df8a | ||
|
|
e3b39a677b | ||
|
|
27713e3a41 | ||
|
|
5066d40ac8 | ||
|
|
f94e883633 | ||
|
|
b1da4dcb99 | ||
|
|
9a539ebbe1 | ||
|
|
9c77502f96 | ||
|
|
ecf77254bb | ||
|
|
9f95878bbd |
7
Makefile
7
Makefile
@@ -4,12 +4,7 @@
|
||||
|
||||
include Makefile.inc
|
||||
|
||||
SUBDIR= conf.d etc init.d local.d man scripts sh src
|
||||
|
||||
# Build our old net foo or not
|
||||
ifeq (${MKOLDNET},yes)
|
||||
SUBDIR+= net doc
|
||||
endif
|
||||
SUBDIR= conf.d doc etc init.d local.d man net scripts sh src
|
||||
|
||||
# Build pkgconfig or not
|
||||
MKPKGCONFIG?= yes
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
NAME= openrc
|
||||
VERSION= 0.9.4
|
||||
VERSION= 0.9.6
|
||||
PKG= ${NAME}-${VERSION}
|
||||
|
||||
2
README
2
README
@@ -14,9 +14,9 @@ MKPAM=pam
|
||||
MKPKGCONFIG=no
|
||||
MKRCSYS=prefix
|
||||
MKSELINUX=yes
|
||||
MKSTATICLIBS=no
|
||||
MKTERMCAP=ncurses
|
||||
MKTERMCAP=termcap
|
||||
MKOLDNET=yes
|
||||
PKG_PREFIX=/usr/pkg
|
||||
LOCAL_PREFIX=/usr/local
|
||||
PREFIX=/usr/local
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
The following applies only to the newnet stack, which is not presently
|
||||
maintained in OpenRC. The oldnet stack is maintained instead.
|
||||
- Robin H. Johnson <robbat2@gentoo.org>, 2011/02/21
|
||||
|
||||
OpenRC Network Ideals
|
||||
---------------------
|
||||
|
||||
The new style networking for OpenRC is very simplistic - provide a basic means
|
||||
of configuring static interface address and routes whilst allowing the
|
||||
possibility to run any command at any point.
|
||||
|
||||
In a nutshell, init.d/network is a wrapper around ifconfig(8) and
|
||||
init.d/staticroute is wrapper around route(8).
|
||||
|
||||
In the Perfect World (TM) ifconfig should be able to configure everything
|
||||
about the interface easily * . The BSD family almost get this right and Linux
|
||||
epically fails.
|
||||
|
||||
* Only static configuration, including link setup.
|
||||
For dynamic, static, IPv4LL, arping and per ssid IPv4 setup dhcpcd-5.x
|
||||
provides your needs.
|
||||
|
||||
It fails because there are many tools to do the same job and often have
|
||||
vastly different syntax where they could be similar. In other words, there
|
||||
is no coherence.
|
||||
|
||||
OpenRC-0.4.x and older (inc Gentoo baselayout-1) had a collection of scripts
|
||||
for each tool and allowed a script per interface. Over the years, this design
|
||||
has proven very hard to maintain as each user has their own idea of how
|
||||
things should work. Also, there were (and still are) race conditions.
|
||||
|
||||
So where do we go from here?
|
||||
Well, it's possible to use the new network scripts using the tools
|
||||
currently available. It's just harder as you have to know them and their
|
||||
documentation can be lacking at times.
|
||||
The correct end goal is a BSD style ifconfig tool.
|
||||
I've started work on it, but the project has stalled somewhat.
|
||||
It's display only right now and the source is not yet publicly available.
|
||||
If you have the skills and share the vision then contact me privately and
|
||||
we'll take it from there.
|
||||
@@ -1,19 +1,23 @@
|
||||
DIR= ${CONFDIR}
|
||||
CONF= bootmisc fsck hostname localmount network staticroute urandom
|
||||
CONF= bootmisc fsck hostname localmount network staticroute urandom \
|
||||
${CONF-${OS}}
|
||||
|
||||
TARGETS+= network staticroute
|
||||
CLEANFILES+= network staticroute
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/os.mk
|
||||
include Makefile.${OS}
|
||||
|
||||
CONF-FreeBSD= ipfw moused powerd rarpd savecore syscons
|
||||
|
||||
CONF-Linux= consolefont dmesg hwclock keymaps killprocs modules
|
||||
|
||||
CONF-NetBSD= moused rarpd savecore
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
|
||||
SOS?= BSD
|
||||
network: network.in network${SFX}
|
||||
cat $^ > $@
|
||||
|
||||
network: network.in network.${SOS}
|
||||
cp $@.in $@
|
||||
[ -e $@.${SOS} ] && cat $@.${SOS} >> $@ || true
|
||||
|
||||
staticroute: staticroute.${SOS}
|
||||
cp $@.${SOS} $@
|
||||
staticroute: staticroute${SFX}
|
||||
cp $@${SFX} $@
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
CONF+= ipfw moused powerd rarpd savecore syscons
|
||||
@@ -1,2 +0,0 @@
|
||||
CONF+= consolefont dmesg hwclock keymaps killprocs modules
|
||||
SOS= Linux
|
||||
@@ -1 +0,0 @@
|
||||
CONF+= moused rarpd savecore
|
||||
@@ -13,6 +13,13 @@
|
||||
#fsck_passno=">1"
|
||||
#fsck_passno="<2"
|
||||
|
||||
# If passno is not enough granularity, you can also specify mountpoints to
|
||||
# check. This should NOT be used for the default non-multiplexed fsck, or your
|
||||
# system might not be checked. Additionally, it is mutually exclusive with
|
||||
# the fsck_passno setting.
|
||||
#fsck_mnt=""
|
||||
#fsck_mnt="/home"
|
||||
|
||||
# Most modern fs's don't require a full fsck on boot, but for those that do
|
||||
# it may be advisable to skip this when running on battery.
|
||||
# WARNING: Do not turn this off if you have any JFS partitions.
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
DIR= ${DOCDIR}/openrc
|
||||
SRCS= net.example.in
|
||||
INC= net.example
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/os.mk
|
||||
include Makefile.${OS}
|
||||
|
||||
%.example.in: %.example${SFX}
|
||||
${CP} $< $@
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
SRCS+= net.example.in
|
||||
|
||||
.SUFFIXES: .BSD.in
|
||||
.BSD.in:
|
||||
${CP} $< $@
|
||||
@@ -1,5 +0,0 @@
|
||||
SRCS+= net.example.in
|
||||
|
||||
.SUFFIXES: .Linux.in
|
||||
.Linux.in:
|
||||
${CP} $< $@
|
||||
@@ -1,5 +0,0 @@
|
||||
SRCS+= net.example.in
|
||||
|
||||
.SUFFIXES: .BSD.in
|
||||
.BSD.in:
|
||||
${CP} $< $@
|
||||
@@ -350,7 +350,7 @@
|
||||
# By default we don't wait for wpa_supplicant to associate and authenticate.
|
||||
# If you need to change this behaviour then you don't know how our scripts work
|
||||
# and setting this value could cause strange things to happen.
|
||||
# If you would like to, so can specify how long in seconds.
|
||||
# If you would like it to wait, you can specify how long in seconds.
|
||||
#associate_timeout_eth0=60
|
||||
# A value of 0 means wait forever.
|
||||
|
||||
@@ -581,6 +581,18 @@
|
||||
# NOTE: depend functions only work in /etc/conf.d/net
|
||||
# and not in profile configs such as /etc/conf.d/net.foo
|
||||
|
||||
# MAC-VLAN support
|
||||
# The following configuration can be used to create a new interface 'macvlan0'
|
||||
# linked to 'eth0'
|
||||
#macvlan_macvlan0="eth0"
|
||||
|
||||
# MAC-VLAN mode (private, vepa, bridge, passtru)
|
||||
#mode_macvlan0="private"
|
||||
|
||||
# IP address, MAC address, ... are configured as a normal interface
|
||||
#config_macvlan0="192.168.20.20/24"
|
||||
#mac_macvlan0="00:50:06:20:20:20"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Bonding
|
||||
# For link bonding/trunking on 2.4 kernels, or kernels without sysfs
|
||||
@@ -827,9 +839,9 @@
|
||||
|
||||
# Below is an example of configuring the bridge
|
||||
# Consult "man brctl" for more details
|
||||
#brctl_br0="setfd 0
|
||||
#sethello 0
|
||||
#stp off"
|
||||
#brctl_br0="setfd 15
|
||||
#sethello 2
|
||||
#stp on"
|
||||
|
||||
# You can also configure the bridge or bridge members via sysfs on 2.6 kernels
|
||||
# or newer. See the kernel bridge documentation for a description of these
|
||||
|
||||
22
etc/Makefile
22
etc/Makefile
@@ -1,17 +1,33 @@
|
||||
DIR= ${SYSCONFDIR}
|
||||
CONF= rc.conf
|
||||
SRCS= rc.conf.in rc.in rc.shutdown.in
|
||||
BIN= ${BIN-${OS}}
|
||||
CONF= rc.conf ${BIN-${OS}}
|
||||
|
||||
CLEANFILES+= rc.conf
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/os.mk
|
||||
include Makefile.${OS}
|
||||
|
||||
SED_EXTRA-FreeBSD= -e 's:@TERM@:cons25:g'
|
||||
BIN-FreeBSD= rc rc.shutdown rc.devd
|
||||
CONF-FreeBSD= devd.conf
|
||||
|
||||
SED_EXTRA-Linux= -e 's:@TERM@:wsvt25:g'
|
||||
BIN-Linux=
|
||||
CONF-Linux=
|
||||
|
||||
SED_EXTRA-NetBSD= -e 's:@TERM@:wsvt25:g'
|
||||
BIN-NetBSD= rc rc.shutdown
|
||||
CONF-NetBSD=
|
||||
|
||||
SED_EXTRA= ${SED_EXTRA-${OS}}
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
|
||||
# We can't use "ifndef" here because that treats set-but-empty
|
||||
# as not-set which is not what we want
|
||||
MKRCSYS ?= automagicplease
|
||||
ifeq ($(MKRCSYS),automagicplease)
|
||||
ifeq (${MKRCSYS},automagicplease)
|
||||
# If the user isn't picking a default, then have the
|
||||
# config go with runtime automagic detection #357247
|
||||
rc.conf: SED_EXTRA += -e '/^rc_sys=""/s:^:\#:'
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
SED_EXTRA= -e 's:@TERM@:cons25:g'
|
||||
SRCS+= rc.conf.in rc.in rc.shutdown.in
|
||||
CONF+= devd.conf
|
||||
BIN+= rc rc.shutdown rc.devd
|
||||
@@ -1,2 +0,0 @@
|
||||
SED_EXTRA= -e 's:@TERM@:wsvt25:g'
|
||||
SRCS+= rc.conf.in rc.in rc.shutdown.in
|
||||
@@ -1,3 +0,0 @@
|
||||
SED_EXTRA= -e 's:@TERM@:wsvt25:g'
|
||||
SRCS+= rc.conf.in rc.in rc.shutdown.in
|
||||
BIN+= rc rc.shutdown
|
||||
@@ -7,5 +7,5 @@ MK= ../mk
|
||||
|
||||
SED_EXTRA+= -e 's:@VARBASE@:/var:g'
|
||||
|
||||
include ${MK}/os.mk
|
||||
include ${MK}/scripts.mk
|
||||
include Makefile.${OS}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
PKG_PREFIX?= /usr/local
|
||||
@@ -1 +0,0 @@
|
||||
PKG_PREFIX?=/usr
|
||||
@@ -1 +0,0 @@
|
||||
PKG_PREFIX?= /usr/pkg
|
||||
@@ -1,25 +1,42 @@
|
||||
DIR= ${INITDIR}
|
||||
SRCS= bootmisc.in fsck.in hostname.in local.in localmount.in netmount.in \
|
||||
network.in root.in savecache.in staticroute.in swap.in swclock.in \
|
||||
sysctl.in urandom.in
|
||||
sysctl.in urandom.in ${SRCS-${OS}}
|
||||
BIN= ${OBJS}
|
||||
|
||||
# Build our old net foo or not
|
||||
ifeq (${MKOLDNET},yes)
|
||||
_OLDNET= net.lo
|
||||
endif
|
||||
_NET_LO= ${_OLDNET}
|
||||
|
||||
INSTALLAFTER= _installafter_${_NET_LO}
|
||||
CLEANFILES+= ${_NET_LO}
|
||||
TARGETS+= ${_NET_LO}
|
||||
INSTALLAFTER= _installafter_net.lo
|
||||
CLEANFILES+= net.lo
|
||||
TARGETS+= net.lo
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/os.mk
|
||||
include Makefile.${OS}
|
||||
|
||||
NET_LO-FreeBSD= net.lo0
|
||||
# Generic BSD scripts
|
||||
SRCS-FreeBSD= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \
|
||||
rpcbind.in savecore.in syslogd.in
|
||||
# These are FreeBSD specific
|
||||
SRCS-FreeBSD+= adjkerntz.in devd.in dumpon.in ipfw.in mixer.in nscd.in \
|
||||
powerd.in syscons.in
|
||||
|
||||
NET_LO-Linux= net.lo
|
||||
SRCS-Linux= devfs.in dmesg.in hwclock.in consolefont.in keymaps.in \
|
||||
killprocs.in modules.in mount-ro.in mtab.in numlock.in \
|
||||
procfs.in sysfs.in termencoding.in migrate-run.in
|
||||
|
||||
NET_LO-NetBSD= net.lo0
|
||||
# Generic BSD scripts
|
||||
SRCS-NetBSD= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \
|
||||
rpcbind.in savecore.in syslogd.in
|
||||
# These are NetBSD specific
|
||||
SRCS-NetBSD+= devdb.in swap-blk.in ttys.in wscons.in
|
||||
|
||||
%.in: %${SFX}
|
||||
sed ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
|
||||
_installafter_: realinstall
|
||||
|
||||
_installafter_net.lo: realinstall
|
||||
${INSTALL} -m ${BINMODE} net.lo ${DESTDIR}/${INITDIR}/${NET_LO}
|
||||
${INSTALL} -m ${BINMODE} net.lo ${DESTDIR}/${INITDIR}/${NET_LO-${OS}}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
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 FreeBSD specific
|
||||
SRCS+= adjkerntz.in devd.in dumpon.in ipfw.in mixer.in nscd.in \
|
||||
powerd.in syscons.in
|
||||
|
||||
.SUFFIXES: .BSD.in
|
||||
.BSD.in:
|
||||
sed ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
@@ -1,9 +0,0 @@
|
||||
NET_LO= net.lo
|
||||
|
||||
SRCS+= devfs.in dmesg.in hwclock.in consolefont.in keymaps.in killprocs.in \
|
||||
modules.in mount-ro.in mtab.in numlock.in procfs.in sysfs.in \
|
||||
termencoding.in
|
||||
|
||||
.SUFFIXES: .Linux.in
|
||||
.Linux.in:
|
||||
sed ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
@@ -1,12 +0,0 @@
|
||||
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+= devdb.in swap-blk.in ttys.in wscons.in
|
||||
|
||||
.SUFFIXES: .BSD.in
|
||||
.BSD.in:
|
||||
sed ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
@@ -10,7 +10,7 @@ depend()
|
||||
keyword -prefix -timeout
|
||||
}
|
||||
|
||||
dir_writeable()
|
||||
dir_writable()
|
||||
{
|
||||
mkdir "$1"/.test.$$ 2>/dev/null && rmdir "$1"/.test.$$
|
||||
}
|
||||
@@ -25,7 +25,7 @@ cleanup_tmp_dir()
|
||||
if ! [ -d "$dir" ]; then
|
||||
mkdir -p "$dir" || return $?
|
||||
fi
|
||||
dir_writeable "$dir" || return 1
|
||||
dir_writable "$dir" || return 1
|
||||
chmod a+rwt "$dir" 2> /dev/null
|
||||
cd "$dir" || return 1
|
||||
if yesno $wipe_tmp; then
|
||||
@@ -89,7 +89,7 @@ start()
|
||||
fi
|
||||
done
|
||||
|
||||
if dir_writeable /var/run; then
|
||||
if dir_writable /var/run; then
|
||||
ebegin "Creating user login records"
|
||||
local xtra=
|
||||
[ "$RC_UNAME" = NetBSD ] && xtra=x
|
||||
@@ -131,7 +131,7 @@ start()
|
||||
cleanup_tmp_dir "$tmp"
|
||||
done
|
||||
|
||||
if dir_writeable /tmp; then
|
||||
if dir_writable /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
|
||||
@@ -144,7 +144,7 @@ start()
|
||||
fi
|
||||
|
||||
if yesno $log_dmesg; then
|
||||
if $logw || dir_writeable /var/log; then
|
||||
if $logw || dir_writable /var/log; then
|
||||
# Create an 'after-boot' dmesg log
|
||||
if [ "$RC_SYS" != VSERVER -a "$RC_SYS" != OPENVZ ]; then
|
||||
dmesg > /var/log/dmesg
|
||||
|
||||
@@ -49,7 +49,7 @@ start()
|
||||
retval=1
|
||||
break
|
||||
fi
|
||||
x=$(($x + 1))
|
||||
: $(( x += 1 ))
|
||||
done
|
||||
eend $retval
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ depend()
|
||||
|
||||
start()
|
||||
{
|
||||
ebegin "Bulding the dev database"
|
||||
ebegin "Building the dev database"
|
||||
if [ /var/run/dev.db -nt /dev ]; then
|
||||
:
|
||||
else
|
||||
|
||||
@@ -19,7 +19,7 @@ start() {
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Deactiving kernel core dump device"
|
||||
ebegin "Deactivating kernel core dump device"
|
||||
dumpon off
|
||||
eend $?
|
||||
}
|
||||
|
||||
@@ -48,8 +48,13 @@ start()
|
||||
|
||||
if [ -n "$fsck_passno" ]; then
|
||||
check_extra="[passno $fsck_passno] $check_extra"
|
||||
if -n "$fsck_mnt" ]; then
|
||||
eerror "Only 1 of fsck_passno and fsck_mnt must be set!"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
ebegin "Checking local filesystems $check_extra"
|
||||
# Append passno mounts
|
||||
for p in $fsck_passno; do
|
||||
local IFS="$_IFS"
|
||||
case "$p" in
|
||||
@@ -58,10 +63,16 @@ start()
|
||||
set -- "$@" $(fstabinfo --passno "$p")
|
||||
unset IFS
|
||||
done
|
||||
# Append custom mounts
|
||||
for m in $fsck_mnt ; do
|
||||
local IFS="$_IFS"
|
||||
set -- "$@" "$m"
|
||||
unset IFS
|
||||
done
|
||||
|
||||
if [ "$RC_UNAME" = Linux ]; then
|
||||
fsck_opts="$fsck_opts -C0 -T"
|
||||
if [ -z "$fsck_passno" ]; then
|
||||
if [ -z "$fsck_passno" -a -z "$fsck_mnt" ]; then
|
||||
fsck_args=${fsck_args--A -p}
|
||||
if echo 2>/dev/null >/.test.$$; then
|
||||
rm -f /.test.$$
|
||||
@@ -91,7 +102,7 @@ start()
|
||||
_reboot
|
||||
fi;;
|
||||
8) ewend 1 "Operational error"; return 0;;
|
||||
12) ewend 1 "fsck interupted";;
|
||||
12) ewend 1 "fsck interrupted";;
|
||||
*) eend 2 "Filesystems couldn't be fixed";;
|
||||
esac
|
||||
_abort || return 1
|
||||
|
||||
@@ -85,7 +85,7 @@ start()
|
||||
|
||||
if [ -e /etc/adjtime ] && yesno $clock_adjfile; then
|
||||
_hwclock --adjust $utc_cmd
|
||||
retval=$(($retval + $?))
|
||||
: $(( retval += $? ))
|
||||
fi
|
||||
|
||||
# If setting UTC, don't bother to run hwclock when first booting
|
||||
@@ -99,7 +99,7 @@ start()
|
||||
else
|
||||
_hwclock --systz $utc_cmd $clock_args
|
||||
fi
|
||||
retval=$(($retval + $?))
|
||||
: $(( retval += $? ))
|
||||
fi
|
||||
|
||||
eend $retval "Failed to set the system clock"
|
||||
|
||||
@@ -59,7 +59,7 @@ start() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Use a statefull firewall
|
||||
# Use a stateful firewall
|
||||
ipfw add check-state
|
||||
ipfw add pass tcp from me to any established
|
||||
|
||||
@@ -123,7 +123,7 @@ start() {
|
||||
ipfw add deny udp from any to any 520 in
|
||||
|
||||
# Noise from webbrowsing.
|
||||
# The statefull filter is a bit agressive, and will cause some
|
||||
# The stateful filter is a bit aggressive, and will cause some
|
||||
# connection teardowns to be logged.
|
||||
ipfw add deny tcp from any 80,443 to any 1024-65535 in
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ start()
|
||||
n=1
|
||||
while [ $n -le $ttyn ]; do
|
||||
kbd_mode $kmode -C $ttydev$n
|
||||
n=$(($n + 1))
|
||||
: $(( n += 1 ))
|
||||
done
|
||||
eend 0
|
||||
|
||||
|
||||
28
init.d/migrate-run.in
Normal file
28
init.d/migrate-run.in
Normal file
@@ -0,0 +1,28 @@
|
||||
#!@PREFIX@/sbin/runscript
|
||||
# Copyright 1999-2011 Gentoo Foundation
|
||||
# Released under the 2-clause BSD license.
|
||||
|
||||
description="Migrate /var/run and /var/lock to /run"
|
||||
|
||||
depend()
|
||||
{
|
||||
before *
|
||||
after localmount
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
return 0
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
if [ -d /run -a ! -L /var/lock -a ! -L /var/run ]; then
|
||||
ebegin "Migrating /var/lock and /var/run to /run"
|
||||
rm -rf /var/lock /var/run
|
||||
ln -s /var/lock /run/lock
|
||||
ln -s /var/run /run
|
||||
eend 0
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@@ -21,7 +21,7 @@ restore()
|
||||
mixer -f "$mixer" \
|
||||
$(cat "/var/db/${mixer#/dev/}-state") >/dev/null
|
||||
veend $?
|
||||
: $((retval += $?))
|
||||
: $(( retval += $? ))
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -40,7 +40,7 @@ stop()
|
||||
vebegin "$mixer"
|
||||
mixer -f "$mixer" -s >/var/db/"${mixer#/dev/}"-state
|
||||
veend $?
|
||||
: $((retval += $?))
|
||||
: $(( retval += $? ))
|
||||
done
|
||||
eoutdent
|
||||
eend $retval
|
||||
|
||||
@@ -57,7 +57,7 @@ start()
|
||||
[ -z "$args" ] && eval args=\$module_${aa}_args
|
||||
[ -z "$args" ] && eval args=\$module_${xx}_args
|
||||
eval modprobe -q "$mpargs" "$x" "$args"
|
||||
eend $? "Failed to load $x" && cnt=$(($cnt + 1))
|
||||
eend $? "Failed to load $x" && : $(( cnt += 1 ))
|
||||
done
|
||||
einfo "Autoloaded $cnt module(s)"
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ start()
|
||||
local ttyv=
|
||||
for ttyv in /dev/ttyv*; do
|
||||
vidcontrol < "$ttyv" -m on
|
||||
: $((retval+= $?))
|
||||
: $(( retval += $? ))
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ _wait_for_carrier()
|
||||
eend 0
|
||||
return 0
|
||||
fi
|
||||
timeout=$((${timeout} - 1))
|
||||
: $(( timeout -= 1 ))
|
||||
[ "${efunc}" = "einfon" ] && printf "."
|
||||
done
|
||||
|
||||
@@ -144,9 +144,9 @@ _netmask2cidr()
|
||||
local i= len=
|
||||
local IFS=.
|
||||
for i in $1; do
|
||||
while [ ${i} != "0" ]; do
|
||||
len=$((${len} + ${i} % 2))
|
||||
i=$((${i} >> 1))
|
||||
while [ ${i} -ne 0 ]; do
|
||||
: $(( len += i % 2 ))
|
||||
: $(( i >>= 1 ))
|
||||
done
|
||||
done
|
||||
|
||||
@@ -277,7 +277,7 @@ _gen_module_list()
|
||||
echo "module_${i}_program_start='${PROGRAM_START}'" >> "${MODULESLIST}"
|
||||
echo "module_${i}_program_stop='${PROGRAM_STOP}'" >> "${MODULESLIST}"
|
||||
echo "module_${i}_provide='${PROVIDE}'" >> "${MODULESLIST}"
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
echo "module_${i}=" >> "${MODULESLIST}"
|
||||
)
|
||||
@@ -304,7 +304,7 @@ _load_modules()
|
||||
|
||||
local i=-1 x= mod= f= provides=
|
||||
while true; do
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
eval mod=\$module_${i}
|
||||
[ -z "${mod}" ] && break
|
||||
[ -e "${MODULESDIR}/${mod}.sh" ] || continue
|
||||
@@ -438,7 +438,7 @@ _load_config()
|
||||
# so modules can influence it
|
||||
for cmd; do
|
||||
eval config_${config_index}="'${cmd}'"
|
||||
config_index=$((${config_index} + 1))
|
||||
: $(( config_index += 1 ))
|
||||
done
|
||||
# Terminate the list
|
||||
eval config_${config_index}=
|
||||
@@ -446,7 +446,7 @@ _load_config()
|
||||
config_index=0
|
||||
for cmd in ${fallback}; do
|
||||
eval fallback_${config_index}="'${cmd}'"
|
||||
config_index=$((${config_index} + 1))
|
||||
: $(( config_index += 1 ))
|
||||
done
|
||||
# Terminate the list
|
||||
eval fallback_${config_index}=
|
||||
@@ -541,7 +541,7 @@ start()
|
||||
if [ -n "${our_metric}" ]; then
|
||||
metric=${our_metric}
|
||||
elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
|
||||
metric=$((${metric} + $(_ifindex)))
|
||||
: $(( metric += $(_ifindex) ))
|
||||
fi
|
||||
|
||||
while true; do
|
||||
@@ -581,11 +581,11 @@ start()
|
||||
eindent
|
||||
eval config_${config_index}=\$config
|
||||
unset fallback_${config_index}
|
||||
config_index=$((${config_index} - 1))
|
||||
: $(( config_index -= 1 ))
|
||||
fi
|
||||
fi
|
||||
eoutdent
|
||||
config_index=$((${config_index} + 1))
|
||||
: $(( config_index += 1 ))
|
||||
done
|
||||
|
||||
if ! ${oneworked}; then
|
||||
|
||||
@@ -219,6 +219,12 @@ start()
|
||||
eend $?
|
||||
fi
|
||||
|
||||
ewarn
|
||||
ewarn "The $RC_SVCNAME script is deprecated and will be"
|
||||
ewarn "removed in the future."
|
||||
ewarn "Please use the net.* scripts to manage your network interfaces."
|
||||
ewarn
|
||||
|
||||
einfo "Starting network"
|
||||
routeflush
|
||||
if [ "$RC_UNAME" = "Linux" ]; then
|
||||
@@ -281,7 +287,7 @@ start()
|
||||
tentative || break
|
||||
[ $r = 5 ] && vebegin "Waiting for tentative addresses"
|
||||
sleep 1
|
||||
r=$(($r - 1))
|
||||
: $(( r -= 1 ))
|
||||
done
|
||||
if [ $r != 5 ]; then
|
||||
[ $r != 0 ]
|
||||
|
||||
@@ -21,7 +21,7 @@ _setleds()
|
||||
|
||||
while [ $i -le $ttyn ]; do
|
||||
setleds -D "$1"num < $dev$i || retval=1
|
||||
i=$(($i + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
return $retval
|
||||
|
||||
@@ -33,7 +33,7 @@ start()
|
||||
|
||||
# Good to go!
|
||||
"$svc" start && started="$started $svc"
|
||||
: $((retval += $?))
|
||||
: $(( retval += $? ))
|
||||
done
|
||||
service_set_value started "$started"
|
||||
eend $retval "Some local rc services failed to start"
|
||||
@@ -46,7 +46,7 @@ stop()
|
||||
local svc= retval=0
|
||||
for svc in $(rcorder $(service_get_value started) 2>/dev/null | sort -r); do
|
||||
"$svc" stop
|
||||
: $((retval += $?))
|
||||
: $(( retval += $? ))
|
||||
done
|
||||
eend $retval "Some local rc services failed to stop"
|
||||
return 0
|
||||
|
||||
@@ -93,6 +93,11 @@ do_routes()
|
||||
|
||||
start()
|
||||
{
|
||||
ewarn
|
||||
ewarn "The $RC_SVCNAME script is deprecated and will be"
|
||||
ewarn "removed in the future."
|
||||
ewarn "Please use the net.* scripts to manage your network interfaces."
|
||||
ewarn
|
||||
do_routes "Adding" "add"
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,37 @@ mount_misc()
|
||||
eend $?
|
||||
fi
|
||||
fi
|
||||
|
||||
# Setup Kernel Support for configfs
|
||||
if [ -d /sys/kernel/config ] && ! mountinfo -q /sys/kernel/config; then
|
||||
if grep -qs configfs /proc/filesystems; then
|
||||
ebegin "Mounting config filesystem"
|
||||
mount -n -t configfs -o nodev,noexec,nosuid \
|
||||
configfs /sys/kernel/config
|
||||
eend $?
|
||||
fi
|
||||
fi
|
||||
|
||||
# Setup Kernel Support for cgroup
|
||||
if [ -d /sys/fs/cgroup ]; then
|
||||
if grep -qs cgroup /proc/filesystems && \
|
||||
! mountinfo -q /sys/fs/cgroup; then
|
||||
ebegin "Mounting cgroup filesystem"
|
||||
mount -n -t tmpfs -o nodev,noexec,nosuid \
|
||||
cgroup /sys/fs/cgroup
|
||||
eend $?
|
||||
fi
|
||||
if ! mountinfo -q /sys/fs/cgroup/openrc; then
|
||||
ebegin "creating openrc control group"
|
||||
mkdir /sys/fs/cgroup/openrc
|
||||
mount -n -t cgroup -o nodev,noexec,nosuid \
|
||||
openrc /sys/fs/cgroup/openrc
|
||||
echo 1 > /sys/fs/cgroup/openrc/notify_on_release
|
||||
echo @LIBEXECDIR@/sh/cgroup-release-agent.sh \
|
||||
> /sys/fs/cgroup/openrc/release_agent
|
||||
eend
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
@@ -31,7 +31,7 @@ start()
|
||||
n=1
|
||||
while [ ${n} -le "$ttyn" ]; do
|
||||
printf "\033%s" "$termencoding" >$ttydev$n
|
||||
n=$(($n + 1))
|
||||
: $(( n += 1 ))
|
||||
done
|
||||
|
||||
# Save the encoding for use immediately at boot
|
||||
|
||||
@@ -16,7 +16,7 @@ save_seed()
|
||||
local psz=1
|
||||
|
||||
if [ -e /proc/sys/kernel/random/poolsize ]; then
|
||||
psz=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
|
||||
: $(( psz = $(cat /proc/sys/kernel/random/poolsize) / 4096 ))
|
||||
fi
|
||||
|
||||
( # sub shell to prevent umask pollution
|
||||
|
||||
@@ -93,6 +93,9 @@ Space separated list of extra commands the service defines.
|
||||
.It Ar extra_started_commands
|
||||
Space separated list of extra commands the service defines. These only work if
|
||||
the service has already been started.
|
||||
.It Ar extra_stopped_commands
|
||||
Space separated list of extra commands the service defines. These only work if
|
||||
the service has already been stopped.
|
||||
.It Ar description
|
||||
String describing the service.
|
||||
.It Ar description_$command
|
||||
@@ -446,7 +449,7 @@ eat()
|
||||
veinfo "Eating `basename ${food}`"
|
||||
${command} --eat ${food}
|
||||
retval=$?
|
||||
: $((${result} += ${retval}))
|
||||
: $(( result += retval ))
|
||||
[ ${retval} = 0 ] && ate="${ate} `basename ${food}`"
|
||||
done
|
||||
|
||||
|
||||
18
mk/lib.mk
18
mk/lib.mk
@@ -8,18 +8,22 @@ SHLIB_NAME= lib${LIB}.so.${SHLIB_MAJOR}
|
||||
SHLIB_LINK= lib${LIB}.so
|
||||
SONAME?= ${SHLIB_NAME}
|
||||
|
||||
SOBJS+= ${SRCS:.c=.So}
|
||||
|
||||
MKSTATICLIBS?= yes
|
||||
ifeq (${MKSTATICLIBS},yes)
|
||||
OBJS+= ${SRCS:.c=.o}
|
||||
SOBJS+= ${OBJS:.o=.So}
|
||||
_LIBS= lib${LIB}.a ${SHLIB_NAME}
|
||||
_LIBS+= lib${LIB}.a
|
||||
endif
|
||||
|
||||
_LIBS+= ${SHLIB_NAME}
|
||||
|
||||
CLEANFILES+= ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK}
|
||||
|
||||
.SUFFIXES: .So
|
||||
|
||||
.c.o:
|
||||
%.o: %.c
|
||||
${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
|
||||
|
||||
.c.So:
|
||||
%.So: %.c
|
||||
${CC} ${PICFLAG} -DPIC ${CPPFLAGS} ${CFLAGS} -c $< -o $@
|
||||
|
||||
all: depend ${_LIBS}
|
||||
@@ -41,8 +45,10 @@ ${SHLIB_NAME}: ${SOBJS}
|
||||
${SOBJS} ${LDADD}
|
||||
|
||||
install: all
|
||||
ifeq (${MKSTATICLIBS},yes)
|
||||
${INSTALL} -d ${DESTDIR}${LIBDIR}
|
||||
${INSTALL} -m ${LIBMODE} lib${LIB}.a ${DESTDIR}${LIBDIR}
|
||||
endif
|
||||
${INSTALL} -d ${DESTDIR}${SHLIBDIR}
|
||||
${INSTALL} -m ${LIBMODE} ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
|
||||
ln -fs ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}/${SHLIB_LINK}
|
||||
|
||||
@@ -3,4 +3,7 @@
|
||||
|
||||
# Generic definitions
|
||||
|
||||
PKG_PREFIX?= /usr/local
|
||||
SFX= .BSD.in
|
||||
|
||||
LIBKVM?= -lkvm
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
# Copyright (c) 2008 Roy Marples <roy@marples.name>
|
||||
# Released under the 2-clause BSD license.
|
||||
|
||||
SFX= .Linux.in
|
||||
PKG_PREFIX?= /usr
|
||||
|
||||
CPPFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=600
|
||||
LIBDL= -Wl,-Bdynamic -ldl
|
||||
|
||||
@@ -24,7 +24,7 @@ CLEANFILES+= ${OBJS} ${PROG}
|
||||
|
||||
all: depend ${PROG}
|
||||
|
||||
.c.o:
|
||||
%.o: %.c
|
||||
${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
|
||||
|
||||
${PROG}: ${SCRIPTS} ${OBJS}
|
||||
|
||||
@@ -15,11 +15,10 @@ _LCL_SED:= $(shell ${_LCL_SED_SH})
|
||||
SED_REPLACE= -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g' -e 's:@PREFIX@:${PREFIX}:g' -e 's:@RC_SYS_DEFAULT@:${MKRCSYS}:g' ${_PKG_SED} ${_LCL_SED}
|
||||
|
||||
# Tweak our shell scripts
|
||||
.SUFFIXES: .sh.in .in
|
||||
.sh.in.sh:
|
||||
%.sh: %.sh.in
|
||||
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
|
||||
.in:
|
||||
%: %.in
|
||||
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
|
||||
all: ${OBJS} ${TARGETS}
|
||||
|
||||
21
net/Makefile
21
net/Makefile
@@ -1,9 +1,24 @@
|
||||
DIR= ${LIBEXECDIR}/net
|
||||
SRCS= ifconfig.sh.in
|
||||
SRCS= ifconfig.sh.in ${SRCS-${OS}}
|
||||
INC= dhclient.sh dhcpcd.sh ifconfig.sh macchanger.sh macnet.sh \
|
||||
ssidnet.sh system.sh wpa_supplicant.sh
|
||||
ssidnet.sh system.sh wpa_supplicant.sh ${INC-${OS}}
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/os.mk
|
||||
include Makefile.${OS}
|
||||
|
||||
SRCS-FreeBSD= iwconfig.sh.in
|
||||
INC-FreeBSD= iwconfig.sh
|
||||
|
||||
SRCS-Linux= iwconfig.sh.in
|
||||
INC-Linux= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
|
||||
ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
|
||||
ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
|
||||
vlan.sh macvlan.sh
|
||||
|
||||
SRCS-NetBSD=
|
||||
INC-NetBSD= ifwatchd.sh
|
||||
|
||||
%.sh: %.sh${SFX}
|
||||
${CP} $< $@
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
SRCS+= iwconfig.sh.in
|
||||
INC+= iwconfig.sh
|
||||
|
||||
.SUFFIXES: .sh.BSD.in
|
||||
.sh.BSD.in.sh:
|
||||
${CP} $< $@
|
||||
@@ -1,9 +0,0 @@
|
||||
SRCS+= iwconfig.sh.in
|
||||
INC+= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
|
||||
ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
|
||||
ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
|
||||
vlan.sh
|
||||
|
||||
.SUFFIXES: .sh.Linux.in
|
||||
.sh.Linux.in.sh:
|
||||
${CP} $< $@
|
||||
@@ -1,5 +0,0 @@
|
||||
INC+= ifwatchd.sh
|
||||
|
||||
.SUFFIXES: .sh.BSD.in
|
||||
.sh.BSD.in.sh:
|
||||
${CP} $< $@
|
||||
@@ -26,20 +26,20 @@ apipa_start()
|
||||
eindent
|
||||
|
||||
while [ ${i} -lt 64516 ]; do
|
||||
i1=$((($(_random) % 255) + 1))
|
||||
i2=$((($(_random) % 255) + 1))
|
||||
: $(( i1 = (_random % 255) + 1 ))
|
||||
: $(( i2 = (_random % 255) + 1 ))
|
||||
|
||||
addr="169.254.${i1}.${i2}"
|
||||
vebegin "${addr}/16"
|
||||
if ! arping_address "${addr}"; then
|
||||
eval config_${config_index}="\"${addr}/16 broadcast 169.254.255.255\""
|
||||
config_index=$((${config_index} - 1))
|
||||
: $(( config_index -= 1 ))
|
||||
veend 0
|
||||
eoutdent
|
||||
return 0
|
||||
fi
|
||||
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
eerror "No free address found!"
|
||||
|
||||
@@ -34,7 +34,7 @@ arping_address()
|
||||
while [ ${w} -gt 0 -a -z "${foundmac}" ]; do
|
||||
foundmac="$(arping2 ${opts} -r -c 1 -i "${IFACE}" "${ip}" 2>/dev/null | \
|
||||
sed -e 'y/abcdef/ABCDEF/')"
|
||||
w=$((${w} - 1))
|
||||
: $(( w -= 1 ))
|
||||
done
|
||||
else
|
||||
[ -z "$(_get_inet_address)" ] && opts="${opts} -D"
|
||||
|
||||
@@ -148,7 +148,7 @@ clip_post_start()
|
||||
|
||||
local nleftretries=10 emsg= ecode=
|
||||
while [ ${nleftretries} -gt 0 ]; do
|
||||
nleftretries=$((${nleftretries} - 1))
|
||||
: $(( nleftretries -= 1 ))
|
||||
emsg="$(atmarp -s "${peerip}" "${ifvpivci}" "$@" 2>&1)"
|
||||
ecode=$? && break
|
||||
sleep 2
|
||||
|
||||
@@ -38,7 +38,7 @@ _ifindex()
|
||||
echo "${x#/dev/net}"
|
||||
return 0
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
;;
|
||||
default)
|
||||
@@ -47,7 +47,7 @@ _ifindex()
|
||||
echo "${i}"
|
||||
return 0
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -26,7 +26,7 @@ _ifindex()
|
||||
{
|
||||
local line= i=-2
|
||||
while read line; do
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
[ ${i} -lt 1 ] && continue
|
||||
case "${line}" in
|
||||
"${IFACE}:"*) echo "${i}"; return 0;;
|
||||
@@ -34,7 +34,7 @@ _ifindex()
|
||||
done < /proc/net/dev
|
||||
|
||||
# Return the next available index
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
echo "${i}"
|
||||
return 1
|
||||
}
|
||||
@@ -96,7 +96,7 @@ _get_inet_addresses()
|
||||
_exists || break
|
||||
local addr="$(_get_inet_address)"
|
||||
[ -n "${addr}" ] && addrs="${addrs}${addrs:+ }${addr}"
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
echo "${addrs}"
|
||||
}
|
||||
@@ -106,26 +106,26 @@ _cidr2netmask()
|
||||
local cidr="$1" netmask="" done=0 i=0 sum=0 cur=128
|
||||
local octets= frac=
|
||||
|
||||
local octets=$((${cidr} / 8))
|
||||
local frac=$((${cidr} % 8))
|
||||
local octets=$(( cidr / 8 ))
|
||||
local frac=$(( cidr % 8 ))
|
||||
while [ ${octets} -gt 0 ]; do
|
||||
netmask="${netmask}.255"
|
||||
octets=$((${octets} - 1))
|
||||
done=$((${done} + 1))
|
||||
: $(( octets -= 1 ))
|
||||
: $(( done += 1 ))
|
||||
done
|
||||
|
||||
if [ ${done} -lt 4 ]; then
|
||||
while [ ${i} -lt ${frac} ]; do
|
||||
sum=$((${sum} + ${cur}))
|
||||
cur=$((${cur} / 2))
|
||||
i=$((${i} + 1))
|
||||
: $(( sum += cur ))
|
||||
: $(( cur /= 2 ))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
netmask="${netmask}.${sum}"
|
||||
done=$((${done} + 1))
|
||||
: $(( done += 1 ))
|
||||
|
||||
while [ ${done} -lt 4 ]; do
|
||||
netmask="${netmask}.0"
|
||||
done=$((${done} + 1))
|
||||
: $(( done += 1 ))
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -150,7 +150,7 @@ _add_address()
|
||||
# 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')
|
||||
i=$((${i:-0} + 1))
|
||||
: $(( i = ${i:-0} + 1 ))
|
||||
iface="${iface}:${i}"
|
||||
fi
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ ifplugd_pre_start()
|
||||
fi
|
||||
sleep 1
|
||||
[ ${timeout} -eq 0 ] && continue
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
[ ${i} -ge ${timeout} ] && break
|
||||
done
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ ip6to4_start()
|
||||
case "${ip}" in
|
||||
172.${i}.*) break;;
|
||||
esac
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
[ ${i} -lt 32 ] && continue
|
||||
;;
|
||||
@@ -90,7 +90,7 @@ ip6to4_start()
|
||||
|
||||
# Now apply our config
|
||||
eval config_${config_index}=\'"${new}"\'
|
||||
config_index=$((${config_index} - 1))
|
||||
: $(( config_index -= 1 ))
|
||||
|
||||
# Add a route for us, ensuring we don't delete anything else
|
||||
local routes="$(_get_array "routes_${IFVAR}")
|
||||
|
||||
@@ -36,7 +36,7 @@ _ifindex()
|
||||
{
|
||||
local line= i=-2
|
||||
while read line; do
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
[ ${i} -lt 1 ] && continue
|
||||
case "${line}" in
|
||||
"${IFACE}:"*) echo "${i}"; return 0;;
|
||||
@@ -44,7 +44,7 @@ _ifindex()
|
||||
done < /proc/net/dev
|
||||
|
||||
# Return the next available index
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
echo "${i}"
|
||||
return 1
|
||||
}
|
||||
@@ -290,7 +290,7 @@ iproute2_post_start()
|
||||
while [ $n -ge 0 ]; do
|
||||
_iproute2_ipv6_tentative || break
|
||||
sleep 1
|
||||
n=$(($n - 1))
|
||||
: $(( n -= 1 ))
|
||||
done
|
||||
[ $n -ge 0 ]
|
||||
eend $?
|
||||
|
||||
@@ -218,7 +218,7 @@ iwconfig_associate()
|
||||
sleep 1
|
||||
|
||||
[ ${timeout} -eq 0 ] && continue
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
[ ${i} -ge ${timeout} ] && { eend 1; return 1; }
|
||||
done
|
||||
|
||||
@@ -252,13 +252,13 @@ iwconfig_scan()
|
||||
scan="$(LC_ALL=C ifconfig -v "${IFACE}" list scan 2>/dev/null | sed -e "1 d" -e "s/$/'/g" -e "s/^/'/g")"
|
||||
while [ ${i} -lt 3 -a -z "${scan}" ] ; do
|
||||
scan="${scan}${scan:+ }$(LC_ALL=C ifconfig -v "${IFACE}" scan 2>/dev/null | sed -e "1 d" -e "s/$/'/g" -e "s/^/'/g")"
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
APS=-1
|
||||
eval set -- ${scan}
|
||||
for line in "$@" ; do
|
||||
APS=$((${APS} + 1))
|
||||
: $(( APS += 1 ))
|
||||
set -- ${line}
|
||||
while true ; do
|
||||
case "$1" in
|
||||
@@ -276,7 +276,7 @@ iwconfig_scan()
|
||||
# Add 1000 for managed nodes as we prefer them to adhoc
|
||||
set -- $*
|
||||
case "$1" in
|
||||
*E*) eval QUAL_${APS}=$((${quality} + 1000)) ;;
|
||||
*E*) eval QUAL_${APS}=$(( quality + 1000 )) ;;
|
||||
*) eval QUAL_${APS}=\$quality ;;
|
||||
esac
|
||||
done
|
||||
@@ -290,7 +290,7 @@ iwconfig_scan()
|
||||
# Sort based on quality
|
||||
local i=0 k=1 a= b= x= t=
|
||||
while [ ${i} -lt ${APS} ] ; do
|
||||
k=$((${i} + 1))
|
||||
: $(( k = i + 1 ))
|
||||
while [ ${k} -le ${APS} ] ; do
|
||||
eval a=\$QUALITY_${i}
|
||||
[ -z "${a}" ] && break
|
||||
@@ -302,15 +302,15 @@ iwconfig_scan()
|
||||
eval ${x}_${k}=\$t
|
||||
done
|
||||
fi
|
||||
k=$((${k} + 1))
|
||||
: $(( k += 1 ))
|
||||
done
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
# Strip any duplicates
|
||||
local i=0 k=1 a= b=
|
||||
while [ ${i} -lt ${APS} ] ; do
|
||||
k=$((${i} + 1))
|
||||
: $(( k = i + 1 ))
|
||||
while [ ${k} -le ${APS} ] ; do
|
||||
eval a=\$MAC_${i}
|
||||
eval b=\$MAC_${k}
|
||||
@@ -327,9 +327,9 @@ iwconfig_scan()
|
||||
unset MAC_${k} SSID_${k} CHAN_${k} QUALITY_${k} CAPS_${k}
|
||||
fi
|
||||
fi
|
||||
k=$((${k} + 1))
|
||||
: $(( k += 1 ))
|
||||
done
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
local i=0 e= m= s=
|
||||
@@ -337,7 +337,7 @@ iwconfig_scan()
|
||||
while [ ${i} -le ${APS} ] ; do
|
||||
eval x=\$MAC_${i}
|
||||
if [ -z "${x}" ] ; then
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -374,7 +374,7 @@ iwconfig_scan()
|
||||
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} CAPS_${i}
|
||||
fi
|
||||
done
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
eoutdent
|
||||
return 0
|
||||
@@ -396,7 +396,7 @@ iwconfig_force_preferred()
|
||||
found_AP=true
|
||||
break
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
if ! ${found_AP} ; then
|
||||
SSID=${ssid}
|
||||
@@ -428,7 +428,7 @@ iwconfig_connect_preferred()
|
||||
iwconfig_associate "${mac}" \
|
||||
"${chan}" "${caps}" && return 0
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
done
|
||||
|
||||
@@ -442,7 +442,7 @@ iwconfig_connect_not_preferred()
|
||||
while [ ${i} -le ${APS} ] ; do
|
||||
eval e=\$SSID_${i}
|
||||
if [ -z "${e}" ] ; then
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -465,7 +465,7 @@ iwconfig_connect_not_preferred()
|
||||
iwconfig_associate "${mac}" \
|
||||
"${chan}" "${caps}" && return 0
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
return 1
|
||||
|
||||
@@ -39,7 +39,7 @@ _get_ssid()
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
i=$((${i} - 1))
|
||||
: $(( i -= 1 ))
|
||||
done
|
||||
|
||||
return 1
|
||||
@@ -229,7 +229,7 @@ iwconfig_wait_for_association()
|
||||
|
||||
sleep 1
|
||||
[ ${timeout} -eq 0 ] && continue
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
[ ${i} -ge ${timeout} ] && return 1
|
||||
done
|
||||
return 1
|
||||
@@ -347,7 +347,7 @@ iwconfig_scan()
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
if [ -z "${scan}" ]; then
|
||||
@@ -377,7 +377,7 @@ iwconfig_scan()
|
||||
for line; do
|
||||
case "${line}" in
|
||||
*Address:*)
|
||||
APS=$((${APS} + 1))
|
||||
: $(( APS += 1 ))
|
||||
eval MAC_${APS}="\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\""
|
||||
eval QUALITY_${APS}=0
|
||||
;;
|
||||
@@ -427,7 +427,7 @@ iwconfig_scan()
|
||||
# Sort based on quality
|
||||
local i=0 k=1 a= b= x= t=
|
||||
while [ ${i} -lt ${APS} ]; do
|
||||
k=$((${i} + 1))
|
||||
: $(( k = i + 1 ))
|
||||
while [ ${k} -le ${APS} ]; do
|
||||
eval a=\$QUALITY_${i}
|
||||
[ -z "${a}" ] && break
|
||||
@@ -439,15 +439,15 @@ iwconfig_scan()
|
||||
eval ${x}_${k}=\$t
|
||||
done
|
||||
fi
|
||||
k=$((${k} + 1))
|
||||
: $(( k += 1 ))
|
||||
done
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
# Strip any duplicates
|
||||
local i=0 k=1 a= b=
|
||||
while [ ${i} -lt ${APS} ]; do
|
||||
k=$((${i} + 1))
|
||||
: $(( k = i + 1 ))
|
||||
while [ ${k} -le ${APS} ]; do
|
||||
eval a=\$MAC_${i}
|
||||
eval b=\$MAC_${k}
|
||||
@@ -459,9 +459,9 @@ iwconfig_scan()
|
||||
[ -n "${a}" -a -n "${b}" ] && [ "${a}" -lt "${b}" ] && u=${i}
|
||||
unset MAC_${u} SSID_${u} MODE_${u} CHAN_${u} QUALITY_${u} ENC_${u}
|
||||
fi
|
||||
k=$((${k} + 1))
|
||||
: $(( k += 1 ))
|
||||
done
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
local i=0 e= m= s=
|
||||
@@ -469,7 +469,7 @@ iwconfig_scan()
|
||||
while [ ${i} -le ${APS} ]; do
|
||||
eval x=\$MAC_${i}
|
||||
if [ -z "${x}" ]; then
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -506,7 +506,7 @@ iwconfig_scan()
|
||||
unset SSID_${i} MAC_${i} ${MODE}_${i} CHAN_${i} QUALITY_${i} ENC_${i}
|
||||
fi
|
||||
done
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
eoutdent
|
||||
}
|
||||
@@ -526,7 +526,7 @@ iwconfig_force_preferred()
|
||||
found_AP=true
|
||||
break
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
if ! ${found_AP}; then
|
||||
SSID=${ssid}
|
||||
@@ -559,7 +559,7 @@ iwconfig_connect_preferred()
|
||||
iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \
|
||||
"${chan}" && return 0
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
done
|
||||
|
||||
@@ -593,7 +593,7 @@ iwconfig_connect_not_preferred()
|
||||
"${chan}" && return 0
|
||||
fi
|
||||
fi
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
done
|
||||
|
||||
return 1
|
||||
|
||||
69
net/macvlan.sh
Normal file
69
net/macvlan.sh
Normal file
@@ -0,0 +1,69 @@
|
||||
# 2011-09-22 Stef Simoens <stef@bgs.org>
|
||||
# based on vlan.sh & tuntap.sh
|
||||
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
||||
# All rights reserved. Released under the 2-clause BSD license.
|
||||
|
||||
_ip()
|
||||
{
|
||||
if [ -x /bin/ip ]; then
|
||||
echo /bin/ip
|
||||
else
|
||||
echo /sbin/ip
|
||||
fi
|
||||
}
|
||||
|
||||
macvlan_depend()
|
||||
{
|
||||
program $(_ip)
|
||||
after interface
|
||||
before dhcp macchanger
|
||||
}
|
||||
|
||||
_is_macvlan()
|
||||
{
|
||||
[ -n "$(export RC_SVCNAME="net.${IFACE}"; service_get_value macvlan)" ]
|
||||
}
|
||||
|
||||
_check_macvlan()
|
||||
{
|
||||
if [ ! -d /sys/module/macvlan ]; then
|
||||
modprobe macvlan
|
||||
if [ ! -d /sys/module/macvlan ]; then
|
||||
eerror "MAC-VLAN support is not present in this kernel"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
macvlan_pre_start()
|
||||
{
|
||||
# MAC-VLAN needs an existing interface to link to
|
||||
local macvlan=
|
||||
eval macvlan=\$macvlan_${IFVAR}
|
||||
[ -z "${macvlan}" ] && return 0
|
||||
|
||||
_check_macvlan || return 1
|
||||
|
||||
# optional mode, default to "private"
|
||||
local mode=
|
||||
eval mode=\$mode_${IFVAR}
|
||||
[ -z "${mode}" ] && mode="private"
|
||||
|
||||
ebegin "Creating MAC-VLAN ${IFACE} to ${macvlan}"
|
||||
e="$(ip link add link "${macvlan}" name "${IFACE}" type macvlan mode "${mode}" 2>&1 1>/dev/null)"
|
||||
if [ -n "${e}" ]; then
|
||||
eend 1 "${e}"
|
||||
else
|
||||
eend 0 && service_set_value macvlan "${macvlan}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
macvlan_post_stop()
|
||||
{
|
||||
_is_macvlan || return 0
|
||||
|
||||
ebegin "Removing MAC-VLAN ${IFACE}"
|
||||
ip link delete "${IFACE}" type macvlan >/dev/null
|
||||
eend $?
|
||||
}
|
||||
@@ -74,7 +74,7 @@ netplugd_pre_start()
|
||||
fi
|
||||
sleep 1
|
||||
[ ${timeout} -eq 0 ] && continue
|
||||
i=$((${i} + 1))
|
||||
: $(( i += 1 ))
|
||||
[ ${i} -ge ${timeout} ] && break
|
||||
done
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ pppd_pre_start()
|
||||
if ! ${hasdefaultmetric}; then
|
||||
local m=
|
||||
eval m=\$metric_${IFVAR}
|
||||
[ -z "${m}" ] && m=$((${metric} + $(_ifindex)))
|
||||
[ -z "${m}" ] && : $(( m = metric + $(_ifindex) ))
|
||||
opts="${opts} defaultmetric ${m}"
|
||||
fi
|
||||
if [ -n "${mtu}" ]; then
|
||||
|
||||
@@ -13,7 +13,7 @@ system_depend()
|
||||
|
||||
_system_dns()
|
||||
{
|
||||
local servers= domain= search= sortlist= options= x=
|
||||
local servers= domain= search= sortlist= options= x= imetric=
|
||||
|
||||
eval servers=\$dns_servers_${IFVAR}
|
||||
[ -z "${servers}" ] && servers=${dns_servers}
|
||||
@@ -46,7 +46,12 @@ _system_dns()
|
||||
|
||||
# Support resolvconf if we have it.
|
||||
if [ -x /sbin/resolvconf ]; then
|
||||
printf "${buffer}" | resolvconf -a "${IFACE}"
|
||||
x="-a ${IFACE}"
|
||||
eval imetric=\${metric_${IFVAR}}
|
||||
if [ -n "${imetric}" ]; then
|
||||
x="${x} -m ${imetric}"
|
||||
fi
|
||||
printf "${buffer}" | resolvconf ${x}
|
||||
else
|
||||
printf "${buffer}" > /etc/resolv.conf
|
||||
chmod 644 /etc/resolv.conf
|
||||
|
||||
@@ -30,7 +30,7 @@ tuntap_pre_start()
|
||||
local timeout=10
|
||||
while [ ! -e /dev/net/tun -a ${timeout} -gt 0 ]; do
|
||||
sleep 1
|
||||
timeout=$((${timeout} - 1))
|
||||
: $(( timeout -= 1 ))
|
||||
done
|
||||
if [ ! -e /dev/net/tun ]; then
|
||||
eerror "TUN/TAP support present but /dev/net/tun is not"
|
||||
|
||||
@@ -34,7 +34,7 @@ _get_ssid()
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
timeout=$((timeout - 1))
|
||||
: $(( timeout -= 1 ))
|
||||
done
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
BOOT= bootmisc fsck hostname localmount network \
|
||||
root staticroute swap sysctl urandom
|
||||
BOOT= bootmisc fsck hostname localmount \
|
||||
root swap sysctl urandom ${BOOT-${OS}}
|
||||
DEFAULT= local netmount
|
||||
SHUTDOWN= savecache
|
||||
SHUTDOWN= savecache ${SHUTDOWN-${OS}}
|
||||
SYSINIT= ${SYSINIT-${OS}}
|
||||
|
||||
LEVELDIR= ${DESTDIR}/${SYSCONFDIR}/runlevels
|
||||
SYSINITDIR= ${LEVELDIR}/sysinit
|
||||
@@ -9,13 +10,30 @@ BOOTDIR= ${LEVELDIR}/boot
|
||||
DEFAULTDIR= ${LEVELDIR}/default
|
||||
SHUTDOWNDIR= ${LEVELDIR}/shutdown
|
||||
|
||||
INITDIR= ../init.d
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/sys.mk
|
||||
include ${MK}/os.mk
|
||||
include ${MK}/gitignore.mk
|
||||
include Makefile.${OS}
|
||||
|
||||
BOOT-${OS}=
|
||||
SHUTDOWN-${OS}=
|
||||
SYSINIT-${OS}=
|
||||
|
||||
BOOT-BSD= hostid newsyslog savecore syslogd swap-blk
|
||||
|
||||
# Generic BSD stuff
|
||||
BOOT-FreeBSD= hostid net.lo0 newsyslog savecore syslogd
|
||||
# FreeBSD specific stuff
|
||||
BOOT-FreeBSD+= adjkerntz dumpon syscons
|
||||
|
||||
BOOT-Linux= hwclock keymaps modules mtab net.lo procfs termencoding migrate-run
|
||||
SHUTDOWN-Linux= killprocs mount-ro
|
||||
SYSINIT-Linux= devfs dmesg
|
||||
|
||||
# Generic BSD stuff
|
||||
BOOT-NetBSD= hostid net.lo0 newsyslog savecore syslogd
|
||||
# NetBSD specific stuff
|
||||
BOOT-NetBSD+= devdb swap-blk ttys wscons
|
||||
|
||||
all:
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
BOOT+= hostid newsyslog savecore syslogd swap-blk
|
||||
@@ -1,5 +0,0 @@
|
||||
# Generic BSD stuff
|
||||
BOOT+= hostid net.lo0 newsyslog savecore syslogd
|
||||
|
||||
# FreeBSD specific stuff
|
||||
BOOT+= adjkerntz dumpon syscons
|
||||
@@ -1,3 +0,0 @@
|
||||
SYSINIT+= devfs dmesg
|
||||
BOOT+= hwclock keymaps modules mtab procfs termencoding
|
||||
SHUTDOWN+= killprocs mount-ro
|
||||
@@ -1,5 +0,0 @@
|
||||
# Generic BSD stuff
|
||||
BOOT+= hostid net.lo0 newsyslog savecore syslogd
|
||||
|
||||
# NetBSD specific stuff
|
||||
BOOT+= devdb swap-blk ttys wscons
|
||||
@@ -3,14 +3,14 @@
|
||||
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
||||
|
||||
# Exit 0 if on AC power, 1 if not and 255 if we don't know how to work it out
|
||||
if [ -f /proc/acpi/ac_adapter/AC*/state ]; then
|
||||
cat /proc/acpi/ac_adapter/AC*/state | while read line; do
|
||||
if [ -f /proc/acpi/ac_adapter/*/state ]; then
|
||||
cat /proc/acpi/ac_adapter/*/state | while read line; do
|
||||
case "$line" in
|
||||
"state:"*"off-line") exit 128;;
|
||||
esac
|
||||
done
|
||||
elif [ -f /sys/class/power_supply/AC*/online ]; then
|
||||
cat /sys/class/power_supply/AC*/online | while read line; do
|
||||
elif [ -f /sys/class/power_supply/*/online ]; then
|
||||
cat /sys/class/power_supply/*/online | while read line; do
|
||||
[ "${line}" = 0 ] && exit 128
|
||||
done
|
||||
elif [ -f /proc/pmu/info ]; then
|
||||
|
||||
20
sh/Makefile
20
sh/Makefile
@@ -1,16 +1,28 @@
|
||||
DIR= ${LIBEXECDIR}/sh
|
||||
SRCS= functions.sh.in gendepends.sh.in init-common-post.sh.in \
|
||||
rc-functions.sh.in runscript.sh.in
|
||||
SRCS= init.sh.in functions.sh.in gendepends.sh.in init-common-post.sh.in \
|
||||
rc-functions.sh.in runscript.sh.in ${SRCS-${OS}}
|
||||
INC= init-common-post.sh rc-mount.sh functions.sh rc-functions.sh
|
||||
BIN= gendepends.sh init.sh runscript.sh
|
||||
BIN= gendepends.sh init.sh runscript.sh ${BIN-${OS}}
|
||||
|
||||
INSTALLAFTER= _installafter
|
||||
|
||||
MK= ../mk
|
||||
include ${MK}/os.mk
|
||||
include Makefile.${OS}
|
||||
|
||||
SRCS-FreeBSD=
|
||||
BIN-FreeBSD=
|
||||
|
||||
SRCS-Linux= cgroup-release-agent.sh.in init-early.sh.in udhcpc-hook.sh.in
|
||||
BIN-Linux= cgroup-release-agent.sh init-early.sh udhcpc-hook.sh
|
||||
|
||||
SRCS-NetBSD= ifwatchd-carrier.sh.in ifwatchd-nocarrier.sh.in
|
||||
BIN-NetBSD= ifwatchd-carrier.sh ifwatchd-nocarrier.sh
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
|
||||
%.sh: %.sh${SFX}
|
||||
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
|
||||
_installafter:
|
||||
${INSTALL} -d ${DESTDIR}/${INITDIR}
|
||||
@# Put functions.sh into init for backwards compat
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
SRCS+= init.sh.in
|
||||
|
||||
.SUFFIXES: .sh.BSD.in
|
||||
.sh.BSD.in.sh:
|
||||
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
SRCS+= init.sh.in init-early.sh.in udhcpc-hook.sh.in
|
||||
BIN+= init-early.sh udhcpc-hook.sh
|
||||
|
||||
.SUFFIXES: .sh.Linux.in
|
||||
.sh.Linux.in.sh:
|
||||
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
SRCS+= init.sh.in
|
||||
|
||||
SRCS+= ifwatchd-carrier.sh.in ifwatchd-nocarrier.sh.in
|
||||
BIN+= ifwatchd-carrier.sh ifwatchd-nocarrier.sh
|
||||
|
||||
.SUFFIXES: .sh.BSD.in
|
||||
.sh.BSD.in.sh:
|
||||
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
|
||||
10
sh/cgroup-release-agent.sh.in
Normal file
10
sh/cgroup-release-agent.sh.in
Normal file
@@ -0,0 +1,10 @@
|
||||
#!@SHELL@
|
||||
#
|
||||
# This is run by the kernel after the last task is removed from a
|
||||
# control group in the openrc hierarchy.
|
||||
|
||||
cgroup=/sys/fs/cgroup/openrc
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||
if [ -d ${cgroup}/$1 ]; then
|
||||
rmdir ${cgroup}/$1
|
||||
fi
|
||||
@@ -8,14 +8,14 @@ RC_GOT_FUNCTIONS="yes"
|
||||
|
||||
eindent()
|
||||
{
|
||||
EINFO_INDENT=$((${EINFO_INDENT:-0} + 2))
|
||||
: $(( EINFO_INDENT = ${EINFO_INDENT:-0} + 2 ))
|
||||
[ "$EINFO_INDENT" -gt 40 ] && EINFO_INDENT=40
|
||||
export EINFO_INDENT
|
||||
}
|
||||
|
||||
eoutdent()
|
||||
{
|
||||
EINFO_INDENT=$((${EINFO_INDENT:-0} - 2))
|
||||
: $(( EINFO_INDENT = ${EINFO_INDENT:-0} - 2 ))
|
||||
[ "$EINFO_INDENT" -lt 0 ] && EINFO_INDENT=0
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ do_unmount()
|
||||
eend 1
|
||||
else
|
||||
local sig="TERM"
|
||||
retry=$(($retry - 1))
|
||||
: $(( retry -= 1 ))
|
||||
[ $retry = 1 ] && sig="KILL"
|
||||
fuser $f_kill$sig -k $f_opts \
|
||||
"$mnt" >/dev/null 2>&1
|
||||
|
||||
@@ -33,6 +33,14 @@ loadconfig()
|
||||
fi
|
||||
}
|
||||
|
||||
sourcex "@SYSCONFDIR@/init.d/functions.sh"
|
||||
sourcex "@LIBEXECDIR@/sh/rc-functions.sh"
|
||||
|
||||
# Support LiveCD foo
|
||||
if sourcex -e "/sbin/livecd-functions.sh"; then
|
||||
livecd_read_commandline
|
||||
fi
|
||||
|
||||
if [ ! -e ${RC_SVCDIR}/softlevel ]; then
|
||||
eerror "You are attempting to run an openrc service on a"
|
||||
eerror "system which openrc did not boot."
|
||||
@@ -45,14 +53,6 @@ if [ ! -e ${RC_SVCDIR}/softlevel ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sourcex "@SYSCONFDIR@/init.d/functions.sh"
|
||||
sourcex "@LIBEXECDIR@/sh/rc-functions.sh"
|
||||
|
||||
# Support LiveCD foo
|
||||
if sourcex -e "/sbin/livecd-functions.sh"; then
|
||||
livecd_read_commandline
|
||||
fi
|
||||
|
||||
if [ -z "$1" -o -z "$2" ]; then
|
||||
eerror "$RC_SVCNAME: not enough arguments"
|
||||
exit 1
|
||||
@@ -88,7 +88,7 @@ keyword() {
|
||||
[ -n "$*" ] && echo "keyword $*"
|
||||
}
|
||||
|
||||
# Descript the init script to the user
|
||||
# Describe the init script to the user
|
||||
describe()
|
||||
{
|
||||
if [ -n "$description" ]; then
|
||||
@@ -98,7 +98,8 @@ describe()
|
||||
fi
|
||||
|
||||
local svc= desc=
|
||||
for svc in ${extra_commands:-$opts} $extra_started_commands; do
|
||||
for svc in ${extra_commands:-$opts} $extra_started_commands \
|
||||
$extra_stopped_commands; do
|
||||
eval desc=\$description_$svc
|
||||
if [ -n "$desc" ]; then
|
||||
einfo "$HILITE$svc$NORMAL: $desc"
|
||||
@@ -147,6 +148,19 @@ start()
|
||||
service_inactive && _inactive=true
|
||||
mark_service_inactive
|
||||
fi
|
||||
if [ "$RC_UNAME" = Linux ]; then
|
||||
local cgroup=/sys/fs/cgroup/openrc
|
||||
local svc_cgroup=${cgroup}/${RC_SVCNAME}
|
||||
if mountinfo -q ${cgroup}; then
|
||||
mkdir ${svc_cgroup}
|
||||
for f in cpuset.cpus cpuset.mems; do
|
||||
if [ -f ${cgroup}/${f} ]; then
|
||||
cp ${cgroup}/${f} ${svc_cgroup}
|
||||
fi
|
||||
done
|
||||
echo $$ > ${svc_cgroup}/tasks
|
||||
fi
|
||||
fi
|
||||
eval start-stop-daemon --start \
|
||||
--exec $command \
|
||||
${procname:+--name} $procname \
|
||||
@@ -213,11 +227,11 @@ unset _f
|
||||
if [ -n "$opts" ]; then
|
||||
ewarn "Use of the opts variable is deprecated and will be"
|
||||
ewarn "removed in the future."
|
||||
ewarn "Please use extra_commands or extra_started_commands."
|
||||
ewarn "Please use extra_commands, extra_started_commands or extra_stopped_commands."
|
||||
fi
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
# Sepcial case depend
|
||||
# Special case depend
|
||||
if [ "$1" = depend ]; then
|
||||
shift
|
||||
_depend
|
||||
@@ -225,7 +239,7 @@ while [ -n "$1" ]; do
|
||||
fi
|
||||
# See if we have the required function and run it
|
||||
for _cmd in describe start stop status ${extra_commands:-$opts} \
|
||||
$extra_started_commands
|
||||
$extra_started_commands $extra_stopped_commands
|
||||
do
|
||||
if [ "$_cmd" = "$1" ]; then
|
||||
if [ "$(command -v "$1")" = "$1" ]; then
|
||||
@@ -253,6 +267,16 @@ while [ -n "$1" ]; do
|
||||
fi
|
||||
fi
|
||||
done
|
||||
# Check to see if we need to be stopped before
|
||||
# we can run this command
|
||||
for _cmd in $extra_stopped_commands; do
|
||||
if [ "$_cmd" = "$1" ]; then
|
||||
if ! service_stopped; then
|
||||
eerror "$RC_SVCNAME: cannot \`$1' as it has not been stopped"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
unset _cmd
|
||||
if [ "$(command -v "$1_pre")" = "$1_pre" ]
|
||||
then
|
||||
@@ -280,3 +304,5 @@ while [ -n "$1" ]; do
|
||||
eerror "$RC_SVCNAME: unknown function \`$1'"
|
||||
exit 1
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -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=$(($tret + 1))
|
||||
: $(( tret += 1 ))
|
||||
echo "!$f!"
|
||||
fi
|
||||
done
|
||||
for f in no NO No false FALSE False 0 ; do
|
||||
if yesno $f; then
|
||||
tret=$(($tret + 1))
|
||||
: $(( tret += 1 ))
|
||||
echo "!$f!"
|
||||
fi
|
||||
done
|
||||
eend $tret
|
||||
ret=$(($ret + $tret))
|
||||
: $(( ret += $tret ))
|
||||
|
||||
exit $ret
|
||||
|
||||
@@ -39,8 +39,7 @@ endif
|
||||
endif
|
||||
SED_CMD+= ${_LCL_PREFIX}
|
||||
|
||||
.SUFFIXES: .h.in .h
|
||||
.h.in.h:
|
||||
%.h: %.h.in
|
||||
${SED} ${SED_CMD} $< > $@
|
||||
${SRCS}: rc.h
|
||||
|
||||
|
||||
@@ -281,6 +281,8 @@ rc_sys_v1(void)
|
||||
else if (file_regex("/proc/self/status",
|
||||
"envID:[[:space:]]*[1-9]"))
|
||||
return RC_SYS_OPENVZ; /* old test */
|
||||
else if (file_regex("/proc/1/environ", "container=lxc"))
|
||||
return RC_SYS_LXC;
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
@@ -524,7 +526,9 @@ rc_service_exists(const char *service)
|
||||
}
|
||||
librc_hidden_def(rc_service_exists)
|
||||
|
||||
#define OPTSTR ". '%s'; echo $extra_commands $extra_started_commands"
|
||||
#define OPTSTR \
|
||||
". '%s'; echo $extra_commands $extra_started_commands $extra_stopped_commands"
|
||||
|
||||
RC_STRINGLIST *
|
||||
rc_service_extra_commands(const char *service)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include "version.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#if lint
|
||||
# define _noreturn
|
||||
@@ -59,6 +60,7 @@ usage(int exit_status)
|
||||
char *lo;
|
||||
char *p;
|
||||
char *token;
|
||||
char val[4] = "-?,";
|
||||
|
||||
#ifdef usagestring
|
||||
printf(usagestring);
|
||||
@@ -70,13 +72,15 @@ usage(int exit_status)
|
||||
#endif
|
||||
printf("\n\nOptions: [" getoptstring "]\n");
|
||||
for (i = 0; longopts[i].name; ++i) {
|
||||
len = printf(" -%c, --%s %s", longopts[i].val, longopts[i].name,
|
||||
has_arg[longopts[i].has_arg]);
|
||||
val[1] = longopts[i].val;
|
||||
len = printf(" %3s --%s %s", isprint(longopts[i].val) ? val : "",
|
||||
longopts[i].name, has_arg[longopts[i].has_arg]);
|
||||
|
||||
lo = p = xstrdup(longopts_help[i]);
|
||||
while ((token = strsep(&p, "\n"))) {
|
||||
while (++len < 37)
|
||||
printf(" ");
|
||||
len = 36 - len;
|
||||
if (len > 0)
|
||||
printf("%*s", len, "");
|
||||
puts(token);
|
||||
len = 0;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ checkpath(int argc, char **argv)
|
||||
applet, optarg);
|
||||
break;
|
||||
|
||||
case_RC_COMMON_GETOPT;
|
||||
case_RC_COMMON_GETOPT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -236,8 +236,8 @@ fstabinfo(int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case_RC_COMMON_GETOPT
|
||||
}
|
||||
case_RC_COMMON_GETOPT
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
|
||||
@@ -391,6 +391,7 @@ mountinfo(int argc, char **argv)
|
||||
int opt;
|
||||
int result;
|
||||
bool quiet;
|
||||
char *this_path;
|
||||
|
||||
/* Ensure that we are only quiet when explicitly told to be */
|
||||
unsetenv("EINFO_QUIET");
|
||||
@@ -450,18 +451,18 @@ mountinfo(int argc, char **argv)
|
||||
args.mount_type = mount_from;
|
||||
break;
|
||||
|
||||
case_RC_COMMON_GETOPT
|
||||
}
|
||||
case_RC_COMMON_GETOPT
|
||||
}
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
if (argv[optind][0] != '/')
|
||||
eerrorx("%s: `%s' is not a mount point",
|
||||
argv[0], argv[optind]);
|
||||
if (realpath(argv[optind++], real_path) == NULL) {
|
||||
eerrorx("%s: realpath() failed: %s", argv[0], strerror(errno));
|
||||
}
|
||||
rc_stringlist_add(args.mounts, real_path);
|
||||
this_path = argv[optind++];
|
||||
if (realpath(this_path, real_path))
|
||||
this_path = real_path;
|
||||
rc_stringlist_add(args.mounts, this_path);
|
||||
}
|
||||
nodes = find_mounts(&args);
|
||||
rc_stringlist_free(args.mounts);
|
||||
|
||||
@@ -173,7 +173,7 @@ rc_depend(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case_RC_COMMON_GETOPT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (deptree_file) {
|
||||
|
||||
@@ -109,8 +109,8 @@ rc_service(int argc, char **argv)
|
||||
return EXIT_SUCCESS;
|
||||
/* NOTREACHED */
|
||||
|
||||
case_RC_COMMON_GETOPT
|
||||
}
|
||||
case_RC_COMMON_GETOPT
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user