Fix output messages content and format

This commit is contained in:
Arnaud Quette 2012-05-02 20:31:36 +02:00
parent 19bb945c64
commit f4447a2e78
2 changed files with 14 additions and 9 deletions

View file

@ -17,7 +17,7 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
NAME=nut-client NAME=nut-client
DESC="Network UPS Tools - power device monitor and shutdown controller" DESC="NUT - power device monitor and shutdown controller"
CONFIG=/etc/nut/nut.conf CONFIG=/etc/nut/nut.conf
pid_dir=/var/run/nut pid_dir=/var/run/nut
upsmon_pid=${pid_dir}/upsmon.pid upsmon_pid=${pid_dir}/upsmon.pid
@ -75,8 +75,7 @@ start_stop_client () {
case "$1" in case "$1" in
start) start)
start-stop-daemon -S -q -p $upsmon_pid -x $upsmon \ start-stop-daemon -S -q -p $upsmon_pid -x $upsmon \
-- $UPSMON_OPTIONS >/dev/null 2>&1 && -- $UPSMON_OPTIONS >/dev/null 2>&1 && return 0 || return 1
log_progress_msg "upsmon" || log_progress_msg "(upsmon failed)"
;; ;;
stop) stop)
start-stop-daemon -K -o -q -p $upsmon_pid -n upsmon >/dev/null 2>&1 && start-stop-daemon -K -o -q -p $upsmon_pid -n upsmon >/dev/null 2>&1 &&
@ -95,17 +94,20 @@ case "$1" in
start) start)
log_daemon_msg "Starting $DESC" log_daemon_msg "Starting $DESC"
check_var_directory check_var_directory
start_stop_client start #&& log_progress_msg "upsmon" start_stop_client start && log_progress_msg "upsmon"
|| log_progress_msg "upsmon (failed)"
log_end_msg 0 log_end_msg 0
;; ;;
stop) stop)
log_daemon_msg "Stopping $DESC" log_daemon_msg "Stopping $DESC"
start_stop_client stop && log_progress_msg "upsmon" start_stop_client stop && log_progress_msg "upsmon"
|| log_progress_msg "upsmon (failed)"
log_end_msg 0 log_end_msg 0
;; ;;
reload) reload)
log_daemon_msg "Reloading $DESC"
$upsmon -c reload >/dev/null 2>&1 $upsmon -c reload >/dev/null 2>&1
;; ;;
@ -117,12 +119,13 @@ case "$1" in
# - restart (Ie stop+start) nut-server # - restart (Ie stop+start) nut-server
# - start nut-client # - start nut-client
log_daemon_msg "Restarting $DESC" log_daemon_msg "Restarting $DESC"
start_stop_client stop start_stop_client stop || log_progress_msg "upsmon (failed)"
# should then 'start_stop_server stop', Ie /etc/init.d/nut-server stop # should then 'start_stop_server stop', Ie /etc/init.d/nut-server stop
#sleep 5 #sleep 5
check_var_directory check_var_directory
# should first 'start_stop_server start', Ie /etc/init.d/nut-server start # should first 'start_stop_server start', Ie /etc/init.d/nut-server start
start_stop_client start && log_progress_msg "upsmon" start_stop_client start && log_progress_msg "upsmon"
|| log_progress_msg "upsmon (failed)"
log_end_msg 0 log_end_msg 0
;; ;;
@ -148,6 +151,7 @@ case "$1" in
fi fi
# Defer to nut-server to actually poweroff the UPS, if needed # Defer to nut-server to actually poweroff the UPS, if needed
# (the need is tested here though!)
if $upsmon -K >/dev/null 2>&1 ; then if $upsmon -K >/dev/null 2>&1 ; then
log_daemon_msg "UPS poweroff required..." log_daemon_msg "UPS poweroff required..."
log_end_msg 0 log_end_msg 0

View file

@ -16,7 +16,7 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
NAME=nut-server NAME=nut-server
DESC="Network UPS Tools - power devices information server and drivers" DESC="NUT - power devices information server and drivers"
CONFIG=/etc/nut/nut.conf CONFIG=/etc/nut/nut.conf
pid_dir=/var/run/nut pid_dir=/var/run/nut
upsd_pid=${pid_dir}/upsd.pid upsd_pid=${pid_dir}/upsd.pid
@ -76,18 +76,19 @@ start_stop_server () {
start) start)
# First, start driver(s) # First, start driver(s)
! $upsdrvctl start >/dev/null 2>&1 && \ ! $upsdrvctl start >/dev/null 2>&1 && \
log_progress_msg "(driver(s) failed)" || log_progress_msg "driver(s)" log_progress_msg " (driver(s) failed)." || log_progress_msg " driver(s)."
# Then, data server (upsd) # Then, data server (upsd)
start-stop-daemon -S -p $upsd_pid -x $upsd \ start-stop-daemon -S -p $upsd_pid -x $upsd \
-- $UPSD_OPTIONS >/dev/null 2>&1 && -- $UPSD_OPTIONS >/dev/null 2>&1 &&
log_progress_msg "upsd" || log_progress_msg "(upsd failed)" log_progress_msg "upsd" || log_progress_msg "(upsd failed)"
;; ;;
stop) stop)
# FIXME: should stop nut-client first!
# Reverse order for stop # Reverse order for stop
start-stop-daemon -K -o -p $upsd_pid -n upsd && #>/dev/null 2>&1 && start-stop-daemon -K -o -p $upsd_pid -n upsd && #>/dev/null 2>&1 &&
log_action_msg "upsd" || log_action_msg "(upsd failed)" log_progress_msg "upsd" || log_progress_msg "(upsd failed)"
! /sbin/upsdrvctl stop >/dev/null 2>&1 && \ ! /sbin/upsdrvctl stop >/dev/null 2>&1 && \
log_action_msg "(driver(s) failed)" || log_action_msg "driver(s)" log_progress_msg "(driver(s) failed)" || log_progress_msg "driver(s)"
;; ;;
esac esac
;; ;;