Compare commits
28 Commits
funtoo-ope
...
openrc-0.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5b14edda8 | ||
|
|
4ee62c7903 | ||
|
|
a029dee59b | ||
|
|
2330978300 | ||
|
|
0c8bea2152 | ||
|
|
3688c85163 | ||
|
|
370e5c775a | ||
|
|
df1f02ac84 | ||
|
|
863ef36011 | ||
|
|
05c2d68192 | ||
|
|
07694255a4 | ||
|
|
6fa6f9523f | ||
|
|
e3b02abd7a | ||
|
|
5541e5ba24 | ||
|
|
a74382d9cb | ||
|
|
fdaf1c65cd | ||
|
|
ef22868f36 | ||
|
|
0c7032840b | ||
|
|
fe6cd23287 | ||
|
|
05e3251467 | ||
|
|
9a068c2500 | ||
|
|
e8e86b96dc | ||
|
|
48dcc55b65 | ||
|
|
44dc7db4f8 | ||
|
|
003d4ba15b | ||
|
|
49f1a8702b | ||
|
|
be990b308a | ||
|
|
9076baa573 |
@@ -1,3 +1,3 @@
|
||||
NAME= openrc
|
||||
VERSION= 0.8.3
|
||||
VERSION= 0.9.0
|
||||
PKG= ${NAME}-${VERSION}
|
||||
|
||||
74
README
74
README
@@ -1,9 +1,8 @@
|
||||
OpenRC README
|
||||
=============
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
make install
|
||||
Yup, that simple. Works with GNU make.
|
||||
|
||||
@@ -68,54 +67,33 @@ 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
|
||||
--------------
|
||||
Since Gentoo Linux is hosting OpenRC development, Bugs should go to
|
||||
the Gentoo Bugzilla:
|
||||
http://bugs.gentoo.org/
|
||||
They should be filed under the "Gentoo Hosted Projects" product and
|
||||
the "openrc" 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 Daniel Robbins
|
||||
---------------------------
|
||||
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.
|
||||
|
||||
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, primarily Martin
|
||||
Schlemmer (azarah).
|
||||
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.
|
||||
|
||||
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.
|
||||
As such, the Gentoo Council have allowed the creation of OpenRC under the
|
||||
2 clause BSD license, managed by me as an external project.
|
||||
|
||||
51
STYLE
51
STYLE
@@ -32,3 +32,54 @@ void foo(int c)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
##################
|
||||
# COMMIT MESSAGES #
|
||||
##################
|
||||
|
||||
The following is an example of a correctly formatted git commit message
|
||||
for this repository. Most of this information came from this blog post
|
||||
[1], so I would like to thank the author.
|
||||
|
||||
### cut here ###
|
||||
Capitalized, short (50 chars or less) summary
|
||||
|
||||
More detailed explanatory text, if necessary. Wrap it to about 72
|
||||
characters or so. In some contexts, the first line is treated as the
|
||||
subject of an email and the rest of the text as the body. The blank
|
||||
line separating the summary from the body is critical (unless you omit
|
||||
the body entirely); tools like rebase can get confused if you run the
|
||||
two together.
|
||||
|
||||
Write your commit message in the present tense: "Fix bug" and not "Fixed
|
||||
bug." This convention matches up with commit messages generated by
|
||||
commands like git merge and git revert.
|
||||
|
||||
Further paragraphs come after blank lines.
|
||||
|
||||
- Bullet points are okay, too
|
||||
|
||||
- Typically a hyphen or asterisk is used for the bullet, preceded by a
|
||||
single space, with blank lines in between, but conventions vary here
|
||||
|
||||
- Use a hanging indent
|
||||
|
||||
Reported-by: User Name <email>
|
||||
X-[Distro]-Bug: BugID
|
||||
X-[Distro]-Bug-URL: URL for the bug (on the distribution's web site typically)
|
||||
### cut here ###
|
||||
|
||||
If you did not write the code and the patch does not include authorship
|
||||
information in a format git can use, please use the --author option of the
|
||||
git commit command to make the authorship correct.
|
||||
|
||||
The Reported-by tag is required if the person who reported the bug is
|
||||
different from the author and committer.
|
||||
|
||||
The X-[Distro]-Bug/Bug-URL tags are required if this commit is related
|
||||
to a bug reported to us by a specific distribution of linux or a
|
||||
*BSD. Also, [Distro] should be replaced with the name of the
|
||||
distribution, e.g. X-Gentoo-Bug.
|
||||
|
||||
[1] http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# You can define a list modules for a specific kernel version,
|
||||
# a released kernel version, a main kernel version or just a list.
|
||||
# The most specific versioned variable will take precedence.
|
||||
#modules_2_6_23_gentoo_r5="ieee1394 ohci1394"
|
||||
#modules_2_6_23="tun ieee1394"
|
||||
#modules_2_6="tun"
|
||||
#modules_2="ipv6"
|
||||
#modules="ohci1394"
|
||||
|
||||
# You can give modules a different name when they load - the new name
|
||||
@@ -10,10 +12,12 @@
|
||||
#modules="dummy:dummy1"
|
||||
|
||||
# Give the modules some arguments if needed, per version if necessary.
|
||||
# Again, the most specific versioned variable will take precedence.
|
||||
#module_ieee1394_args="debug"
|
||||
#module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394"
|
||||
#module_ieee1394_args_2_6_23="tun ieee1394"
|
||||
#module_ieee1394_args_2_6="tun"
|
||||
#module_ieee1394_args_2_6_23_gentoo_r5="debug2"
|
||||
#module_ieee1394_args_2_6_23="debug3"
|
||||
#module_ieee1394_args_2_6="debug4"
|
||||
#module_ieee1394_args_2="debug5"
|
||||
|
||||
# You should consult your kernel documentation and configuration
|
||||
# for a list of modules and their options.
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
# logging can take place and as such cannot log the sysinit runlevel.
|
||||
#rc_logger="YES"
|
||||
|
||||
# Through rc_log_path you can specify a custom log file.
|
||||
# The default value is: /var/log/rc.log
|
||||
#rc_log_path="/var/log/rc.log"
|
||||
|
||||
# By default we filter the environment for our running scripts. To allow other
|
||||
# variables through, add them here. Use a * to allow all variables through.
|
||||
#rc_env_allow="VAR1 VAR2"
|
||||
|
||||
@@ -16,7 +16,7 @@ start()
|
||||
{
|
||||
# Mount local filesystems in /etc/fstab.
|
||||
local types="noproc" x= no_netdev=
|
||||
for x in $net_fs_list; do
|
||||
for x in $net_fs_list $extra_net_fs_list; do
|
||||
types="${types},${x}"
|
||||
done
|
||||
|
||||
@@ -37,16 +37,10 @@ stop()
|
||||
local x= no_umounts_r="/|/dev|/dev/.*|${RC_SVCDIR}"
|
||||
no_umounts_r="${no_umounts_r}|/bin|/sbin|/lib|/libexec"
|
||||
# RC_NO_UMOUNTS is an env var that can be set by plugins
|
||||
local OIFS=$IFS SIFS=${IFS-y}
|
||||
IFS=$IFS:
|
||||
local IFS="$IFS:"
|
||||
for x in $no_umounts $RC_NO_UMOUNTS; do
|
||||
no_umounts_r="$no_umounts_r|$x"
|
||||
done
|
||||
if [ "$SIFS" = y ]; then
|
||||
IFS=$OIFS
|
||||
else
|
||||
unset IFS
|
||||
fi
|
||||
|
||||
if [ "$RC_UNAME" = Linux ]; then
|
||||
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/run|/sys|/sys/.*"
|
||||
@@ -70,7 +64,7 @@ stop()
|
||||
einfo "Unmounting filesystems"
|
||||
eindent
|
||||
local fs=
|
||||
for x in $net_fs_list; do
|
||||
for x in $net_fs_list $extra_net_fs_list; do
|
||||
fs="$fs${fs:+|}$x"
|
||||
done
|
||||
[ -n "$fs" ] && fs="^($fs)$"
|
||||
|
||||
@@ -16,18 +16,21 @@ start()
|
||||
# support compiled in ...
|
||||
[ ! -f /proc/modules ] && return 0
|
||||
|
||||
local KV=$(uname -r)
|
||||
local KV_MAJOR=${KV%%.*}
|
||||
local x=${KV#*.}
|
||||
local KV_MINOR=${x%%.*}
|
||||
x=${KV#*.*.}
|
||||
local KV_MICRO=${x%%-*}
|
||||
local KV x y kv_variant_list
|
||||
KV=$(uname -r)
|
||||
# full $KV
|
||||
kv_variant_list="${KV}"
|
||||
# remove any KV_EXTRA options to just get the full version
|
||||
x=${KV%%-*}
|
||||
# now slowly strip them
|
||||
while [ -n "$x" ] && [ "$x" != "$y" ]; do
|
||||
kv_variant_list="${kv_variant_list} $x"
|
||||
y=$x
|
||||
x=${x%.*}
|
||||
done
|
||||
|
||||
local list= x= xx= y= args= mpargs= cnt=0 a=
|
||||
for x in "$KV" \
|
||||
$KV_MAJOR.$KV_MINOR.$KV_MICRO \
|
||||
$KV_MAJOR.$KV_MINOR \
|
||||
; do
|
||||
for x in $kv_variant_list ; do
|
||||
eval list=\$modules_$(shell_var "$x")
|
||||
[ -n "$list" ] && break
|
||||
done
|
||||
@@ -45,10 +48,7 @@ start()
|
||||
fi
|
||||
aa=$(shell_var "$a")
|
||||
xx=$(shell_var "$x")
|
||||
for y in "$KV" \
|
||||
$KV_MAJOR.$KV_MINOR.$KV_MICRO \
|
||||
$KV_MAJOR.$KV_MINOR \
|
||||
; do
|
||||
for y in $kv_variant_list ; do
|
||||
eval args=\$module_${aa}_args_$(shell_var "$y")
|
||||
[ -n "${args}" ] && break
|
||||
eval args=\$module_${xx}_args_$(shell_var "$y")
|
||||
|
||||
@@ -22,19 +22,13 @@ start()
|
||||
local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|${RC_SVCDIR}" x= fs=
|
||||
m="$m|/bin|/sbin|/lib|/libexec"
|
||||
# RC_NO_UMOUNTS is an env var that can be set by plugins
|
||||
local OIFS=$IFS SIFS=${IFS-y} IFS=$IFS
|
||||
IFS=$IFS:
|
||||
local IFS="$IFS:"
|
||||
for x in $no_umounts $RC_NO_UMOUNTS; do
|
||||
m="$m|$x"
|
||||
done
|
||||
if [ "$SIFS" = y ]; then
|
||||
IFS=$OIFS
|
||||
else
|
||||
unset IFS
|
||||
fi
|
||||
m="^($m)$"
|
||||
fs=
|
||||
for x in $net_fs_list; do
|
||||
for x in $net_fs_list $extra_net_fs_list; do
|
||||
fs="$fs${fs:+|}$x"
|
||||
done
|
||||
[ -n "$fs" ] && fs="^($fs)$"
|
||||
|
||||
@@ -12,9 +12,9 @@ depend()
|
||||
|
||||
start()
|
||||
{
|
||||
# /etc/mtab could be a symlink to /proc/mounts
|
||||
if [ ! -w /etc/mtab -a -L /etc/mtab ]; then
|
||||
eeinfo "Skipping mtab update (non writeable symlink)"
|
||||
if [ -l /etc/mtab ]
|
||||
then
|
||||
einfo "Skipping mtab update (mtab is a symbolic link)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ _get_array()
|
||||
if [ -n "${BASH}" ]; then
|
||||
case "$(declare -p "$1" 2>/dev/null)" in
|
||||
"declare -a "*)
|
||||
ewarn "You are using a bash array for $1."
|
||||
ewarn "This feature will be removed in the future."
|
||||
ewarn "Please see net.example for the correct format for $1."
|
||||
eval "set -- \"\${$1[@]}\""
|
||||
for _a; do
|
||||
printf "%s\n" "${_a}"
|
||||
@@ -69,6 +72,9 @@ _flatten_array()
|
||||
if [ -n "${BASH}" ]; then
|
||||
case "$(declare -p "$1" 2>/dev/null)" in
|
||||
"declare -a "*)
|
||||
ewarn "You are using a bash array for $1."
|
||||
ewarn "This feature will be removed in the future."
|
||||
ewarn "Please see net.example for the correct format for $1."
|
||||
eval "set -- \"\${$1[@]}\""
|
||||
for x; do
|
||||
printf "'%s' " "$(printf "$x" | sed "s:':'\\\'':g")"
|
||||
@@ -539,7 +545,9 @@ start()
|
||||
[ -z "${config}" ] && break
|
||||
|
||||
set -- ${config}
|
||||
ebegin "$1"
|
||||
if [ "$1" != "null" -a "$1" != "noop" ]; then
|
||||
ebegin "$1"
|
||||
fi
|
||||
eindent
|
||||
case "$1" in
|
||||
noop)
|
||||
|
||||
@@ -44,7 +44,7 @@ start()
|
||||
[ -x @SYSCONFDIR@/init.d/rpcbind ] && pmap="rpcbind"
|
||||
|
||||
local x= fs= rc=
|
||||
for x in $net_fs_list; do
|
||||
for x in $net_fs_list $extra_net_fs_list; do
|
||||
case "$x" in
|
||||
nfs|nfs4)
|
||||
# If the nfsmount script took care of the nfs
|
||||
@@ -81,7 +81,7 @@ stop()
|
||||
ebegin "Unmounting network filesystems"
|
||||
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
|
||||
|
||||
for x in $net_fs_list; do
|
||||
for x in $net_fs_list $extra_net_fs_list; do
|
||||
fs="$fs${fs:+,}$x"
|
||||
done
|
||||
if [ -n "$fs" ]; then
|
||||
@@ -90,7 +90,7 @@ stop()
|
||||
|
||||
eindent
|
||||
fs=
|
||||
for x in $net_fs_list; do
|
||||
for x in $net_fs_list $extra_net_fs_list; do
|
||||
fs="$fs${fs:+|}$x"
|
||||
done
|
||||
[ -n "$fs" ] && fs="^($fs)$"
|
||||
|
||||
@@ -16,7 +16,9 @@ depend()
|
||||
start()
|
||||
{
|
||||
ebegin "Setting the local clock based on last shutdown time"
|
||||
swclock --warn
|
||||
if ! swclock 2> /dev/null; then
|
||||
swclock --warn @PREFIX@/sbin/runscript
|
||||
fi
|
||||
eend $?
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,7 @@ and
|
||||
respectively, but only work when
|
||||
.Va EINFO_VERBOSE
|
||||
is true. You can also make the
|
||||
.Fn einfo ,
|
||||
.Fn ewarn ,
|
||||
.Fn einfo
|
||||
and
|
||||
.Fn ebegin
|
||||
functions silent by setting
|
||||
|
||||
@@ -462,12 +462,6 @@ show()
|
||||
|
||||
.Ed
|
||||
.Sh BUGS
|
||||
Because of the way we load our configuration files and the need to handle
|
||||
more than one service directory, you can only use symlinks in service
|
||||
directories to other services in the same directory.
|
||||
You cannot symlink to a service in a different directory even if it is
|
||||
another service directory.
|
||||
.Pp
|
||||
is_older_than should return 0 on success.
|
||||
Instead we return 1 to be compliant with Gentoo baselayout.
|
||||
Users are encouraged to use the is_newer_than function which returns correctly.
|
||||
|
||||
@@ -29,7 +29,7 @@ ethtool_pre_start() {
|
||||
|
||||
# Skip everything if no arguments
|
||||
[ -z "${args}" ] && continue
|
||||
|
||||
|
||||
# Split on \n
|
||||
local IFS="$__IFS"
|
||||
|
||||
|
||||
@@ -111,38 +111,32 @@ _add_address()
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Convert an ifconfig line to iproute2
|
||||
if [ "$2" = "netmask" ]; then
|
||||
local one="$1" three="$3"
|
||||
shift; shift; shift
|
||||
set -- "${one}/$(_netmask2cidr "${three}")" "$@"
|
||||
fi
|
||||
|
||||
# tunnel keyword is 'peer' in iproute2, but 'pointopoint' in ifconfig.
|
||||
if [ "$2" = "pointopoint" ]; then
|
||||
local one="$1"
|
||||
shift; shift
|
||||
set -- "${one}" "peer" "$@"
|
||||
fi
|
||||
local address netmask broadcast peer anycast label scope
|
||||
local valid_lft preferred_lft home nodad
|
||||
address="$1" ; shift
|
||||
while [ -n "$*" ]; do
|
||||
case "$1" in
|
||||
netmask)
|
||||
netmask="/$(_netmask2cidr "$2")" ; shift ; shift ;;
|
||||
broadcast|brd)
|
||||
broadcast="broadcast $2" ; shift ; shift ;;
|
||||
pointopoint|pointtopoint|peer)
|
||||
peer="peer $2" ; shift ; shift ;;
|
||||
anycast|label|scope|valid_lft|preferred_lft)
|
||||
eval "$1=$2" ; shift ; shift ;;
|
||||
home|nodad)
|
||||
eval "$1=$1" ; shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Always scope lo addresses as host unless specified otherwise
|
||||
if [ "${IFACE}" = "lo" ]; then
|
||||
set -- "$@" "scope" "host"
|
||||
[ -z "$scope" ] && scope="scope host"
|
||||
fi
|
||||
|
||||
# IPv4 specifics
|
||||
case "$1" in
|
||||
*.*.*.*)
|
||||
case "$@" in
|
||||
*" brd "*);;
|
||||
*" broadcast "*);;
|
||||
*) set -- "$@" brd +;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
veinfo ip addr add "$@" dev "${IFACE}"
|
||||
ip addr add "$@" dev "${IFACE}"
|
||||
set -- "${address}${netmask}" $peer $broadcast $anycast $label $scope dev "${IFACE}" $valid_lft $preferred_lft $home $nodad
|
||||
veinfo ip addr add "$@"
|
||||
ip addr add "$@"
|
||||
}
|
||||
|
||||
_add_route()
|
||||
|
||||
@@ -38,7 +38,8 @@ yesno()
|
||||
esac
|
||||
}
|
||||
|
||||
rc_runlevel() {
|
||||
rc_runlevel()
|
||||
{
|
||||
rc-status --runlevel
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ stop_addon()
|
||||
}
|
||||
|
||||
net_fs_list="afs cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre
|
||||
ncpfs nfs nfs4 ocfs2 shfs smbfs $extra_net_fs_list"
|
||||
ncpfs nfs nfs4 ocfs2 shfs smbfs"
|
||||
is_net_fs()
|
||||
{
|
||||
[ -z "$1" ] && return 1
|
||||
@@ -50,7 +50,7 @@ is_net_fs()
|
||||
|
||||
# Fall back on fs types
|
||||
local t=$(mountinfo --fstype "$1")
|
||||
for x in $net_fs_list; do
|
||||
for x in $net_fs_list $extra_net_fs_list; do
|
||||
[ "$x" = "$t" ] && return 0
|
||||
done
|
||||
return 1
|
||||
|
||||
@@ -16,6 +16,23 @@ sourcex()
|
||||
fi
|
||||
}
|
||||
|
||||
loadconfig()
|
||||
{
|
||||
# If we're net.eth0 or openvpn.work then load net or openvpn config
|
||||
_c=${RC_SVCNAME%%.*}
|
||||
if [ -n "$_c" -a "$_c" != "$RC_SVCNAME" ]; then
|
||||
if ! sourcex -e "$1/$_c.$RC_RUNLEVEL"; then
|
||||
sourcex -e "$1/$_c"
|
||||
fi
|
||||
fi
|
||||
unset _c
|
||||
|
||||
# Overlay with our specific config
|
||||
if ! sourcex -e "$1/$RC_SVCNAME.$RC_RUNLEVEL"; then
|
||||
sourcex -e "$1/$RC_SVCNAME"
|
||||
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."
|
||||
@@ -165,21 +182,9 @@ status()
|
||||
|
||||
yesno $RC_DEBUG && set -x
|
||||
|
||||
_conf_d=${RC_SERVICE%/*}/../conf.d
|
||||
# If we're net.eth0 or openvpn.work then load net or openvpn config
|
||||
_c=${RC_SVCNAME%%.*}
|
||||
if [ -n "$_c" -a "$_c" != "$RC_SVCNAME" ]; then
|
||||
if ! sourcex -e "$_conf_d/$_c.$RC_RUNLEVEL"; then
|
||||
sourcex -e "$_conf_d/$_c"
|
||||
fi
|
||||
if ! loadconfig "${RC_SERVICE%/*}/../conf.d"; then
|
||||
loadconfig "@SYSCONFDIR@/conf.d"
|
||||
fi
|
||||
unset _c
|
||||
|
||||
# Overlay with our specific config
|
||||
if ! sourcex -e "$_conf_d/$RC_SVCNAME.$RC_RUNLEVEL"; then
|
||||
sourcex -e "$_conf_d/$RC_SVCNAME"
|
||||
fi
|
||||
unset _conf_d
|
||||
|
||||
# Load any system overrides
|
||||
sourcex -e "@SYSCONFDIR@/rc.conf"
|
||||
@@ -206,6 +211,12 @@ for _f in $required_files; do
|
||||
done
|
||||
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."
|
||||
fi
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
# Sepcial case depend
|
||||
if [ "$1" = depend ]; then
|
||||
|
||||
@@ -30,7 +30,7 @@ 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"
|
||||
@@ -64,7 +64,7 @@ update_interface()
|
||||
update_routes()
|
||||
{
|
||||
peer_var "${PEER_ROUTERS}" && return
|
||||
|
||||
|
||||
if [ -n "${router}" ] ; then
|
||||
metric=
|
||||
[ -n "${IF_METRIC}" ] && metric="metric ${IF_METRIC}"
|
||||
|
||||
@@ -725,7 +725,7 @@ ewarn(const char *EINFO_RESTRICT fmt, ...)
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
if (!fmt || is_quiet())
|
||||
if (!fmt)
|
||||
return 0;
|
||||
va_start(ap, fmt);
|
||||
elogv(LOG_WARNING, fmt, ap);
|
||||
|
||||
@@ -54,6 +54,54 @@ rc_yesno(const char *value)
|
||||
}
|
||||
librc_hidden_def(rc_yesno)
|
||||
|
||||
|
||||
/**
|
||||
* Read the entire @file into the buffer and set @len to the
|
||||
* size of the buffer when finished. For C strings, this will
|
||||
* be strlen(buffer) + 1.
|
||||
* Don't forget to free the buffer afterwards!
|
||||
*/
|
||||
bool
|
||||
rc_getfile(const char *file, char **buffer, size_t *len)
|
||||
{
|
||||
bool ret = false;
|
||||
FILE *fp;
|
||||
int fd;
|
||||
struct stat st;
|
||||
size_t done, left;
|
||||
|
||||
fp = fopen(file, "re");
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
/* assume fileno() never fails */
|
||||
fd = fileno(fp);
|
||||
|
||||
if (fstat(fd, &st))
|
||||
goto finished;
|
||||
|
||||
left = st.st_size;
|
||||
*len = left + 1; /* NUL terminator */
|
||||
*buffer = xrealloc(*buffer, *len);
|
||||
while (left) {
|
||||
done = fread(*buffer, sizeof(*buffer[0]), left, fp);
|
||||
if (done == 0 && ferror(fp))
|
||||
goto finished;
|
||||
left -= done;
|
||||
}
|
||||
ret = true;
|
||||
|
||||
finished:
|
||||
if (!ret) {
|
||||
free(*buffer);
|
||||
*len = 0;
|
||||
} else
|
||||
(*buffer)[*len - 1] = '\0';
|
||||
fclose(fp);
|
||||
return ret;
|
||||
}
|
||||
librc_hidden_def(rc_getfile)
|
||||
|
||||
ssize_t
|
||||
rc_getline(char **line, size_t *len, FILE *fp)
|
||||
{
|
||||
@@ -173,10 +221,8 @@ rc_config_load(const char *file)
|
||||
/* In shells the last item takes precedence, so we need to remove
|
||||
any prior values we may already have */
|
||||
TAILQ_FOREACH(cline, config, entries) {
|
||||
p = strchr(cline->value, '=');
|
||||
if (p && strncmp(entry, cline->value,
|
||||
(size_t)(p - cline->value)) == 0)
|
||||
{
|
||||
i = strlen(entry);
|
||||
if (strncmp(entry, cline->value, i) == 0 && cline->value[i] == '=') {
|
||||
/* We have a match now - to save time we directly replace it */
|
||||
free(cline->value);
|
||||
cline->value = newline;
|
||||
@@ -202,15 +248,13 @@ rc_config_value(RC_STRINGLIST *list, const char *entry)
|
||||
{
|
||||
RC_STRING *line;
|
||||
char *p;
|
||||
size_t len, dif;
|
||||
size_t len;
|
||||
|
||||
len = strlen(entry);
|
||||
TAILQ_FOREACH(line, list, entries) {
|
||||
p = strchr(line->value, '=');
|
||||
if (p != NULL) {
|
||||
dif = (p - line->value);
|
||||
if (dif == len &&
|
||||
strncmp(entry, line->value, dif) == 0)
|
||||
if (strncmp(entry, line->value, len) == 0 && line->value[len] == '=')
|
||||
return ++p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,19 +767,15 @@ librc_hidden_def(rc_service_state)
|
||||
char *
|
||||
rc_service_value_get(const char *service, const char *option)
|
||||
{
|
||||
FILE *fp;
|
||||
char *line = NULL;
|
||||
char *buffer = NULL;
|
||||
size_t len = 0;
|
||||
char file[PATH_MAX];
|
||||
|
||||
snprintf(file, sizeof(file), RC_SVCDIR "/options/%s/%s",
|
||||
service, option);
|
||||
if ((fp = fopen(file, "r"))) {
|
||||
rc_getline(&line, &len, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
rc_getfile(file, &buffer, &len);
|
||||
|
||||
return line;
|
||||
return buffer;
|
||||
}
|
||||
librc_hidden_def(rc_service_value_get)
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ librc_hidden_proto(rc_deptree_order)
|
||||
librc_hidden_proto(rc_deptree_update)
|
||||
librc_hidden_proto(rc_deptree_update_needed)
|
||||
librc_hidden_proto(rc_find_pids)
|
||||
librc_hidden_proto(rc_getfile)
|
||||
librc_hidden_proto(rc_getline)
|
||||
librc_hidden_proto(rc_newer_than)
|
||||
librc_hidden_proto(rc_older_than)
|
||||
|
||||
@@ -544,6 +544,9 @@ typedef LIST_HEAD(rc_pidlist, rc_pid) RC_PIDLIST;
|
||||
* @return NULL terminated list of pids */
|
||||
RC_PIDLIST *rc_find_pids(const char *, const char *const *, uid_t, pid_t);
|
||||
|
||||
/* Basically the same as rc_getline() below, it just returns multiple lines */
|
||||
bool rc_getfile(const char *, char **, size_t *);
|
||||
|
||||
/* getline is a handy glibc function that not all libcs have, so
|
||||
* we have our own */
|
||||
ssize_t rc_getline(char **, size_t *, FILE *);
|
||||
|
||||
@@ -14,6 +14,7 @@ global:
|
||||
rc_deptree_update_needed;
|
||||
rc_environ_fd;
|
||||
rc_find_pids;
|
||||
rc_getfile;
|
||||
rc_getline;
|
||||
rc_newer_than;
|
||||
rc_older_than;
|
||||
|
||||
@@ -57,10 +57,8 @@
|
||||
#include "rc.h"
|
||||
#include "rc-misc.h"
|
||||
|
||||
#define LOGFILE RC_SVCDIR "/rc.log"
|
||||
#define PERMLOG "/var/log/rc.log"
|
||||
#define MOVELOG "cat " LOGFILE " 2>/dev/null >>" PERMLOG " && " \
|
||||
"rm -f " LOGFILE
|
||||
#define TMPLOG RC_SVCDIR "/rc.log"
|
||||
#define DEFAULTLOG "/var/log/rc.log"
|
||||
|
||||
static int signal_pipe[2] = { -1, -1 };
|
||||
static int fd_stdout = -1;
|
||||
@@ -149,12 +147,15 @@ rc_logger_open(const char *level)
|
||||
int slave_tty;
|
||||
struct termios tt;
|
||||
struct winsize ws;
|
||||
char *buffer;
|
||||
char buffer[BUFSIZ];
|
||||
struct pollfd fd[2];
|
||||
int s = 0;
|
||||
size_t bytes;
|
||||
int i;
|
||||
FILE *log = NULL;
|
||||
FILE *plog = NULL;
|
||||
const char *logfile;
|
||||
int log_error = 0;
|
||||
|
||||
if (!rc_conf_yesno("rc_logger"))
|
||||
return;
|
||||
@@ -192,7 +193,7 @@ rc_logger_open(const char *level)
|
||||
signal_pipe[1] = -1;
|
||||
|
||||
runlevel = level;
|
||||
if ((log = fopen(LOGFILE, "a")))
|
||||
if ((log = fopen(TMPLOG, "ae")))
|
||||
write_time(log, "started");
|
||||
else {
|
||||
free(logbuf);
|
||||
@@ -201,7 +202,6 @@ rc_logger_open(const char *level)
|
||||
logbuf_len = 0;
|
||||
}
|
||||
|
||||
buffer = xmalloc(sizeof (char) * BUFSIZ);
|
||||
fd[0].fd = signal_pipe[0];
|
||||
fd[0].events = fd[1].events = POLLIN;
|
||||
fd[0].revents = fd[1].revents = 0;
|
||||
@@ -242,9 +242,8 @@ rc_logger_open(const char *level)
|
||||
if (fd[0].revents & (POLLIN | POLLHUP))
|
||||
break;
|
||||
}
|
||||
free(buffer);
|
||||
if (logbuf) {
|
||||
if ((log = fopen(LOGFILE, "a"))) {
|
||||
if ((log = fopen(TMPLOG, "ae"))) {
|
||||
write_time(log, "started");
|
||||
write_log(fileno(log), logbuf, logbuf_len);
|
||||
}
|
||||
@@ -255,10 +254,39 @@ rc_logger_open(const char *level)
|
||||
fclose(log);
|
||||
}
|
||||
|
||||
/* Try and cat our new logfile to a more permament location
|
||||
and then punt it */
|
||||
if (system(MOVELOG) == -1)
|
||||
eerror("system: %s: %s", MOVELOG, strerror(errno));
|
||||
/* Append the temporary log to the real log */
|
||||
logfile = rc_conf_value("rc_log_path");
|
||||
if (logfile == NULL)
|
||||
logfile = DEFAULTLOG;
|
||||
|
||||
if ((plog = fopen(logfile, "ae"))) {
|
||||
if ((log = fopen(TMPLOG, "re"))) {
|
||||
while ((bytes = fread(buffer, sizeof(*buffer), BUFSIZ, log)) > 0) {
|
||||
if (fwrite(buffer, sizeof(*buffer), bytes, plog) < bytes) {
|
||||
log_error = 1;
|
||||
eerror("Error: write(%s) failed: %s", logfile, strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log_error = 1;
|
||||
eerror("Error: fopen(%s) failed: %s", TMPLOG, strerror(errno));
|
||||
}
|
||||
|
||||
fclose(log);
|
||||
fclose(plog);
|
||||
} else {
|
||||
log_error = 1;
|
||||
eerror("Error: fopen(%s) failed: %s", logfile, strerror(errno));
|
||||
}
|
||||
|
||||
/* Try to keep the temporary log in case of errors */
|
||||
if (!log_error) {
|
||||
if (unlink(TMPLOG) == -1)
|
||||
eerror("Error: unlink(%s) failed: %s", TMPLOG, strerror(errno));
|
||||
} else if (exists(TMPLOG))
|
||||
eerrorx("Warning: temporary logfile left behind: %s", TMPLOG);
|
||||
|
||||
exit(0);
|
||||
/* NOTREACHED */
|
||||
|
||||
|
||||
@@ -1100,7 +1100,7 @@ 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, *save2 = NULL;
|
||||
char *save = NULL;
|
||||
char pidstr[10];
|
||||
size_t l = 0, ll;
|
||||
const char *file;
|
||||
@@ -1120,40 +1120,7 @@ runscript(int argc, char **argv)
|
||||
|
||||
atexit(cleanup);
|
||||
|
||||
/* We need to work out the real full path to our service.
|
||||
* This works fine, provided that we ONLY allow multiplexed services
|
||||
* to exist in the same directory as the master link.
|
||||
* Also, the master link as to be a real file in the init dir. */
|
||||
if (!realpath(argv[1], path)) {
|
||||
fprintf(stderr, "realpath: %s\n", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
memset(lnk, 0, sizeof(lnk));
|
||||
if (readlink(argv[1], lnk, sizeof(lnk)-1)) {
|
||||
dir = dirname(path);
|
||||
if (strchr(lnk, '/')) {
|
||||
save = xstrdup(dir);
|
||||
save2 = xstrdup(lnk);
|
||||
dir = dirname(save2);
|
||||
if (strcmp(dir, save) == 0)
|
||||
file = basename_c(argv[1]);
|
||||
else
|
||||
file = basename_c(lnk);
|
||||
dir = save;
|
||||
} else
|
||||
file = basename_c(argv[1]);
|
||||
ll = strlen(dir) + strlen(file) + 2;
|
||||
service = xmalloc(ll);
|
||||
snprintf(service, ll, "%s/%s", dir, file);
|
||||
if (stat(service, &stbuf) != 0) {
|
||||
free(service);
|
||||
service = xstrdup(lnk);
|
||||
}
|
||||
free(save);
|
||||
free(save2);
|
||||
}
|
||||
if (!service)
|
||||
service = xstrdup(path);
|
||||
service = xstrdup(argv[1]);
|
||||
applet = basename_c(service);
|
||||
|
||||
if (argc < 3)
|
||||
@@ -1333,12 +1300,6 @@ runscript(int argc, char **argv)
|
||||
prefix = NULL;
|
||||
retval = svc_exec("status", NULL);
|
||||
} else {
|
||||
if (strcmp(optarg, "pause") == 0) {
|
||||
ewarn("WARNING: 'pause' is deprecated; please use '--nodeps stop'");
|
||||
deps = false;
|
||||
optarg = "stop";
|
||||
}
|
||||
|
||||
if (strcmp(optarg, "conditionalrestart") == 0 ||
|
||||
strcmp(optarg, "condrestart") == 0)
|
||||
{
|
||||
@@ -1349,7 +1310,11 @@ runscript(int argc, char **argv)
|
||||
svc_restart();
|
||||
} else if (strcmp(optarg, "start") == 0) {
|
||||
svc_start();
|
||||
} else if (strcmp(optarg, "stop") == 0) {
|
||||
} else if (strcmp(optarg, "stop") == 0 || strcmp(optarg, "pause") == 0) {
|
||||
if (strcmp(optarg, "pause") == 0) {
|
||||
ewarn("WARNING: 'pause' is deprecated; please use '--nodeps stop'");
|
||||
deps = false;
|
||||
}
|
||||
if (deps && in_background)
|
||||
get_started_services();
|
||||
svc_stop();
|
||||
|
||||
@@ -24,6 +24,8 @@ rc_deptree_update_needed
|
||||
rc_deptree_update_needed@@RC_1.0
|
||||
rc_find_pids
|
||||
rc_find_pids@@RC_1.0
|
||||
rc_getfile
|
||||
rc_getfile@@RC_1.0
|
||||
rc_getline
|
||||
rc_getline@@RC_1.0
|
||||
rc_newer_than
|
||||
|
||||
Reference in New Issue
Block a user