Re: after upgrade, can't restart apache via cron
----Security_Multipart0(Fri_Nov_23_23_37_54_2012_910)--
Content-Type: Multipart/Mixed;
boundary="--Next_Part(Fri_Nov_23_23_37_54_2012_649)--"
Content-Transfer-Encoding: 7bit
----Next_Part(Fri_Nov_23_23_37_54_2012_649)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
"Michael W. Lucas" <mwlucas@michaelwlucas.com> wrote
in <20121123031753.GA59632@bewilderbeast.blackhelicopters.org>:
mw> eval: setfib: not found
mw> /usr/local/etc/rc.d/apache22: WARNING: failed to start apache22
mw>
mw> If I run /usr/local/etc/rc.d/apache22 restart from the command line, I
mw> can restart httpd without trouble.
mw>
mw> Any thoughts?
This was due to $PATH in the cron job as already pointed out, but
this should not happen. I attached a patch to use full-path for
external commands in rc.subr. If there is no objection to this
change I will commit it.
-- Hiroki
----Next_Part(Fri_Nov_23_23_37_54_2012_649)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="rc.subr.cmdpath.20121123-1.diff"
Index: etc/rc.subr
===================================================================
--- etc/rc.subr (revision 243327)
+++ etc/rc.subr (working copy)
@@ -49,6 +49,18 @@
IDCMD="if [ -x $ID ]; then $ID -un; fi"
PS="/bin/ps -ww"
JID=`$PS -p $$ -o jid=`
+CHROOT_CMD="/usr/sbin/chroot"
+DEVFS_CMD="/sbin/devfs"
+EGREP_CMD="/usr/bin/egrep"
+GREP_CMD="/usr/bin/grep"
+KLDSTAT_CMD="/sbin/kldstat"
+KLDLOAD_CMD="/sbin/kldload"
+LOGGER_CMD="/usr/bin/logger"
+MDMFS_CMD="/sbin/mdmfs"
+MOUNT_CMD="/sbin/mount"
+NICE_CMD="/usr/bin/nice"
+SETFIB_CMD="/usr/sbin/setfib"
+SU_CMD="/usr/bin/su"
#
# functions
@@ -181,7 +193,7 @@
if $_ismounted; then
:
else
- mount $_fs >/dev/null 2>&1
+ ${MOUNT_CMD} $_fs >/dev/null 2>&1
fi
)
done
@@ -726,17 +738,17 @@
check_startmsgs && echo "Starting ${name}."
if [ -n "$_chroot" ]; then
_doit="\
-${_nice:+nice -n $_nice }\
-${_fib:+setfib -F $_fib }\
-chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
+${_nice:+${NICE_CMD} -n $_nice }\
+${_fib:+${SETFIB_CMD} -F $_fib }\
+${CHROOT_CMD} ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
$_chroot $command $rc_flags $command_args"
else
_doit="\
${_chdir:+cd $_chdir && }\
-${_fib:+setfib -F $_fib }\
+${_fib:+${SETFIB_CMD} -F $_fib }\
$command $rc_flags $command_args"
if [ -n "$_user" ]; then
- _doit="su -m $_user -c 'sh -c \"$_doit\"'"
+ _doit="${SU_CMD} -m $_user -c 'sh -c \"$_doit\"'"
fi
if [ -n "$_nice" ]; then
if [ -z "$_user" ]; then
@@ -953,7 +965,7 @@
_cmd="kill -$1 $rc_pid"
if [ -n "$_user" ]; then
- _cmd="su -m ${_user} -c 'sh -c \"${_cmd}\"'"
+ _cmd="${SU_CMD} -m ${_user} -c 'sh -c \"${_cmd}\"'"
fi
echo "$_cmd"
}
@@ -1110,8 +1122,8 @@
exitval=$1
shift
- if [ -x /usr/bin/logger ]; then
- logger "$0: ERROR: $*"
+ if [ -x ${LOGGER_CMD} ]; then
+ ${LOGGER_CMD} "$0: ERROR: $*"
fi
echo 1>&2 "$0: ERROR: $*"
exit $exitval
@@ -1123,8 +1135,8 @@
#
warn()
{
- if [ -x /usr/bin/logger ]; then
- logger "$0: WARNING: $*"
+ if [ -x ${LOGGER_CMD} ]; then
+ ${LOGGER_CMD} "$0: WARNING: $*"
fi
echo 1>&2 "$0: WARNING: $*"
}
@@ -1137,8 +1149,8 @@
{
case ${rc_info} in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
- if [ -x /usr/bin/logger ]; then
- logger "$0: INFO: $*"
+ if [ -x ${LOGGER_CMD} ]; then
+ ${LOGGER_CMD} "$0: INFO: $*"
fi
echo "$0: INFO: $*"
;;
@@ -1155,8 +1167,8 @@
{
case ${rc_debug} in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
- if [ -x /usr/bin/logger ]; then
- logger "$0: DEBUG: $*"
+ if [ -x ${LOGGER_CMD} ]; then
+ ${LOGGER_CMD} "$0: DEBUG: $*"
fi
echo 1>&2 "$0: DEBUG: $*"
;;
@@ -1320,7 +1332,7 @@
fi
eval $rulename=\$rulenum
debug "found ruleset: $rulename=$rulenum"
- if ! /sbin/devfs rule -s $rulenum delset; then
+ if ! ${DEVFS_CMD} rule -s $rulenum delset; then
_err=1
break
fi
@@ -1331,7 +1343,7 @@
# other rules
if [ -n "$rulecmd" ]; then
debug "adding rule ($rulecmd)"
- if ! eval /sbin/devfs rule -s $rulenum $rulecmd
+ if ! eval ${DEVFS_CMD} rule -s $rulenum $rulecmd
then
_err=1
break
@@ -1389,7 +1401,7 @@
return 1
fi
debug "$_me: setting ruleset ($rs) on mount-point (${devdir#-m })"
- if ! /sbin/devfs $devdir ruleset $rs; then
+ if ! ${DEVFS_CMD} $devdir ruleset $rs; then
warn "$_me: unable to set ruleset $rs to ${devdir#-m }"
return 1
fi
@@ -1414,7 +1426,7 @@
return 1
fi
debug "$_me: applying ruleset ($rs) to mount-point (${devdir#-m })"
- if ! /sbin/devfs $devdir rule -s $rs applyset; then
+ if ! ${DEVFS_CMD} $devdir rule -s $rs applyset; then
warn "$_me: unable to apply ruleset $rs to ${devdir#-m }"
return 1
fi
@@ -1438,14 +1450,14 @@
return 1
fi
debug "$_me: mount-point is ($devdir), ruleset is ($rs)"
- if ! mount -t devfs dev "$devdir"; then
+ if ! ${MOUNT_CMD} -t devfs dev "$devdir"; then
warn "$_me: Unable to mount devfs on $devdir"
return 1
fi
if [ -n "$rs" ]; then
devfs_init_rulesets
devfs_set_ruleset $rs $devdir
- devfs -m $devdir rule applyset
+ ${DEVFS_CMD} -m $devdir rule applyset
fi
return 0
}
@@ -1483,7 +1495,7 @@
if [ -n "$3" ]; then
flags="$3"
fi
- /sbin/mdmfs $flags -s $1 md $2
+ ${MDMFS_CMD} $flags -s $1 md $2
}
# Code common to scripts that need to load a kernel module
@@ -1512,16 +1524,16 @@
_mod=${_mod:-$1}
_loaded=false
if [ -n "$_re" ]; then
- if kldstat -v | egrep -q -e "$_re"; then
+ if ${KLDSTAT_CMD} -v | ${EGREP_CMD} -q -e "$_re"; then
_loaded=true
fi
else
- if kldstat -q -m "$_mod"; then
+ if ${KLDSTAT_CMD} -q -m "$_mod"; then
_loaded=true
fi
fi
if ! $_loaded; then
- if ! kldload "$1"; then
+ if ! ${KLDLOAD_CMD} "$1"; then
warn "Unable to load kernel module $1"
return 1
else
@@ -1607,12 +1619,12 @@
for dir in ${local_startup}; do
if [ -d "${dir}" ]; then
for file in ${dir}/[0-9]*.sh; do
- grep '^# PROVIDE:' $file >/dev/null 2>&1 &&
+ ${GREP_CMD} '^# PROVIDE:' $file >/dev/null 2>&1 &&
continue
zlist="$zlist $file"
done
for file in ${dir}/[!0-9]*.sh; do
- grep '^# PROVIDE:' $file >/dev/null 2>&1 &&
+ ${GREP_CMD} '^# PROVIDE:' $file >/dev/null 2>&1 &&
continue
slist="$slist $file"
done
@@ -1624,7 +1636,7 @@
local_rc=''
for dir in ${local_startup}; do
if [ -d "${dir}" ]; then
- for file in `grep -l '^# PROVIDE:' ${dir}/* 2>/dev/null`; do
+ for file in `${GREP_CMD} -l '^# PROVIDE:' ${dir}/* 2>/dev/null`; do
case "$file" in
*.sample) ;;
*) if [ -x "$file" ]; then
----Next_Part(Fri_Nov_23_23_37_54_2012_649)----
----Security_Multipart0(Fri_Nov_23_23_37_54_2012_910)--
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)
iEYEABECAAYFAlCvikIACgkQTyzT2CeTzy2yzACdEQHZqMfc6auIsEPrUgqZ2Jfi
rLYAoI8ZS8Pp7aEB2a2+riVyvQBJYqvy
=v0c/
-----END PGP SIGNATURE-----
----Security_Multipart0(Fri_Nov_23_23_37_54_2012_910)----
討論串 (同標題文章)
完整討論串 (本文為第 8 之 9 篇):