SVCNAME -> RC_SVCNAME, but export SVCNAME still for compat.
This commit is contained in:
parent
6d2e1f7add
commit
6159a32f39
@ -2,7 +2,7 @@
|
|||||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||||
# All rights reserved. Released under the 2-clause BSD license.
|
# All rights reserved. Released under the 2-clause BSD license.
|
||||||
|
|
||||||
mouse=${SVCNAME##*.}
|
mouse=${RC_SVCNAME##*.}
|
||||||
if [ -n "${name}" -a "${mouse}" != "moused" ]; then
|
if [ -n "${name}" -a "${mouse}" != "moused" ]; then
|
||||||
moused_device=/dev/"${mouse}"
|
moused_device=/dev/"${mouse}"
|
||||||
pidfile=/var/run/moused-"${mouse}".pid
|
pidfile=/var/run/moused-"${mouse}".pid
|
||||||
|
@ -18,7 +18,7 @@ depend()
|
|||||||
|
|
||||||
reload()
|
reload()
|
||||||
{
|
{
|
||||||
ebegin "Reloading ${SVCNAME}"
|
ebegin "Reloading ${RC_SVCNAME}"
|
||||||
start-stop-daemon --signal SIGHUP --pidfile "${pidfile}"
|
start-stop-daemon --signal SIGHUP --pidfile "${pidfile}"
|
||||||
eend $?
|
eend $?
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
||||||
# All rights reserved. Released under the 2-clause BSD license.
|
# All rights reserved. Released under the 2-clause BSD license.
|
||||||
|
|
||||||
vpn=${SVCNAME#*.}
|
vpn=${RC_SVCNAME#*.}
|
||||||
name="OpenVPN"
|
name="OpenVPN"
|
||||||
[ "${vpn}" != "openvpn" ] && name="${name} (${vpn})"
|
[ "${vpn}" != "openvpn" ] && name="${name} (${vpn})"
|
||||||
command=@PKG_PREFIX@/sbin/openvpn
|
command=@PKG_PREFIX@/sbin/openvpn
|
||||||
|
|
||||||
pidfile=@VARBASE@/run/"${SVCNAME}".pid
|
pidfile=@VARBASE@/run/"${RC_SVCNAME}".pid
|
||||||
openvpn_dir=${openvpn_dir:-@PKG_PREFIX@/etc/openvpn}
|
openvpn_dir=${openvpn_dir:-@PKG_PREFIX@/etc/openvpn}
|
||||||
openvpn_config=${openvpn_config:-${openvpn_dir}/${vpn}.conf}
|
openvpn_config=${openvpn_config:-${openvpn_dir}/${vpn}.conf}
|
||||||
command_args="${openvpn_args} --daemon --config ${openvpn_config} --writepid ${pidfile}"
|
command_args="${openvpn_args} --daemon --config ${openvpn_config} --writepid ${pidfile}"
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd Feb 22, 2008
|
.Dd Mar 19, 2008
|
||||||
.Dt RUNSCRIPT 8 SMM
|
.Dt RUNSCRIPT 8 SMM
|
||||||
.Os OpenRC
|
.Os OpenRC
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -276,7 +276,7 @@ matches YES, TRUE, ON or 1 regardless of case then we return 0, otherwise 1.
|
|||||||
.Nm
|
.Nm
|
||||||
sets the following environment variables for use in the service scripts:
|
sets the following environment variables for use in the service scripts:
|
||||||
.Bl -tag -width "RC_DEFAULTLEVEL"
|
.Bl -tag -width "RC_DEFAULTLEVEL"
|
||||||
.It Va SVCNAME
|
.It Va RC_SVCNAME
|
||||||
Name of the service.
|
Name of the service.
|
||||||
.It Va RC_RUNLEVEL
|
.It Va RC_RUNLEVEL
|
||||||
Current runlevel that rc is in.
|
Current runlevel that rc is in.
|
||||||
@ -295,11 +295,11 @@ The result of `uname -s`.
|
|||||||
Configuration files, relative to the location of the service.
|
Configuration files, relative to the location of the service.
|
||||||
If a file ending with .${RC_RUNLEVEL} exists then we use that instead.
|
If a file ending with .${RC_RUNLEVEL} exists then we use that instead.
|
||||||
.Bl -ohang
|
.Bl -ohang
|
||||||
.It Pa ../conf.d/${SVCNAME%%.*}
|
.It Pa ../conf.d/${RC_SVCNAME%%.*}
|
||||||
mulitplexed configuration file.
|
mulitplexed configuration file.
|
||||||
Example: if ${SVCNAME} is net.eth1 then look for
|
Example: if ${RC_SVCNAME} is net.eth1 then look for
|
||||||
.Pa ../conf.d/net .
|
.Pa ../conf.d/net .
|
||||||
.It Pa ../conf.d/${SVCNAME}
|
.It Pa ../conf.d/${RC_SVCNAME}
|
||||||
service configuration file.
|
service configuration file.
|
||||||
.It Pa /etc/rc.conf
|
.It Pa /etc/rc.conf
|
||||||
host configuration file.
|
host configuration file.
|
||||||
|
@ -10,7 +10,7 @@ _config_vars="$_config_vars tunctl"
|
|||||||
|
|
||||||
_is_tuntap()
|
_is_tuntap()
|
||||||
{
|
{
|
||||||
[ -n "$(export SVCNAME="net.${IFACE}"; service_get_value tuntap)" ]
|
[ -n "$(export RC_SVCNAME="net.${IFACE}"; service_get_value tuntap)" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
tuntap_pre_start()
|
tuntap_pre_start()
|
||||||
|
@ -91,7 +91,7 @@ vlan_post_start()
|
|||||||
/proc/net/vlan/config )"
|
/proc/net/vlan/config )"
|
||||||
mark_service_started "net.${ifname}"
|
mark_service_started "net.${ifname}"
|
||||||
(
|
(
|
||||||
export SVCNAME="net.${ifname}"
|
export RC_SVCNAME="net.${ifname}"
|
||||||
start
|
start
|
||||||
) || mark_service_stopped "net.${ifname}"
|
) || mark_service_stopped "net.${ifname}"
|
||||||
done
|
done
|
||||||
@ -106,7 +106,7 @@ vlan_post_stop()
|
|||||||
for vlan in $(_get_vlans); do
|
for vlan in $(_get_vlans); do
|
||||||
einfo "Removing VLAN ${vlan##*.} from ${IFACE}"
|
einfo "Removing VLAN ${vlan##*.} from ${IFACE}"
|
||||||
(
|
(
|
||||||
export SVCNAME="net.${vlan}"
|
export RC_SVCNAME="net.${vlan}"
|
||||||
stop
|
stop
|
||||||
) && {
|
) && {
|
||||||
mark_service_stopped "net.${vlan}"
|
mark_service_stopped "net.${vlan}"
|
||||||
|
@ -66,7 +66,7 @@ wpa_supplicant_pre_start()
|
|||||||
# the background unless we're not currently running
|
# the background unless we're not currently running
|
||||||
if yesno ${IN_BACKGROUND}; then
|
if yesno ${IN_BACKGROUND}; then
|
||||||
if ${wireless} && \
|
if ${wireless} && \
|
||||||
service_started_daemon "${SVCNAME}" "${wpas}"; then
|
service_started_daemon "${RC_SVCNAME}" "${wpas}"; then
|
||||||
SSID=$(_get_ssid "${IFACE}")
|
SSID=$(_get_ssid "${IFACE}")
|
||||||
SSIDVAR=$(shell_var "${SSID}")
|
SSIDVAR=$(shell_var "${SSID}")
|
||||||
service_set_value "SSID" "${SSID}"
|
service_set_value "SSID" "${SSID}"
|
||||||
@ -177,7 +177,7 @@ wpa_supplicant_post_stop()
|
|||||||
|
|
||||||
if yesno "${IN_BACKGROUND}"; then
|
if yesno "${IN_BACKGROUND}"; then
|
||||||
# Only stop wpa_supplicant if it's not the controlling daemon
|
# Only stop wpa_supplicant if it's not the controlling daemon
|
||||||
! service_started_daemon "${SVCNAME}" "${wpas}" 1
|
! service_started_daemon "${RC_SVCNAME}" "${wpas}" 1
|
||||||
fi
|
fi
|
||||||
[ $? != 0 ] && return 0
|
[ $? != 0 ] && return 0
|
||||||
|
|
||||||
|
@ -7,25 +7,25 @@
|
|||||||
. @PREFIX@/@SYSCONFDIR@/init.d/functions.sh
|
. @PREFIX@/@SYSCONFDIR@/init.d/functions.sh
|
||||||
|
|
||||||
config() {
|
config() {
|
||||||
[ -n "$*" ] && echo "${SVCNAME} config $*" >&3
|
[ -n "$*" ] && echo "${RC_SVCNAME} config $*" >&3
|
||||||
}
|
}
|
||||||
need() {
|
need() {
|
||||||
[ -n "$*" ] && echo "${SVCNAME} ineed $*" >&3
|
[ -n "$*" ] && echo "${RC_SVCNAME} ineed $*" >&3
|
||||||
}
|
}
|
||||||
use() {
|
use() {
|
||||||
[ -n "$*" ] && echo "${SVCNAME} iuse $*" >&3
|
[ -n "$*" ] && echo "${RC_SVCNAME} iuse $*" >&3
|
||||||
}
|
}
|
||||||
before() {
|
before() {
|
||||||
[ -n "$*" ] && echo "${SVCNAME} ibefore $*" >&3
|
[ -n "$*" ] && echo "${RC_SVCNAME} ibefore $*" >&3
|
||||||
}
|
}
|
||||||
after() {
|
after() {
|
||||||
[ -n "$*" ] && echo "${SVCNAME} iafter $*" >&3
|
[ -n "$*" ] && echo "${RC_SVCNAME} iafter $*" >&3
|
||||||
}
|
}
|
||||||
provide() {
|
provide() {
|
||||||
[ -n "$*" ] && echo "${SVCNAME} iprovide $*" >&3
|
[ -n "$*" ] && echo "${RC_SVCNAME} iprovide $*" >&3
|
||||||
}
|
}
|
||||||
keyword() {
|
keyword() {
|
||||||
[ -n "$*" ] && echo "${SVCNAME} keyword $*" >&3
|
[ -n "$*" ] && echo "${RC_SVCNAME} keyword $*" >&3
|
||||||
}
|
}
|
||||||
depend() {
|
depend() {
|
||||||
:
|
:
|
||||||
@ -47,35 +47,39 @@ do
|
|||||||
_done_dirs="${_done_dirs} ${_dir}"
|
_done_dirs="${_done_dirs} ${_dir}"
|
||||||
|
|
||||||
cd "${_dir}"
|
cd "${_dir}"
|
||||||
for SVCNAME in *; do
|
for RC_SERVICE in *; do
|
||||||
[ -x "${SVCNAME}" ] || continue
|
[ -x "${RC_SERVICE}" ] || continue
|
||||||
|
|
||||||
# Only generate dependencies for runscripts
|
# Only generate dependencies for runscripts
|
||||||
read one two < "${SVCNAME}"
|
read one two < "${RC_SERVICE}"
|
||||||
[ "${one}" = "#!@PREFIX@/sbin/runscript" ] || continue
|
[ "${one}" = "#!@PREFIX@/sbin/runscript" ] || continue
|
||||||
unset one two
|
unset one two
|
||||||
|
|
||||||
export SVCNAME=${SVCNAME##*/}
|
export RC_SVCNAME=${RC_SERVICE##*/}
|
||||||
|
|
||||||
|
# Compat
|
||||||
|
export SVCNAME=${RC_SVCNAME}
|
||||||
|
|
||||||
(
|
(
|
||||||
# Save stdout in fd3, then remap it to stderr
|
# Save stdout in fd3, then remap it to stderr
|
||||||
exec 3>&1 1>&2
|
exec 3>&1 1>&2
|
||||||
|
|
||||||
_rc_c=${SVCNAME%%.*}
|
_rc_c=${RC_SVCNAME%%.*}
|
||||||
if [ -n "${_rc_c}" -a "${_rc_c}" != "${SVCNAME}" ]; then
|
if [ -n "${_rc_c}" -a "${_rc_c}" != "${RC_SVCNAME}" ]; then
|
||||||
if [ -e "${_dir}/../conf.d/${_rc_c}" ]; then
|
if [ -e "${_dir}/../conf.d/${_rc_c}" ]; then
|
||||||
. "${_dir}/../conf.d/${_rc_c}"
|
. "${_dir}/../conf.d/${_rc_c}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
unset _rc_c
|
unset _rc_c
|
||||||
|
|
||||||
if [ -e "${_dir}/../conf.d/${SVCNAME}" ]; then
|
if [ -e "${_dir}/../conf.d/${RC_SVCNAME}" ]; then
|
||||||
. "${_dir}/../conf.d/${SVCNAME}"
|
. "${_dir}/../conf.d/${RC_SVCNAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -e @PREFIX@/@SYSCONFDIR@/rc.conf ] && . @PREFIX@/@SYSCONFDIR@/rc.conf
|
[ -e @PREFIX@/@SYSCONFDIR@/rc.conf ] && . @PREFIX@/@SYSCONFDIR@/rc.conf
|
||||||
|
|
||||||
if . "${_dir}/${SVCNAME}"; then
|
if . "${_dir}/${RC_SVCNAME}"; then
|
||||||
echo "${SVCNAME}" >&3
|
echo "${RC_SVCNAME}" >&3
|
||||||
depend
|
depend
|
||||||
|
|
||||||
# Add any user defined depends
|
# Add any user defined depends
|
||||||
@ -85,9 +89,9 @@ do
|
|||||||
IFS=:
|
IFS=:
|
||||||
set -- ${_deptype}
|
set -- ${_deptype}
|
||||||
unset IFS
|
unset IFS
|
||||||
eval _depends=\$rc_$(shell_var "${SVCNAME}")_$1
|
eval _depends=\$rc_$(shell_var "${RC_SVCNAME}")_$1
|
||||||
[ -z "${_depends}" ] && eval _depends=\$rc_$1
|
[ -z "${_depends}" ] && eval _depends=\$rc_$1
|
||||||
[ -z "${_depends}" ] && eval _depends=\$RC_$(shell_var "${SVCNAME}")_$2
|
[ -z "${_depends}" ] && eval _depends=\$RC_$(shell_var "${RC_SVCNAME}")_$2
|
||||||
[ -z "${_depends}" ] && eval _depends=\$RC_$2
|
[ -z "${_depends}" ] && eval _depends=\$RC_$2
|
||||||
|
|
||||||
$1 ${_depends}
|
$1 ${_depends}
|
||||||
|
10
sh/net.sh.in
10
sh/net.sh.in
@ -15,7 +15,7 @@ __IFS="
|
|||||||
"
|
"
|
||||||
depend()
|
depend()
|
||||||
{
|
{
|
||||||
local IFACE=${SVCNAME#*.}
|
local IFACE=${RC_SVCNAME#*.}
|
||||||
local IFVAR=$(shell_var "${IFACE}")
|
local IFVAR=$(shell_var "${IFACE}")
|
||||||
|
|
||||||
need localmount
|
need localmount
|
||||||
@ -335,7 +335,7 @@ _load_modules()
|
|||||||
|
|
||||||
# Now load and wrap our functions
|
# Now load and wrap our functions
|
||||||
if ! . "${MODULESDIR}/${mod}.sh"; then
|
if ! . "${MODULESDIR}/${mod}.sh"; then
|
||||||
eend 1 "${SVCNAME}: error loading module \`${mod}'"
|
eend 1 "${RC_SVCNAME}: error loading module \`${mod}'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ _load_config()
|
|||||||
|
|
||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
local IFACE=${SVCNAME#*.} oneworked=false module=
|
local IFACE=${RC_SVCNAME#*.} oneworked=false module=
|
||||||
local IFVAR=$(shell_var "${IFACE}") cmd= our_metric=
|
local IFVAR=$(shell_var "${IFACE}") cmd= our_metric=
|
||||||
local metric=0
|
local metric=0
|
||||||
|
|
||||||
@ -487,7 +487,7 @@ start()
|
|||||||
if ! _wait_for_carrier; then
|
if ! _wait_for_carrier; then
|
||||||
if service_started devd; then
|
if service_started devd; then
|
||||||
ewarn "no carrier, but devd will start us when we have one"
|
ewarn "no carrier, but devd will start us when we have one"
|
||||||
mark_service_inactive "${SVCNAME}"
|
mark_service_inactive "${RC_SVCNAME}"
|
||||||
else
|
else
|
||||||
eerror "no carrier"
|
eerror "no carrier"
|
||||||
fi
|
fi
|
||||||
@ -617,7 +617,7 @@ ${routes}"
|
|||||||
|
|
||||||
stop()
|
stop()
|
||||||
{
|
{
|
||||||
local IFACE=${SVCNAME#*.} module=
|
local IFACE=${RC_SVCNAME#*.} module=
|
||||||
local IFVAR=$(shell_var "${IFACE}") opts=
|
local IFVAR=$(shell_var "${IFACE}") opts=
|
||||||
|
|
||||||
einfo "Bringing down interface ${IFACE}"
|
einfo "Bringing down interface ${IFACE}"
|
||||||
|
@ -14,20 +14,23 @@ if [ -r /sbin/livecd-functions.sh ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$1" -o -z "$2" ]; then
|
if [ -z "$1" -o -z "$2" ]; then
|
||||||
eerror "${SVCNAME}: not enough arguments"
|
eerror "${RC_SVCNAME}: not enough arguments"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# So daemons know where to recall us if needed
|
# So daemons know where to recall us if needed
|
||||||
export RC_SERVICE="$1"
|
export RC_SERVICE="$1"
|
||||||
|
|
||||||
|
# Compat
|
||||||
|
export SVCNAME=${RC_SVCNAME}
|
||||||
|
|
||||||
# Descript the init script to the user
|
# Descript the init script to the user
|
||||||
describe()
|
describe()
|
||||||
{
|
{
|
||||||
if [ -n "${description}" ]; then
|
if [ -n "${description}" ]; then
|
||||||
einfo "${description}"
|
einfo "${description}"
|
||||||
else
|
else
|
||||||
ewarn "No description for ${SVCNAME}"
|
ewarn "No description for ${RC_SVCNAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local svc= desc=
|
local svc= desc=
|
||||||
@ -45,8 +48,8 @@ yesno ${RC_DEBUG} && set -x
|
|||||||
|
|
||||||
_conf_d=${1%/*}/../conf.d
|
_conf_d=${1%/*}/../conf.d
|
||||||
# If we're net.eth0 or openvpn.work then load net or openvpn config
|
# If we're net.eth0 or openvpn.work then load net or openvpn config
|
||||||
_c=${SVCNAME%%.*}
|
_c=${RC_SVCNAME%%.*}
|
||||||
if [ -n "${_c}" -a "${_c}" != "${SVCNAME}" ]; then
|
if [ -n "${_c}" -a "${_c}" != "${RC_SVCNAME}" ]; then
|
||||||
if [ -e "${_conf_d}/${_c}.${RC_RUNLEVEL}" ]; then
|
if [ -e "${_conf_d}/${_c}.${RC_RUNLEVEL}" ]; then
|
||||||
. "${_conf_d}/${_c}.${RC_RUNLEVEL}"
|
. "${_conf_d}/${_c}.${RC_RUNLEVEL}"
|
||||||
elif [ -e "${_conf_d}/${_c}" ]; then
|
elif [ -e "${_conf_d}/${_c}" ]; then
|
||||||
@ -56,10 +59,10 @@ fi
|
|||||||
unset _c
|
unset _c
|
||||||
|
|
||||||
# Overlay with our specific config
|
# Overlay with our specific config
|
||||||
if [ -e "${_conf_d}/${SVCNAME}.${RC_RUNLEVEL}" ]; then
|
if [ -e "${_conf_d}/${RC_SVCNAME}.${RC_RUNLEVEL}" ]; then
|
||||||
. "${_conf_d}/${SVCNAME}.${RC_RUNLEVEL}"
|
. "${_conf_d}/${RC_SVCNAME}.${RC_RUNLEVEL}"
|
||||||
elif [ -e "${_conf_d}/${SVCNAME}" ]; then
|
elif [ -e "${_conf_d}/${RC_SVCNAME}" ]; then
|
||||||
. "${_conf_d}/${SVCNAME}"
|
. "${_conf_d}/${RC_SVCNAME}"
|
||||||
fi
|
fi
|
||||||
unset _conf_d
|
unset _conf_d
|
||||||
|
|
||||||
@ -75,7 +78,7 @@ shift
|
|||||||
|
|
||||||
for _d in ${required_dirs}; do
|
for _d in ${required_dirs}; do
|
||||||
if [ ! -d ${_d} ]; then
|
if [ ! -d ${_d} ]; then
|
||||||
eerror "${SVCNAME}: \`${_d}' is not a directory"
|
eerror "${RC_SVCNAME}: \`${_d}' is not a directory"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -83,7 +86,7 @@ unset _d
|
|||||||
|
|
||||||
for _f in ${required_files}; do
|
for _f in ${required_files}; do
|
||||||
if [ ! -r ${_f} ]; then
|
if [ ! -r ${_f} ]; then
|
||||||
eerror "${SVCNAME}: \`${_f}' is not readable"
|
eerror "${RC_SVCNAME}: \`${_f}' is not readable"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -94,7 +97,7 @@ if [ -n "${command}" ]; then
|
|||||||
if ! type start >/dev/null 2>&1; then
|
if ! type start >/dev/null 2>&1; then
|
||||||
start() {
|
start() {
|
||||||
local _background=
|
local _background=
|
||||||
ebegin "Starting ${name:-${SVCNAME}}"
|
ebegin "Starting ${name:-${RC_SVCNAME}}"
|
||||||
if yesno "${command_background}"; then
|
if yesno "${command_background}"; then
|
||||||
_background="--background --pidfile"
|
_background="--background --pidfile"
|
||||||
fi
|
fi
|
||||||
@ -109,7 +112,7 @@ if [ -n "${command}" ]; then
|
|||||||
${pidfile:+--pidfile} ${pidfile} \
|
${pidfile:+--pidfile} ${pidfile} \
|
||||||
${_background} ${start_stop_daemon_args} \
|
${_background} ${start_stop_daemon_args} \
|
||||||
-- ${command_args}
|
-- ${command_args}
|
||||||
eend $? "Failed to start ${SVCNAME}" && return 0
|
eend $? "Failed to start ${RC_SVCNAME}" && return 0
|
||||||
if yesno "${start_inactive}"; then
|
if yesno "${start_inactive}"; then
|
||||||
if ! ${_inactive}; then
|
if ! ${_inactive}; then
|
||||||
mark_service_stopped
|
mark_service_stopped
|
||||||
@ -125,12 +128,12 @@ fi
|
|||||||
if [ -n "${command}" -o -n "${procname}" -o -n "${pidfile}" ]; then
|
if [ -n "${command}" -o -n "${procname}" -o -n "${pidfile}" ]; then
|
||||||
if ! type stop >/dev/null 2>&1; then
|
if ! type stop >/dev/null 2>&1; then
|
||||||
stop() {
|
stop() {
|
||||||
ebegin "Stopping ${name:-${SVCNAME}}"
|
ebegin "Stopping ${name:-${RC_SVCNAME}}"
|
||||||
start-stop-daemon --stop \
|
start-stop-daemon --stop \
|
||||||
${command:+--exec} ${command} \
|
${command:+--exec} ${command} \
|
||||||
${procname:+--name} ${procname} \
|
${procname:+--name} ${procname} \
|
||||||
${pidfile:+--pidfile} ${pidfile}
|
${pidfile:+--pidfile} ${pidfile}
|
||||||
eend $? "Failed to stop ${SVCNAME}"
|
eend $? "Failed to stop ${RC_SVCNAME}"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -159,7 +162,7 @@ while [ -n "$1" ]; do
|
|||||||
for _cmd in ${extra_started_commands}; do
|
for _cmd in ${extra_started_commands}; do
|
||||||
if [ "${_cmd}" = "$1" ]; then
|
if [ "${_cmd}" = "$1" ]; then
|
||||||
if ! service_started; then
|
if ! service_started; then
|
||||||
eerror "${SVCNAME}: cannot \`$1' as it has not been started"
|
eerror "${RC_SVCNAME}: cannot \`$1' as it has not been started"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -179,12 +182,12 @@ while [ -n "$1" ]; do
|
|||||||
shift
|
shift
|
||||||
continue 2
|
continue 2
|
||||||
else
|
else
|
||||||
eerror "${SVCNAME}: function \`$1' defined but does not exist"
|
eerror "${RC_SVCNAME}: function \`$1' defined but does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
eerror "${SVCNAME}: unknown function \`$1'"
|
eerror "${RC_SVCNAME}: unknown function \`$1'"
|
||||||
exit 1
|
exit 1
|
||||||
done
|
done
|
||||||
|
@ -207,7 +207,7 @@ static int do_service(int argc, char **argv)
|
|||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
service = argv[1];
|
service = argv[1];
|
||||||
else
|
else
|
||||||
service = getenv("SVCNAME");
|
service = getenv("RC_SVCNAME");
|
||||||
|
|
||||||
if (! service || *service == '\0')
|
if (! service || *service == '\0')
|
||||||
eerrorx("%s: no service specified", applet);
|
eerrorx("%s: no service specified", applet);
|
||||||
@ -229,7 +229,7 @@ static int do_service(int argc, char **argv)
|
|||||||
else if (strcmp(applet, "service_started_daemon") == 0) {
|
else if (strcmp(applet, "service_started_daemon") == 0) {
|
||||||
d[0] = argv[1];
|
d[0] = argv[1];
|
||||||
|
|
||||||
service = getenv("SVCNAME");
|
service = getenv("RC_SVCNAME");
|
||||||
if (argc > 3) {
|
if (argc > 3) {
|
||||||
service = argv[1];
|
service = argv[1];
|
||||||
d[0] = argv[2];
|
d[0] = argv[2];
|
||||||
@ -252,7 +252,7 @@ static int do_service(int argc, char **argv)
|
|||||||
static int do_mark_service(int argc, char **argv)
|
static int do_mark_service(int argc, char **argv)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
char *svcname = getenv("SVCNAME");
|
char *svcname = getenv("RC_SVCNAME");
|
||||||
char *service = NULL;
|
char *service = NULL;
|
||||||
char *runscript_pid;
|
char *runscript_pid;
|
||||||
char *mtime;
|
char *mtime;
|
||||||
@ -262,7 +262,7 @@ static int do_mark_service(int argc, char **argv)
|
|||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
service = argv[1];
|
service = argv[1];
|
||||||
else
|
else
|
||||||
service = getenv("SVCNAME");
|
service = getenv("RC_SVCNAME");
|
||||||
|
|
||||||
if (! service || *service == '\0')
|
if (! service || *service == '\0')
|
||||||
eerrorx("%s: no service specified", applet);
|
eerrorx("%s: no service specified", applet);
|
||||||
@ -311,7 +311,7 @@ static int do_mark_service(int argc, char **argv)
|
|||||||
static int do_value(int argc, char **argv)
|
static int do_value(int argc, char **argv)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
char *service = getenv("SVCNAME");
|
char *service = getenv("RC_SVCNAME");
|
||||||
char *option;
|
char *option;
|
||||||
|
|
||||||
if (! service)
|
if (! service)
|
||||||
|
@ -1129,7 +1129,7 @@ int runscript(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
setenv("EINFO_LOG", service, 1);
|
setenv("EINFO_LOG", service, 1);
|
||||||
setenv("SVCNAME", applet, 1);
|
setenv("RC_SVCNAME", applet, 1);
|
||||||
|
|
||||||
/* Set an env var so that we always know our pid regardless of any
|
/* Set an env var so that we always know our pid regardless of any
|
||||||
subshells the init script may create so that our mark_service_*
|
subshells the init script may create so that our mark_service_*
|
||||||
|
@ -583,7 +583,7 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
int stderr_fd;
|
int stderr_fd;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int i;
|
int i;
|
||||||
char *svcname = getenv("SVCNAME");
|
char *svcname = getenv("RC_SVCNAME");
|
||||||
RC_STRINGLIST *env_list;
|
RC_STRINGLIST *env_list;
|
||||||
RC_STRING *env;
|
RC_STRING *env;
|
||||||
char *path;
|
char *path;
|
||||||
@ -974,8 +974,9 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
rc_stringlist_add(env_list, environ[i++]);
|
rc_stringlist_add(env_list, environ[i++]);
|
||||||
TAILQ_FOREACH(env, env_list, entries) {
|
TAILQ_FOREACH(env, env_list, entries) {
|
||||||
if ((strncmp(env->value, "RC_", 3) == 0 &&
|
if ((strncmp(env->value, "RC_", 3) == 0 &&
|
||||||
strncmp(env->value, "RC_SERVICE=", strlen("RC_SERVICE=")) != 0) ||
|
strncmp(env->value, "RC_SERVICE=", 10) != 0 &&
|
||||||
strncmp(env->value, "SSD_NICELEVEL=", strlen("SSD_NICELEVEL=")) == 0)
|
strncmp(env->value, "RC_SVCNAME=", 10) != 0) ||
|
||||||
|
strncmp(env->value, "SSD_NICELEVEL=", 14)) == 0)
|
||||||
{
|
{
|
||||||
p = strchr(env->value, '=');
|
p = strchr(env->value, '=');
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# All rights reserved. Released under the 2-clause BSD license.
|
# All rights reserved. Released under the 2-clause BSD license.
|
||||||
|
|
||||||
# If we have a service specific script, run this now
|
# If we have a service specific script, run this now
|
||||||
[ -x "${SVCNAME}"-down.sh ] && "${SVCNAME}"-down.sh
|
[ -x "${RC_SVCNAME}"-down.sh ] && "${RC_SVCNAME}"-down.sh
|
||||||
|
|
||||||
# Restore resolv.conf to how it was
|
# Restore resolv.conf to how it was
|
||||||
if type resolvconf >/dev/null 2>&1; then
|
if type resolvconf >/dev/null 2>&1; then
|
||||||
@ -16,12 +16,10 @@ elif [ -e /etc/resolv.conf-"${dev}".sv ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Re-enter the init script to stop any dependant services
|
# Re-enter the init script to stop any dependant services
|
||||||
service=/etc/init.d/"${SVCNAME}"
|
if [ -x "${RC_SERVICE}" ]; then
|
||||||
[ ! -x "${service}" ] && service=/usr/local/etc/init.d/"${SVCNAME}"
|
if "${RC_SERVICE}" --quiet status; then
|
||||||
if [ -x "${service}" ]; then
|
|
||||||
if "${service}" --quiet status; then
|
|
||||||
export IN_BACKGROUND=YES
|
export IN_BACKGROUND=YES
|
||||||
"${service}" --quiet stop
|
"${RC_SERVICE}" --quiet stop
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
# A possible workaround would be to just list multiple domain lines
|
# A possible workaround would be to just list multiple domain lines
|
||||||
# and try and let resolvconf handle it
|
# and try and let resolvconf handle it
|
||||||
|
|
||||||
PATH=$PATH:/usr/local/sbin
|
|
||||||
|
|
||||||
NS=
|
NS=
|
||||||
DOMAIN=
|
DOMAIN=
|
||||||
SEARCH=
|
SEARCH=
|
||||||
@ -59,19 +57,15 @@ if [ -n "${NS}" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Below section is OpenRC specific
|
# Below section is OpenRC specific
|
||||||
# Quick summary - our init scripts are re-entrant and set the SVCNAME env var
|
|
||||||
# as we could have >1 openvpn service
|
|
||||||
|
|
||||||
# If we have a service specific script, run this now
|
# If we have a service specific script, run this now
|
||||||
[ -x "${SVCNAME}"-up.sh ] && "${SVCNAME}"-up.sh
|
[ -x "${RC_SVCNAME}"-up.sh ] && "${RC_SVCNAME}"-up.sh
|
||||||
|
|
||||||
# Re-enter the init script to start any dependant services
|
# Re-enter the init script to start any dependant services
|
||||||
service=/etc/init.d/"${SVCNAME}"
|
if [ -x "${RC_SERVICE}" ]; then
|
||||||
[ ! -x "${service}" ] && service=/usr/local/etc/init.d/"${SVCNAME}"
|
if ! "${RC_SERVICE}" --quiet status; then
|
||||||
if [ -x "${service}" ]; then
|
|
||||||
if ! "${service}" --quiet status; then
|
|
||||||
export IN_BACKGROUND=true
|
export IN_BACKGROUND=true
|
||||||
"${service}" --quiet start
|
"${RC_SERVICE}" --quiet start
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user