Lines 122-189
_status()
Link Here
|
122 |
fi |
122 |
fi |
123 |
} |
123 |
} |
124 |
|
124 |
|
125 |
# Template start / stop / status functions |
|
|
126 |
start() |
127 |
{ |
128 |
[ -n "$command" ] || return 0 |
129 |
local _background= |
130 |
ebegin "Starting ${name:-$RC_SVCNAME}" |
131 |
if yesno "${command_background}"; then |
132 |
if [ -z "${pidfile}" ]; then |
133 |
eend 1 "command_background option used but no pidfile specified" |
134 |
return 1 |
135 |
fi |
136 |
_background="--background --make-pidfile" |
137 |
fi |
138 |
if yesno "$start_inactive"; then |
139 |
local _inactive=false |
140 |
service_inactive && _inactive=true |
141 |
mark_service_inactive |
142 |
fi |
143 |
eval start-stop-daemon --start \ |
144 |
--exec $command \ |
145 |
${procname:+--name} $procname \ |
146 |
${pidfile:+--pidfile} $pidfile \ |
147 |
$_background $start_stop_daemon_args \ |
148 |
-- $command_args |
149 |
if eend $? "Failed to start $RC_SVCNAME"; then |
150 |
service_set_value "command" "${command}" |
151 |
[ -n "${pidfile}" ] && service_set_value "pidfile" "${pidfile}" |
152 |
[ -n "${procname}" ] && service_set_value "procname" "${procname}" |
153 |
return 0 |
154 |
fi |
155 |
if yesno "$start_inactive"; then |
156 |
if ! $_inactive; then |
157 |
mark_service_stopped |
158 |
fi |
159 |
fi |
160 |
return 1 |
161 |
} |
162 |
|
163 |
stop() |
164 |
{ |
165 |
local startcommand="$(service_get_value "command")" |
166 |
local startpidfile="$(service_get_value "pidfile")" |
167 |
local startprocname="$(service_get_value "procname")" |
168 |
command="${startcommand:-$command}" |
169 |
pidfile="${startpidfile:-$pidfile}" |
170 |
procname="${startprocname:-$procname}" |
171 |
[ -n "$command" -o -n "$procname" -o -n "$pidfile" ] || return 0 |
172 |
ebegin "Stopping ${name:-$RC_SVCNAME}" |
173 |
start-stop-daemon --stop \ |
174 |
${retry:+--retry} $retry \ |
175 |
${command:+--exec} $command \ |
176 |
${procname:+--name} $procname \ |
177 |
${pidfile:+--pidfile} $pidfile \ |
178 |
${stopsig:+--signal} $stopsig |
179 |
eend $? "Failed to stop $RC_SVCNAME" |
180 |
} |
181 |
|
182 |
status() |
183 |
{ |
184 |
_status |
185 |
} |
186 |
|
187 |
yesno $RC_DEBUG && set -x |
125 |
yesno $RC_DEBUG && set -x |
188 |
|
126 |
|
189 |
_conf_d=${RC_SERVICE%/*}/../conf.d |
127 |
_conf_d=${RC_SERVICE%/*}/../conf.d |
Lines 205-210
unset _conf_d
Link Here
|
205 |
# Load any system overrides |
143 |
# Load any system overrides |
206 |
sourcex -e "@SYSCONFDIR@/rc.conf" |
144 |
sourcex -e "@SYSCONFDIR@/rc.conf" |
207 |
|
145 |
|
|
|
146 |
# load a service supervisor |
147 |
sourcex "@LIBEXECDIR@/sh/start-stop-daemon.sh" |
148 |
if [ -n "$rc_supervisor" ]; then |
149 |
if ! sourcex -e "@LIBEXECDIR@/sh/${rc_supervisor}.sh"; then |
150 |
ewarn "$rc_supervisor is an invalid value for rc_supervisor" |
151 |
ewarn "Using the default." |
152 |
fi |
153 |
fi |
154 |
|
208 |
# Apply any ulimit defined |
155 |
# Apply any ulimit defined |
209 |
[ -n "${rc_ulimit:-$RC_ULIMIT}" ] && ulimit ${rc_ulimit:-$RC_ULIMIT} |
156 |
[ -n "${rc_ulimit:-$RC_ULIMIT}" ] && ulimit ${rc_ulimit:-$RC_ULIMIT} |
210 |
|
157 |
|