COMMAND=/etc/init.d/$NAME
LOGGER="/usr/bin/logger -t $NAME-hotplug"
-LOG_ERR="$LOGGER -p user.err --"
-LOG_NOTICE="$LOGGER -p user.notice --"
+LOG_ERR="$LOGGER -p daemon.err --"
+LOG_INFO="$LOGGER -p daemon.info --"
+LOG_WARN="$LOGGER -p daemon.warn --"
[ "$ACTION" = ifup ] || exit 0
pidof $NAME &> /dev/null
if [ $? -eq 0 ]; then
- $LOG_NOTICE stopping $NAME
+ $LOG_INFO stopping $NAME
$COMMAND stop &> /dev/null
fi
while [ -n "$notReady" -a $tmp_timeout -gt 0 ]; do
if [ "$notReady" != start ]; then
- $LOG_NOTICE "$mnt" not yet mounted, timeout in $tmp_timeout s
+ $LOG_INFO "$mnt" not yet mounted, timeout in $tmp_timeout s
sleep 5
tmp_timeout=$(($tmp_timeout-5))
fi
$LOG_ERR not starting $NAME
exit 1
else
- $LOG_NOTICE "$mnt" mounted
+ $LOG_INFO "$mnt" mounted
fi
}
while [ -n "$notReady" -a $tmp_timeout -gt 0 ]; do
if [ "$notReady" != start ]; then
- $LOG_NOTICE system time not in sync yet, timeout in $tmp_timeout s
+ $LOG_INFO system time not in sync yet, timeout in $tmp_timeout s
sleep 5
tmp_timeout=$(($tmp_timeout-5))
fi
result=$(ntpq -c 'timeout 300' -c 'rv 0 stratum' 2> /dev/null | \
awk -F '=' '{print $2}' | grep -o -E '^[0-9]+')
if [ -z $result ]; then
- $LOG_ERR failed to extract stratum from ntpd
+ $LOG_WARN failed to extract stratum from ntpd
notReady="unable to extract stratum"
else
- $LOG_NOTICE ntpd stratum $result
+ $LOG_INFO ntpd stratum $result
if [ $result -lt 16 ] 2> /dev/null; then
result=$(ntpq -c 'timeout 300' -c 'rv 0 offset' 2> /dev/null \
- | awk -F '=' '{print $2}' | grep -o -E '^-?[0-9]+')
+ | awk -F '=' '{print $2}' | grep -o -E '^[-+]?[0-9]+')
if [ -z $result ]; then
- $LOG_ERR failed to extract offset from ntpd
+ $LOG_WARN failed to extract offset from ntpd
notReady="unable to extract offset"
else
# "-0" looks stupid, so remove "-"
result=$(echo $result | grep -o '[0-9]*')
- $LOG_NOTICE ntpd to system time offset \+\/\- $result ms
+ $LOG_INFO ntpd to system time offset \+\/\- $result ms
# If offset < 100 ms consider system time in sync
[ $result -lt 100 ] || notReady="system time not in sync yet"
fi
$LOG_ERR not starting $NAME
exit 1
else
- $LOG_NOTICE system time in sync
+ $LOG_INFO system time in sync
fi
}
sleep 1
pidof $NAME &>/dev/null
if [ $? -eq 0 ]; then
- $LOG_NOTICE started $NAME due to \"ifup "$INTERFACE"\" event
+ $LOG_INFO started $NAME due to \"ifup "$INTERFACE"\" event
else
$LOG_ERR start of $NAME due to \"ifup "$INTERFACE"\" event failed
exit 1
NAME=freeswitch
COMMAND=/usr/bin/$NAME
-LOGGER="/usr/bin/logger -p user.err -s -t $NAME --"
+LOGGER="/usr/bin/logger -s -t $NAME"
+LOG_ERR="$LOGGER -p daemon.err --"
+LOG_WARN="$LOGGER -p daemon.warn --"
+LOG_INFO="$LOGGER -p daemon.info --"
start_service() {
dir_etc=/etc/$NAME
config_get_bool enabled general enabled 0
if [ $enabled -eq 0 ]; then
- $LOGGER service not enabled in /etc/config/$NAME
+ $LOG_ERR service not enabled in /etc/config/$NAME
exit 1
fi
config_get options general options
+ config_get term_timeout general term_timeout default
+ if [ default = "$term_timeout" ]; then
+ $LOG_INFO using procd\'s default term_timeout
+ elif ! [ 0 -lt "$term_timeout" ] 2>/dev/null; then
+ $LOG_ERR invalid term_timeout in /etc/config/$NAME
+ exit 1
+ fi
+
for i in "$dir_localstate" "$dir_run"; do
if ! [ -e "$i" ]; then
mkdir -m 0750 -p "$i"
command -v su >/dev/null
ret=$?
if [ 0 != "$ret" ]; then
- $LOGGER utility \"su\" not available
- $LOGGER will not attempt to create directories
+ $LOG_WARN utility \"su\" not available
+ $LOG_WARN will not attempt to create directories
else
for i in "$dir_cache" \
"$dir_db" \
procd_set_param stderr $log_stderr
# same for stdout
procd_set_param stdout $log_stdout
+ if ! [ default = "$term_timeout" ]; then
+ procd_set_param term_timeout "$term_timeout"
+ fi
procd_close_instance
}