66c5665356
manually. - Ignore lines with rfact at stop time, they cannot be stopped. Reported by wiz@.
89 lines
1.4 KiB
Bash
Executable File
89 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# $NetBSD: envsys,v 1.2 2007/07/25 12:47:44 xtraeme Exp $
|
|
#
|
|
|
|
# PROVIDE: envsys
|
|
# REQUIRE: LOGIN DAEMON
|
|
|
|
$_rc_subr_loaded . /etc/rc.subr
|
|
|
|
name="envsys"
|
|
rcvar=${name}
|
|
required_files="/etc/envsys.conf"
|
|
start_cmd="do_envsys start"
|
|
stop_cmd="do_envsys stop"
|
|
envsys_bin="/usr/sbin/envstat"
|
|
|
|
do_envsys()
|
|
{
|
|
IFS=":"
|
|
if [ "$1" = "start" ]; then
|
|
TARGET="Starting"
|
|
else
|
|
TARGET="Stopping"
|
|
fi
|
|
|
|
while read -r device sensname target value; do
|
|
case "${device}" in
|
|
\#*|"")
|
|
continue
|
|
;;
|
|
esac
|
|
|
|
case "${value}" in
|
|
*degF)
|
|
add_arg="-f"
|
|
;;
|
|
esac
|
|
|
|
case "$1" in
|
|
start)
|
|
case "${target}" in
|
|
*desc)
|
|
continue
|
|
;;
|
|
esac
|
|
;;
|
|
stop)
|
|
case "${target}" in
|
|
*desc|*rfact)
|
|
continue
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
[ -z ${device} ] && err_msg="missing device"
|
|
[ -z ${target} ] && err_msg="missing target"
|
|
[ -z ${value} ] && err_msg="missing value"
|
|
|
|
if [ -n "${err_msg}" ]; then
|
|
echo "${name}: invalid entry (${err_msg})."
|
|
return 1
|
|
fi
|
|
|
|
if [ "$1" = "start" ]; then
|
|
${envsys_bin} \
|
|
${add_arg} \
|
|
-d ${device} \
|
|
-s "${sensname}" \
|
|
-m ${target}=${value%%degF}
|
|
else
|
|
${envsys_bin} \
|
|
${add_arg} \
|
|
-d ${device} \
|
|
-s "${sensname}" \
|
|
-m ${target}=remove
|
|
fi
|
|
|
|
# reinitialize the var
|
|
add_arg=
|
|
done < ${required_files}
|
|
|
|
echo "$TARGET sensors monitoring."
|
|
}
|
|
|
|
load_rc_config ${name}
|
|
run_rc_command "$1"
|