Compare commits
47 Commits
openrc-0.8
...
funtoo-ope
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7146e99855 | ||
|
|
e65ce9e301 | ||
|
|
7ca74d7636 | ||
|
|
e49da2af91 | ||
|
|
a2c8e5ce50 | ||
|
|
11d8b70d74 | ||
|
|
227f831639 | ||
|
|
98d3b407fe | ||
|
|
fe18c7bb63 | ||
|
|
f8ff4a86a3 | ||
|
|
d59e245bc7 | ||
|
|
74c8667497 | ||
|
|
3d56124ed1 | ||
|
|
bb34ea886a | ||
|
|
fd48bc09ff | ||
|
|
db1daa5857 | ||
|
|
2493a1f32e | ||
|
|
40341fcd7e | ||
|
|
8fcaba9a22 | ||
|
|
04e256e3b8 | ||
|
|
b712a9161f | ||
|
|
8202e7dce4 | ||
|
|
2d197357ef | ||
|
|
b6409feaac | ||
|
|
ede4d1cd60 | ||
|
|
64ef51ab09 | ||
|
|
372bae3213 | ||
|
|
ac56ab7f6d | ||
|
|
6a5e6f1ee0 | ||
|
|
d8ce5dccb2 | ||
|
|
62bd337494 | ||
|
|
06c8bd0156 | ||
|
|
33803219d4 | ||
|
|
18c08a9d4d | ||
|
|
2406dc4f3e | ||
|
|
8e6d461a7f | ||
|
|
472a3bb99c | ||
|
|
c9a2085699 | ||
|
|
69169b7e95 | ||
|
|
3a11f8af34 | ||
|
|
e2e5b27d85 | ||
|
|
f343360741 | ||
|
|
694fd2027f | ||
|
|
ca76764743 | ||
|
|
19bd9923d7 | ||
|
|
2a844e1122 | ||
|
|
5135412978 |
15
.gitignore
vendored
15
.gitignore
vendored
@@ -1 +1,16 @@
|
||||
*.bz2
|
||||
|
||||
*.diff
|
||||
*.patch
|
||||
*.orig
|
||||
*.rej
|
||||
|
||||
core
|
||||
.gdb_history
|
||||
.gdbinit
|
||||
|
||||
.depend
|
||||
*.a
|
||||
*.o
|
||||
*.So
|
||||
lib*.so
|
||||
|
||||
@@ -5,27 +5,6 @@ removed, it should also be removed from this file.
|
||||
|
||||
---------------------------
|
||||
|
||||
What: rc_sys automatic detection code
|
||||
- Functions for removal: rc_sys_v1, rc_sys_v2
|
||||
|
||||
When: 2011/03/01
|
||||
|
||||
Why: The original automatic sub-system detection is flawed in that it cannot
|
||||
safely detect some variables (Using cgroups confused it to think you were
|
||||
using LXC, and Prefix cannot be detect by definition). Also, almost all of
|
||||
the detection requires that /proc is available and readable. During early
|
||||
boot, /proc may not be mounted yet, leading to mis-detection. The readable
|
||||
condition can also fail under some hardened kernels when running as an
|
||||
unprivileged user.
|
||||
|
||||
The new rc_sys_v2 function uses the rc_sys variable from rc.conf. After
|
||||
the removal, the contents of the rc_sys_v2 function will move into the
|
||||
rc_sys function.
|
||||
|
||||
Who: Robin H. Johnson <robbat2@gentoo.org>
|
||||
|
||||
---------------------------
|
||||
|
||||
What: oldnet ADSL rp-pppoe mode
|
||||
|
||||
When: undecided
|
||||
|
||||
72
README
72
README
@@ -1,8 +1,9 @@
|
||||
OpenRC README
|
||||
|
||||
=============
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
make install
|
||||
Yup, that simple. Works with GNU make.
|
||||
|
||||
@@ -67,31 +68,54 @@ init.d.misc is not installed by default as the scripts will need
|
||||
tweaking on a per distro basis. They are also non essential to the operation
|
||||
of the system.
|
||||
|
||||
|
||||
Reporting Bugs
|
||||
--------------
|
||||
Bugs should go to the Gentoo Bugzilla:
|
||||
http://bugs.gentoo.org/
|
||||
You'll want the "Gentoo Linux" product and the "baselayout" component.
|
||||
|
||||
If you installed OpenRC from your chosen distribution, you should report
|
||||
bugs directly to them. For example, if you use Gentoo and emerged OpenRC
|
||||
then you should reports bugs to http://bugs.gentoo.org.
|
||||
|
||||
History - by Roy Marples
|
||||
------------------------
|
||||
I became a Gentoo/Linux developer in 2004 and wrote the modular network
|
||||
scripts for the Gentoo baselayout package. baselayout is a collection of
|
||||
bash scripts to bring up your computer and its services.
|
||||
Then towards the end of 2005 I found myself as the primary maintainer
|
||||
for baselayout.
|
||||
History - by Daniel Robbins
|
||||
---------------------------
|
||||
|
||||
At the start of 2007, baselayout-2 is announced to the world, re-writing the
|
||||
core of baselayout in C and allowing POSIX sh init scripts instead of
|
||||
forcing the use of bash. By Mid 2007 I have re-written everything, including
|
||||
init scripts, and alpha and pre baselayout-2 snapshots where put into Gentoo.
|
||||
Towards the end of 2007 I retired as a Gentoo developer for reasons I won't
|
||||
go into here. baselayout-2 was still in the pre stage, and aside from the
|
||||
fbsd users, it was masked everywhere. However, I also desired to keep the
|
||||
baselayout-2 project alive, but outside of Gentoo and into other projects
|
||||
such as FreeBSD.
|
||||
The Gentoo modular network scripts were created by Daniel Robbins for
|
||||
Gentoo Linux 1.0_rc6, in development during most of 2001 and released
|
||||
in September 2001. After their development, the dependency-based initscript
|
||||
system was maintained by a number of senior developers (add names here....
|
||||
need to look at baselayout cvs logs.)
|
||||
|
||||
As such, the Gentoo Council have allowed the creation of OpenRC under the
|
||||
2 clause BSD license, managed by me as an external project.
|
||||
excerpt from http://www.gentoo.org/news/en/gwn/20040426-newsletter.xml
|
||||
by Grant Goodyear:
|
||||
|
||||
"My recollection is that one of woodchip's more impressive early feats was the
|
||||
complete replacement of all of the init scripts in Portage for Gentoo Linux
|
||||
1.0_rc6. Through 1.0_rc5 Gentoo had used fairly standard rc scripts modified
|
||||
from Stampede Linux, but for 1.0_rc6 Daniel Robbins (drobbins) and Martin
|
||||
Schlemmer (azarah) had created a new dependency-based init script system that
|
||||
is still used today. Within a span of days Donny rewrote every single init
|
||||
script in the Portage tree and committed new masked packages to await the
|
||||
release of 1.0_rc6. Thanks to woodchip (and drobbins and azarah, of course) the
|
||||
transition to the new init scripts was nearly painless."
|
||||
|
||||
Roy Marples became a Gentoo/Linux developer in 2004 and maintained the modular
|
||||
network scripts for the Gentoo baselayout package. Then towards the end of
|
||||
2005, he became the the primary maintainer for baselayout.
|
||||
|
||||
At the start of 2007, Roy Marples announced the ongoing development of
|
||||
baselayout-2, containing a rewritten initscript code in C and allowing POSIX sh
|
||||
init scripts instead of forcing the use of bash. By Mid 2007 Roy Marples had
|
||||
re-implemented the Gentoo initscript design created by Daniel Robbins, using an
|
||||
entirely new code base. Alpha and pre-release baselayout-2 snapshots were
|
||||
added to Gentoo's Portage tree as an optional component.
|
||||
|
||||
Towards the end of 2007, Roy Marples retired as a Gentoo developer Baselayout-2
|
||||
was still in the pre stage, and aside from the fbsd users, it was masked
|
||||
everywhere. However, Roy Marples desired to keep the baselayout-2 project
|
||||
alive, but outside of Gentoo and into other projects such as FreeBSD.
|
||||
|
||||
As such, the Gentoo Council permitted Roy Marples to release OpenRC under the 2
|
||||
clause BSD license, managed by him as an external project. Around mid-2010, Roy
|
||||
Marples decided to no longer maintain OpenRC. At this point, he transferred
|
||||
development back to Gentoo, which continues to maintain the scripts. In
|
||||
addition, Daniel Robbins continues to maintain an independent version OpenRC
|
||||
for Funtoo Linux, which includes a Funtoo-specific network configuration
|
||||
system.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Use KEYMAP to specify the default console keymap. There is a complete tree
|
||||
# Use keymap to specify the default console keymap. There is a complete tree
|
||||
# of keymaps in /usr/share/keymaps to choose from.
|
||||
keymap="us"
|
||||
|
||||
|
||||
@@ -414,7 +414,7 @@
|
||||
# dhclient: emerge net-misc/dhcp
|
||||
# dhcpcd: emerge net-misc/dhcpcd
|
||||
# pump: emerge net-misc/pump
|
||||
# udhcpc: emerge net-misc/udhcp
|
||||
# udhcpc: emerge sys-apps/busybox
|
||||
|
||||
# If you have more than one DHCP client installed, you need to specify which
|
||||
# one to use - otherwise we default to dhcpcd if available.
|
||||
@@ -975,10 +975,12 @@
|
||||
# and you're done :)
|
||||
|
||||
# By default we don't wait for netplug/ifplugd to configure the interface.
|
||||
# If you would like it to wait so that other services know that network is up
|
||||
# then you can specify a timeout here.
|
||||
# If you would like it to wait so that other services know that network is
|
||||
# up then you can specify a timeout here. A value of 0 means wait forever,
|
||||
# and a negative value means never wait.
|
||||
#plug_timeout_eth0="10"
|
||||
# If you want to set it for all interfaces:
|
||||
#plug_timeout="10"
|
||||
# A value of 0 means wait forever.
|
||||
|
||||
# If you don't want to use netplug on a specific interface but you have it
|
||||
# installed, you can disable it for that interface via the modules statement
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
##############################################################################
|
||||
# FreeBSD SPECIFIC OPTIONS
|
||||
|
||||
# This is the subsystem type. Valid options on FreeBSD:
|
||||
# "" - nothing special
|
||||
# "jail" - FreeBSD jails
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
##############################################################################
|
||||
# LINUX SPECIFIC OPTIONS
|
||||
|
||||
# This is the subsystem type. Valid options on Linux:
|
||||
# "" - nothing special
|
||||
# "lxc" - Linux Containers
|
||||
@@ -15,9 +18,6 @@
|
||||
# PRESENTLY in, not the virtualization the environment is capable of.
|
||||
rc_sys="@RC_SYS_DEFAULT@"
|
||||
|
||||
##############################################################################
|
||||
# LINUX SPECIFIC OPTIONS
|
||||
|
||||
# This is the number of tty's used in most of the rc-scripts (like
|
||||
# consolefont, numlock, etc ...)
|
||||
rc_tty_number=12
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
##############################################################################
|
||||
# NetBSD SPECIFIC OPTIONS
|
||||
|
||||
# This is the subsystem type. Valid options on NetBSD:
|
||||
# "" - nothing special
|
||||
# "prefix" - Prefix
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
description="Sets the hostname of the machine."
|
||||
|
||||
depend() {
|
||||
keyword -prefix
|
||||
keyword -prefix -lxc
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
@@ -27,7 +27,7 @@ start()
|
||||
local_start
|
||||
fi
|
||||
|
||||
return 0
|
||||
eend 0
|
||||
}
|
||||
|
||||
stop()
|
||||
@@ -47,5 +47,5 @@ stop()
|
||||
local_stop
|
||||
fi
|
||||
|
||||
return 0
|
||||
eend 0
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ stop()
|
||||
fi
|
||||
|
||||
if [ "$RC_UNAME" = Linux ]; then
|
||||
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/sys|/sys/.*"
|
||||
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/run|/sys|/sys/.*"
|
||||
fi
|
||||
no_umounts_r="^($no_umounts_r)$"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ depend()
|
||||
start()
|
||||
{
|
||||
# Make sure we insert usbcore if it's a module
|
||||
if [ -f /proc/modules -a ! -d /proc/bus/usb ]; then
|
||||
if [ -f /proc/modules -a ! -d /sys/module/usbcore -a ! -d /proc/bus/usb ]; then
|
||||
modprobe -q usbcore
|
||||
fi
|
||||
|
||||
|
||||
4
mk/cc.mk
4
mk/cc.mk
@@ -1,7 +1,7 @@
|
||||
# Copyright (c) 2008 Roy Marples <roy@marples.name>
|
||||
|
||||
# Setup some good default CFLAGS
|
||||
CFLAGS?= -O2
|
||||
CFLAGS?= -O2 -g
|
||||
|
||||
# Default to using the C99 standard
|
||||
CSTD?= c99
|
||||
@@ -31,3 +31,5 @@ _CC_FLAGS_SH= for f in ${_CCFLAGS}; do \
|
||||
done;
|
||||
_CC_FLAGS:= $(shell ${_CC_FLAGS_SH})
|
||||
CFLAGS+= ${_CC_FLAGS}
|
||||
|
||||
include ${MK}/debug.mk
|
||||
|
||||
@@ -97,13 +97,16 @@ bonding_pre_start()
|
||||
# finally add in slaves
|
||||
eoutdent
|
||||
if [ -d /sys/class/net ]; then
|
||||
sys_bonding_path=/sys/class/net/"${IFACE}"/bonding
|
||||
if [ -n "${primary}" ]; then
|
||||
echo "+${primary}" >/sys/class/net/"${IFACE}"/bonding/slaves
|
||||
echo "${primary}" >/sys/class/net/"${IFACE}"/bonding/primary
|
||||
echo "+${primary}" >$sys_bonding_path/slaves
|
||||
echo "${primary}" >$sys_bonding_path/primary
|
||||
fi
|
||||
for s in ${slaves}; do
|
||||
[ "${s}" = "${primary}" ] && continue
|
||||
echo "+${s}" >/sys/class/net/"${IFACE}"/bonding/slaves
|
||||
if ! grep -q ${s} $sys_bonding_path/slaves; then
|
||||
echo "+${s}" >$sys_bonding_path/slaves
|
||||
fi
|
||||
done
|
||||
else
|
||||
/sbin/ifenslave "${IFACE}" ${slaves} >/dev/null
|
||||
|
||||
@@ -8,60 +8,89 @@ ccwgroup_depend()
|
||||
before interface
|
||||
}
|
||||
|
||||
ccwgroup_pre_start()
|
||||
ccwgroup_load_modules()
|
||||
{
|
||||
local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
|
||||
[ -z "${ccwgroup}" ] && return 0
|
||||
|
||||
if [ ! -d /sys/bus/ccwgroup ]; then
|
||||
modprobe qeth
|
||||
if [ ! -d /sys/bus/ccwgroup ]; then
|
||||
# make sure we have ccwgroup support or this is a crap shoot
|
||||
if [ ! -d /sys/bus/ccwgroup ] ; then
|
||||
modprobe -q ccwgroup
|
||||
if [ ! -d /sys/bus/ccwgroup ] ; then
|
||||
eerror "ccwgroup support missing in kernel"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
einfo "Enabling ccwgroup on ${IFACE}"
|
||||
local x= ccw= first= layer2=
|
||||
for x in ${ccwgroup}; do
|
||||
[ -z "${first}" ] && first=${x}
|
||||
ccw="${ccw}${ccw:+,}${x}"
|
||||
done
|
||||
if [ -e /sys/devices/qeth/"${first}" ]; then
|
||||
echo "0" >/sys/devices/qeth/"${first}"/online
|
||||
else
|
||||
echo "${ccw}" >/sys/bus/ccwgroup/drivers/qeth/group
|
||||
# verify the specific interface is supported
|
||||
if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then
|
||||
modprobe $1 >& /dev/null
|
||||
if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then
|
||||
eerror "$1 support missing in kernel"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
eval layer2=\$qeth_layer2_${IFVAR}
|
||||
echo "${layer2:-0}" > /sys/devices/qeth/"${first}"/layer2
|
||||
echo "1" >/sys/devices/qeth/"${first}"/online
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
ccwgroup_pre_start()
|
||||
{
|
||||
local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
|
||||
[ -z "${ccwgroup}" ] && return 0
|
||||
|
||||
local ccw_type
|
||||
eval ccw_type=\${ccwgroup_type_${IFVAR}:-qeth}
|
||||
|
||||
ccwgroup_load_modules ${ccw_type} || return 1
|
||||
|
||||
einfo "Enabling ccwgroup/${ccw_type} on ${IFACE}"
|
||||
|
||||
set -- ${ccwgroup}
|
||||
local first=$1; shift
|
||||
if [ -e /sys/devices/${ccw_type}/${first}/online ]; then
|
||||
echo "0" >/sys/devices/${ccw_type}/${first}/online
|
||||
else
|
||||
echo "${first}$(printf ',%s' "$@")" >/sys/bus/ccwgroup/drivers/${ccw_type}/group
|
||||
fi
|
||||
|
||||
local var val
|
||||
for var in $(_get_array "ccwgroup_opts_${IFVAR}") online=1 ; do
|
||||
val=${var#*=}
|
||||
var=${var%%=*}
|
||||
echo "${val}" > /sys/devices/${ccw_type}/${first}/${var}
|
||||
done
|
||||
eend $?
|
||||
}
|
||||
|
||||
ccwgroup_pre_stop()
|
||||
{
|
||||
local path="/sys/class/net/${IFACE}"
|
||||
|
||||
# Erase any existing ccwgroup to be safe
|
||||
service_set_value ccwgroup_device ""
|
||||
service_set_value ccwgroup_type ""
|
||||
|
||||
[ ! -L /sys/class/net/"${FACE}"/driver ] && return 0
|
||||
local driver="$(readlink /sys/class/net/"${IFACE}"/driver)"
|
||||
case "${diver}" in
|
||||
*/bus/ccwgroup/*);;
|
||||
[ ! -L "${path}"/device/driver ] && return 0
|
||||
case "$(readlink "${path}"/device/driver)" in
|
||||
*/bus/ccwgroup/*) ;;
|
||||
*) return 0;;
|
||||
esac
|
||||
|
||||
local device="$(readlink /sys/class/net/"${IFACE}"/device)"
|
||||
local device
|
||||
device="$(readlink "${path}"/device)"
|
||||
device=${device##*/}
|
||||
service_set_value ccwgroup_device "${device}"
|
||||
device="$(readlink "${path}"/device/driver)"
|
||||
device=${device##*/}
|
||||
service_set_value ccwgroup_type "${device}"
|
||||
}
|
||||
|
||||
ccwgroup_post_stop()
|
||||
{
|
||||
local device="$(service_get_value ccwgroup_device)"
|
||||
[ -z "${device}" ] && return 0
|
||||
local ccw_type="$(service_get_value ccwgroup_type)"
|
||||
|
||||
einfo "Disabling ccwgroup on ${iface}"
|
||||
echo "0" >/sys/devices/qeth/"${device}"/online
|
||||
echo "1" >/sys/devices/qeth/"${device}"/ungroup
|
||||
einfo "Disabling ccwgroup/${ccw_type} on ${IFACE}"
|
||||
echo "0" >/sys/devices/${ccw_type}/"${device}"/online
|
||||
echo "1" >/sys/devices/${ccw_type}/"${device}"/ungroup
|
||||
eend $?
|
||||
}
|
||||
|
||||
@@ -51,7 +51,9 @@ ifplugd_pre_start()
|
||||
|
||||
eindent
|
||||
|
||||
# IFACE-specific, then global, then default
|
||||
eval timeout=\$plug_timeout_${IFVAR}
|
||||
[ -z "${timeout}" ] && timeout=$plug_timeout
|
||||
[ -z "${timeout}" ] && timeout=-1
|
||||
if [ ${timeout} -eq 0 ]; then
|
||||
ewarn "WARNING: infinite timeout set for ${IFACE} to come up"
|
||||
|
||||
@@ -53,7 +53,9 @@ netplugd_pre_start()
|
||||
|
||||
eindent
|
||||
|
||||
# IFACE-specific, then global, then default
|
||||
eval timeout=\$plug_timeout_${IFVAR}
|
||||
[ -z "${timeout}" ] && timeout=$plug_timeout
|
||||
[ -z "${timeout}" ] && timeout=-1
|
||||
if [ ${timeout} -eq 0 ]; then
|
||||
ewarn "WARNING: infinite timeout set for ${IFACE} to come up"
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
|
||||
udhcpc_depend()
|
||||
{
|
||||
program start /sbin/udhcpc
|
||||
program start /bin/busybox
|
||||
after interface
|
||||
provide dhcp
|
||||
}
|
||||
|
||||
_config_vars="$_config_vars dhcp udhcpc"
|
||||
|
||||
# WARNING:- The relies heavily on Gentoo patches and scripts for udhcpc
|
||||
udhcpc_start()
|
||||
{
|
||||
local args= opt= opts= pidfile="/var/run/udhcpc-${IFACE}.pid"
|
||||
@@ -22,17 +21,22 @@ udhcpc_start()
|
||||
eval opts=\$dhcp_${IFVAR}
|
||||
[ -z "${opts}" ] && opts=${dhcp}
|
||||
|
||||
# This omits the Gentoo specific patch to busybox,
|
||||
# but it creates temporary files.
|
||||
# We can move this stuff to udhcpc hook script to avoid that, should we do?
|
||||
local conf="/var/run/udhcpc-${IFACE}.conf"
|
||||
echo -n >"$conf"
|
||||
# Map some generic options to dhcpcd
|
||||
for opt in ${opts}; do
|
||||
case "${opt}" in
|
||||
nodns) args="${args} --env PEER_DNS=no";;
|
||||
nontp) args="${args} --env PEER_NTP=no";;
|
||||
nogateway) args="${args} --env PEER_ROUTERS=no";;
|
||||
nodns) echo "PEER_DNS=no" >>"$conf" ;;
|
||||
nontp) echo "PEER_NTP=no" >>"$conf" ;;
|
||||
nogateway) echo "PEER_ROUTERS=no" >>"$conf" ;;
|
||||
nosendhost) sendhost=false;
|
||||
esac
|
||||
done
|
||||
|
||||
[ "${metric:-0}" != "0" ] && args="${args} --env IF_METRIC=${metric}"
|
||||
[ "${metric:-0}" != "0" ] && echo "IF_METRIC=${metric}" >>"$conf"
|
||||
|
||||
ebegin "Running udhcpc"
|
||||
|
||||
@@ -51,9 +55,9 @@ udhcpc_start()
|
||||
fi
|
||||
|
||||
case " ${args} " in
|
||||
*" --quit "*|*" -q "*) x="/sbin/udhcpc";;
|
||||
*) x="start-stop-daemon --start --exec /sbin/udhcpc \
|
||||
--pidfile \"${pidfile}\" --";;
|
||||
*" --quit "*|*" -q "*) x="/bin/busybox udhcpc";;
|
||||
*) x="start-stop-daemon --start --exec /bin/busybox \
|
||||
--pidfile \"${pidfile}\" -- udhcpc";;
|
||||
esac
|
||||
|
||||
case " ${args} " in
|
||||
@@ -68,11 +72,8 @@ udhcpc_start()
|
||||
;;
|
||||
esac
|
||||
|
||||
local script="${RC_LIBEXECDIR}"/sh/udhcpc.h
|
||||
[ -x "${script}" ] || script=/lib/rcscripts/sh/udhcpc.sh
|
||||
|
||||
eval "${x}" "${args}" --interface="${IFACE}" --now \
|
||||
--script="${script}" \
|
||||
--script="${RC_LIBEXECDIR}/sh/udhcpc-hook.sh" \
|
||||
--pidfile="${pidfile}" >/dev/null
|
||||
eend $? || return 1
|
||||
|
||||
@@ -92,14 +93,18 @@ udhcpc_stop()
|
||||
ebegin "Stopping udhcpc on ${IFACE}"
|
||||
case " ${opts} " in
|
||||
*" release "*)
|
||||
start-stop-daemon --stop --quiet --oknodo --signal USR2 \
|
||||
--exec /sbin/udhcpc --pidfile "${pidfile}"
|
||||
start-stop-daemon --stop --quiet --signal USR2 \
|
||||
--exec /bin/busybox --pidfile "${pidfile}"
|
||||
if [ -f /var/cache/udhcpc-"${IFACE}".lease ]; then
|
||||
rm -f /var/cache/udhcpc-"${IFACE}".lease
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
start-stop-daemon --stop --exec /sbin/udhcpc --pidfile "${pidfile}"
|
||||
start-stop-daemon --stop --exec /bin/busybox --pidfile "${pidfile}"
|
||||
eend $?
|
||||
|
||||
if [ -e "/var/run/udhcpc-${IFACE}.conf" ]; then
|
||||
rm -f "/var/run/udhcpc-${IFACE}.conf"
|
||||
fi
|
||||
}
|
||||
|
||||
1
sh/.gitignore
vendored
1
sh/.gitignore
vendored
@@ -7,3 +7,4 @@ init.sh
|
||||
init-early.sh
|
||||
ifwatchd-carrier.sh
|
||||
ifwatchd-nocarrier.sh
|
||||
udhcpc-hook.sh
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
SRCS+= init.sh.in init-early.sh.in
|
||||
BIN+= init-early.sh
|
||||
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:
|
||||
|
||||
@@ -104,7 +104,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; @LIBEXECDIR@/bin/$_e \"\$@\"; _r=$?; \
|
||||
eval "$_e() { local _r; @LIBEXECDIR@/bin/$_e \"\$@\"; _r=\$?; \
|
||||
export EINFO_LASTCMD=$_e; return \$_r; }"
|
||||
done
|
||||
unset _e
|
||||
|
||||
@@ -91,6 +91,30 @@ if $mountproc; then
|
||||
eend $?
|
||||
fi
|
||||
|
||||
# Mount tmpfs on /run when directory exists.
|
||||
# /run is a new directory for storing volatile runtime data.
|
||||
# Read more about /run at https://lwn.net/Articles/436012
|
||||
if [ -d /run ]; then
|
||||
if mountinfo -q /run; then
|
||||
einfo "/run is already mounted, skipping"
|
||||
else
|
||||
ebegin "Mounting /run"
|
||||
if ! fstabinfo --mount /run; then
|
||||
mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run
|
||||
fi
|
||||
eend $?
|
||||
fi
|
||||
if [ ! -d /run/lock ]; then
|
||||
mkdir /run/lock
|
||||
fi
|
||||
if [ -d /run/lock ]; then
|
||||
chown root:uucp /run/lock
|
||||
chmod 0775 /run/lock
|
||||
fi
|
||||
elif [ -e /run ]; then
|
||||
einfo "Unable to mount /run since it is not a directory"
|
||||
fi
|
||||
|
||||
# Try to mount xenfs as early as possible, otherwise rc_sys() will always
|
||||
# return RC_SYS_XENU and will think that we are in a domU while it's not.
|
||||
if grep -Eq "[[:space:]]+xenfs$" /proc/filesystems; then
|
||||
|
||||
@@ -16,6 +16,18 @@ sourcex()
|
||||
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."
|
||||
eerror "You may be inside a chroot or you may have used"
|
||||
eerror "another initialization system to boot this system."
|
||||
eerror "In this situation, you will get unpredictable results!"
|
||||
eerror
|
||||
eerror "If you really want to do this, issue the following command:"
|
||||
eerror "touch ${RC_SVCDIR}/softlevel"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sourcex "@SYSCONFDIR@/init.d/functions.sh"
|
||||
sourcex "@LIBEXECDIR@/sh/rc-functions.sh"
|
||||
|
||||
|
||||
117
sh/udhcpc-hook.sh.in
Normal file
117
sh/udhcpc-hook.sh.in
Normal file
@@ -0,0 +1,117 @@
|
||||
#!@SHELL@
|
||||
# busybox udhcp setup script
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||
|
||||
peer_var()
|
||||
{
|
||||
[ -n "$1" ] && [ "$1" != "yes" ]
|
||||
}
|
||||
|
||||
update_dns()
|
||||
{
|
||||
peer_var "${PEER_DNS}" && return
|
||||
[ -z "${domain}" ] && [ -z "${dns}" ] && return
|
||||
|
||||
conf="# Generated by udhcpc for ${interface}\n"
|
||||
[ -n "${domain}" ] && conf="${conf}search ${domain}\n"
|
||||
for i in ${dns} ; do
|
||||
conf="${conf}nameserver ${i}\n"
|
||||
done
|
||||
if [ -x /sbin/resolvconf ] ; then
|
||||
printf "${conf}" | resolvconf -a ${interface}
|
||||
else
|
||||
printf "${conf}" > /etc/resolv.conf
|
||||
chmod 644 /etc/resolv.conf
|
||||
fi
|
||||
}
|
||||
|
||||
update_ntp()
|
||||
{
|
||||
peer_var "${PEER_NTP}" && return
|
||||
[ -z "${ntpsrv}" ] && return
|
||||
|
||||
conf="# Generated by udhcpc for interface ${interface}\n"
|
||||
conf="${conf}restrict default noquery notrust nomodify\n"
|
||||
conf="${conf}restrict 127.0.0.1\n"
|
||||
for i in ${ntpsrv} ; do
|
||||
conf="${conf}restrict ${i} nomodify notrap noquery\n"
|
||||
conf="${conf}server ${i}\n"
|
||||
done
|
||||
conf="${conf}driftfile /var/lib/ntp/ntp.drift\n"
|
||||
conf="${conf}logfile /var/log/ntp.log\n"
|
||||
printf "${conf}" > /etc/ntp.conf
|
||||
chmod 644 /etc/ntp.conf
|
||||
}
|
||||
|
||||
update_hostname()
|
||||
{
|
||||
peer_var "${PEER_HOSTNAME}" && return
|
||||
[ -z "${hostname}" ] && return
|
||||
|
||||
myhost="$(hostname)"
|
||||
[ -z "${myhost}" ] || [ "${myhost}" = "(none)" ] && hostname "${hostname}"
|
||||
}
|
||||
|
||||
update_interface()
|
||||
{
|
||||
[ -n "${broadcast}" ] && broadcast="broadcast ${broadcast}"
|
||||
[ -n "${subnet}" ] && netmask="netmask ${subnet}"
|
||||
[ -n "${mtu}" ] && mtu="mtu ${mtu}"
|
||||
ifconfig "${interface}" ${ip} ${broadcast} ${netmask} ${mtu}
|
||||
}
|
||||
|
||||
update_routes()
|
||||
{
|
||||
peer_var "${PEER_ROUTERS}" && return
|
||||
|
||||
if [ -n "${router}" ] ; then
|
||||
metric=
|
||||
[ -n "${IF_METRIC}" ] && metric="metric ${IF_METRIC}"
|
||||
for i in ${router} ; do
|
||||
route add default gw "${i}" ${metric} dev "${interface}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
deconfig()
|
||||
{
|
||||
ifconfig "${interface}" 0.0.0.0
|
||||
|
||||
if ! peer_var "${PEER_ROUTERS}" ; then
|
||||
while route del default dev "${interface}" >& /dev/null; do
|
||||
:
|
||||
done
|
||||
fi
|
||||
|
||||
if ! peer_var "${PEER_DNS}" ; then
|
||||
[ -x /sbin/resolvconf ] && resolvconf -d "${interface}"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -r "/var/run/udhcpc-${interface}.conf" ]; then
|
||||
. "/var/run/udhcpc-${interface}.conf"
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
bound|renew)
|
||||
update_hostname
|
||||
update_interface
|
||||
update_routes
|
||||
update_dns
|
||||
update_ntp
|
||||
;;
|
||||
deconfig|leasefail)
|
||||
deconfig
|
||||
;;
|
||||
nak)
|
||||
echo "nak: ${message}"
|
||||
;;
|
||||
*)
|
||||
echo "unknown option $1" >&2
|
||||
echo "Usage: $0 {bound|deconfig|leasefail|nak|renew}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
6
src/libeinfo/.gitignore
vendored
6
src/libeinfo/.gitignore
vendored
@@ -1,7 +1 @@
|
||||
.depend
|
||||
libeinfo.o
|
||||
libeinfo.So
|
||||
libeinfo.a
|
||||
libeinfo.so.1
|
||||
libeinfo.so
|
||||
.depend
|
||||
|
||||
@@ -9,5 +9,4 @@ CPPFLAGS+= -I../includes
|
||||
MK= ../../mk
|
||||
include ${MK}/lib.mk
|
||||
include ${MK}/cc.mk
|
||||
include ${MK}/debug.mk
|
||||
include ${MK}/termcap.mk
|
||||
|
||||
14
src/librc/.gitignore
vendored
14
src/librc/.gitignore
vendored
@@ -1,16 +1,2 @@
|
||||
.depend
|
||||
librc.o
|
||||
librc-daemon.o
|
||||
librc-depend.o
|
||||
librc-misc.o
|
||||
librc-stringlist.o
|
||||
librc.So
|
||||
librc-daemon.So
|
||||
librc-depend.So
|
||||
librc-misc.So
|
||||
librc-stringlist.So
|
||||
librc.a
|
||||
librc.so.1
|
||||
librc.so
|
||||
.depend
|
||||
rc.h
|
||||
|
||||
@@ -12,7 +12,6 @@ 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'
|
||||
|
||||
@@ -308,10 +308,10 @@ _match_list(const char *exec, const char *const *argv, const char *pidfile)
|
||||
|
||||
if (pidfile) {
|
||||
l = strlen(pidfile) + 9;
|
||||
m = xmalloc(sizeof (char) * l);
|
||||
m = xmalloc(sizeof(char) * l);
|
||||
snprintf(m, l, "pidfile=%s", pidfile);
|
||||
rc_stringlist_add(match, m);
|
||||
free (m);
|
||||
free(m);
|
||||
}
|
||||
|
||||
return match;
|
||||
@@ -508,7 +508,7 @@ rc_service_daemons_crashed(const char *service)
|
||||
if ((fp = fopen(pidfile, "r"))) {
|
||||
if (fscanf(fp, "%d", &pid) == 1)
|
||||
retval = false;
|
||||
fclose (fp);
|
||||
fclose(fp);
|
||||
}
|
||||
free(pidfile);
|
||||
pidfile = NULL;
|
||||
|
||||
@@ -144,7 +144,7 @@ rc_deptree_load_file(const char *deptree_file)
|
||||
e = strsep(&p, "_");
|
||||
if (!e || strcmp(e, "depinfo") != 0)
|
||||
continue;
|
||||
e = strsep (&p, "_");
|
||||
e = strsep(&p, "_");
|
||||
if (!e || sscanf(e, "%d", &i) != 1)
|
||||
continue;
|
||||
if (!(type = strsep(&p, "_=")))
|
||||
@@ -425,8 +425,8 @@ visit_service(const RC_DEPTREE *deptree,
|
||||
continue;
|
||||
provided = get_provided(di, runlevel, options);
|
||||
TAILQ_FOREACH(p, provided, entries)
|
||||
if (strcmp (p->value, depinfo->service) == 0) {
|
||||
visit_service (deptree, types, sorted, visited, di,
|
||||
if (strcmp(p->value, depinfo->service) == 0) {
|
||||
visit_service(deptree, types, sorted, visited, di,
|
||||
runlevel, options | RC_DEP_TRACE);
|
||||
break;
|
||||
}
|
||||
@@ -681,7 +681,7 @@ rc_deptree_update_needed(time_t *newest, char *file)
|
||||
/* Create base directories if needed */
|
||||
for (i = 0; depdirs[i]; i++)
|
||||
if (mkdir(depdirs[i], 0755) != 0 && errno != EEXIST)
|
||||
fprintf(stderr, "mkdir `%s': %s\n", depdirs[i], strerror (errno));
|
||||
fprintf(stderr, "mkdir `%s': %s\n", depdirs[i], strerror(errno));
|
||||
|
||||
/* Quick test to see if anything we use has changed and we have
|
||||
* data in our deptree */
|
||||
@@ -922,7 +922,7 @@ rc_deptree_update(void)
|
||||
di = get_depinfo(deptree, s->value);
|
||||
if (!di) {
|
||||
if (strcmp(deptype->type, "ineed") == 0) {
|
||||
fprintf (stderr,
|
||||
fprintf(stderr,
|
||||
"Service `%s' needs non"
|
||||
" existent service `%s'\n",
|
||||
depinfo->service, s->value);
|
||||
@@ -1032,7 +1032,7 @@ rc_deptree_update(void)
|
||||
if (TAILQ_FIRST(config)) {
|
||||
if ((fp = fopen(RC_DEPCONFIG, "w"))) {
|
||||
TAILQ_FOREACH(s, config, entries)
|
||||
fprintf (fp, "%s\n", s->value);
|
||||
fprintf(fp, "%s\n", s->value);
|
||||
fclose(fp);
|
||||
} else {
|
||||
fprintf(stderr, "fopen `%s': %s\n",
|
||||
|
||||
@@ -41,7 +41,7 @@ rc_stringlist_new(void)
|
||||
librc_hidden_def(rc_stringlist_new)
|
||||
|
||||
RC_STRING *
|
||||
rc_stringlist_add (RC_STRINGLIST *list, const char *value)
|
||||
rc_stringlist_add(RC_STRINGLIST *list, const char *value)
|
||||
{
|
||||
RC_STRING *s = xmalloc(sizeof(*s));
|
||||
|
||||
@@ -52,7 +52,7 @@ rc_stringlist_add (RC_STRINGLIST *list, const char *value)
|
||||
librc_hidden_def(rc_stringlist_add)
|
||||
|
||||
RC_STRING *
|
||||
rc_stringlist_addu (RC_STRINGLIST *list, const char *value)
|
||||
rc_stringlist_addu(RC_STRINGLIST *list, const char *value)
|
||||
{
|
||||
RC_STRING *s;
|
||||
|
||||
@@ -74,8 +74,8 @@ rc_stringlist_delete(RC_STRINGLIST *list, const char *value)
|
||||
TAILQ_FOREACH(s, list, entries)
|
||||
if (strcmp(s->value, value) == 0) {
|
||||
TAILQ_REMOVE(list, s, entries);
|
||||
free (s->value);
|
||||
free (s);
|
||||
free(s->value);
|
||||
free(s);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ rc_stringlist_sort(RC_STRINGLIST **list)
|
||||
TAILQ_REMOVE(l, s, entries);
|
||||
last = NULL;
|
||||
TAILQ_FOREACH(n, new, entries) {
|
||||
if (strcmp (s->value, n->value) < 0)
|
||||
if (strcmp(s->value, n->value) < 0)
|
||||
break;
|
||||
last = n;
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ rc_service_exists(const char *service)
|
||||
}
|
||||
librc_hidden_def(rc_service_exists)
|
||||
|
||||
#define OPTSTR ". '%s'; echo $opts"
|
||||
#define OPTSTR ". '%s'; echo $extra_commands $extra_started_commands"
|
||||
RC_STRINGLIST *
|
||||
rc_service_extra_commands(const char *service)
|
||||
{
|
||||
@@ -550,14 +550,16 @@ rc_service_extra_commands(const char *service)
|
||||
if ((fp = popen(cmd, "r"))) {
|
||||
rc_getline(&buffer, &len, fp);
|
||||
p = buffer;
|
||||
while ((token = strsep(&p, " "))) {
|
||||
if (!commands)
|
||||
commands = rc_stringlist_new();
|
||||
rc_stringlist_add(commands, token);
|
||||
}
|
||||
commands = rc_stringlist_new();
|
||||
|
||||
while ((token = strsep(&p, " ")))
|
||||
if (token[0] != '\0')
|
||||
rc_stringlist_add(commands, token);
|
||||
|
||||
pclose(fp);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
free(cmd);
|
||||
return commands;
|
||||
}
|
||||
@@ -747,7 +749,7 @@ rc_service_state(const char *service)
|
||||
|
||||
if (state & RC_SERVICE_STOPPED) {
|
||||
dirs = ls_dir(RC_SVCDIR "/scheduled", 0);
|
||||
TAILQ_FOREACH (dir, dirs, entries) {
|
||||
TAILQ_FOREACH(dir, dirs, entries) {
|
||||
snprintf(file, sizeof(file),
|
||||
RC_SVCDIR "/scheduled/%s/%s",
|
||||
dir->value, service);
|
||||
@@ -890,7 +892,7 @@ rc_services_in_runlevel_stacked(const char *runlevel)
|
||||
|
||||
list = rc_services_in_runlevel(runlevel);
|
||||
stacks = rc_runlevel_stacks(runlevel);
|
||||
TAILQ_FOREACH (stack, stacks, entries) {
|
||||
TAILQ_FOREACH(stack, stacks, entries) {
|
||||
sl = rc_services_in_runlevel(stack->value);
|
||||
if (list != NULL) {
|
||||
TAILQ_CONCAT(list, sl, entries);
|
||||
@@ -1006,7 +1008,7 @@ rc_services_scheduled_by(const char *service)
|
||||
RC_STRING *dir;
|
||||
char file[PATH_MAX];
|
||||
|
||||
TAILQ_FOREACH (dir, dirs, entries) {
|
||||
TAILQ_FOREACH(dir, dirs, entries) {
|
||||
snprintf(file, sizeof(file), RC_SVCDIR "/scheduled/%s/%s",
|
||||
dir->value, service);
|
||||
if (exists(file))
|
||||
|
||||
17
src/rc/.gitignore
vendored
17
src/rc/.gitignore
vendored
@@ -1,4 +1,3 @@
|
||||
.depend
|
||||
version.h
|
||||
rc-status
|
||||
rc-service
|
||||
@@ -56,20 +55,4 @@ mark_service_wasinactive
|
||||
mark_service_hotplugged
|
||||
mark_service_failed
|
||||
rc-abort
|
||||
checkpath.o
|
||||
fstabinfo.o
|
||||
mountinfo.o
|
||||
start-stop-daemon.o
|
||||
swclock.o
|
||||
rc-applets.o
|
||||
rc-depend.o
|
||||
rc-logger.o
|
||||
rc-misc.o
|
||||
rc-plugin.o
|
||||
rc-service.o
|
||||
rc-status.o
|
||||
rc-update.o
|
||||
runscript.o
|
||||
rc.o
|
||||
rc
|
||||
.depend
|
||||
|
||||
@@ -36,7 +36,6 @@ LDADD+= -lutil -lrc -leinfo
|
||||
|
||||
include ../../Makefile.inc
|
||||
MK= ../../mk
|
||||
include ${MK}/debug.mk
|
||||
include ${MK}/prog.mk
|
||||
include ${MK}/git.mk
|
||||
include ${MK}/cc.mk
|
||||
|
||||
@@ -164,6 +164,7 @@ show(RC_STRINGLIST *runlevels, bool verbose)
|
||||
char buffer[PATH_MAX];
|
||||
size_t l;
|
||||
|
||||
rc_stringlist_sort(&services);
|
||||
TAILQ_FOREACH(service, services, entries) {
|
||||
in = rc_stringlist_new();
|
||||
inone = false;
|
||||
@@ -299,6 +300,7 @@ rc_update(int argc, char **argv)
|
||||
runlevels = rc_runlevel_list();
|
||||
}
|
||||
|
||||
rc_stringlist_sort(&runlevels);
|
||||
show (runlevels, verbose);
|
||||
} else {
|
||||
if (!service)
|
||||
|
||||
@@ -806,7 +806,6 @@ main(int argc, char **argv)
|
||||
int opt;
|
||||
bool parallel;
|
||||
int regen = 0;
|
||||
int i;
|
||||
#ifdef __linux__
|
||||
char *proc;
|
||||
char *p;
|
||||
|
||||
@@ -1101,7 +1101,8 @@ runscript(int argc, char **argv)
|
||||
bool doneone = false;
|
||||
int retval, opt, depoptions = RC_DEP_TRACE;
|
||||
RC_STRING *svc;
|
||||
char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, pidstr[10];
|
||||
char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, *save2 = NULL;
|
||||
char pidstr[10];
|
||||
size_t l = 0, ll;
|
||||
const char *file;
|
||||
struct stat stbuf;
|
||||
@@ -1133,7 +1134,8 @@ runscript(int argc, char **argv)
|
||||
dir = dirname(path);
|
||||
if (strchr(lnk, '/')) {
|
||||
save = xstrdup(dir);
|
||||
dir = dirname(lnk);
|
||||
save2 = xstrdup(lnk);
|
||||
dir = dirname(save2);
|
||||
if (strcmp(dir, save) == 0)
|
||||
file = basename_c(argv[1]);
|
||||
else
|
||||
@@ -1149,6 +1151,7 @@ runscript(int argc, char **argv)
|
||||
service = xstrdup(lnk);
|
||||
}
|
||||
free(save);
|
||||
free(save2);
|
||||
}
|
||||
if (!service)
|
||||
service = xstrdup(path);
|
||||
|
||||
Reference in New Issue
Block a user