Imported Upstream version 2.4.3

This commit is contained in:
arnaud.quette@free.fr 2010-03-26 00:20:59 +01:00
commit 26fb71b504
446 changed files with 148951 additions and 0 deletions

51
scripts/HP-UX/Makefile Normal file
View file

@ -0,0 +1,51 @@
# directory definitions
INSTALLSH = ../../install-sh
CONFIGPATH = /etc/rc.config.d
SCRIPTPATH = /sbin/init.d
LINKPATH = /sbin/rc3.d
LINKPREFIX = 991
OWNER = root
GROUP = root
SCRIPTS = nut-upsd.sh nut-drvctl.sh nut-upsmon.sh
CONFIGS = nut-drvctl nut-upsd nut-upsmon
INSTALLPERMS = 0755
INSTALLCMD = $(INSTALLSH) -c
all: install
install:
@if (test ! -d $(CONFIGPATH)) then \
echo "NO $(CONFIGPATH)"; exit 1; \
fi
@if (test ! -d $(SCRIPTPATH)) then \
echo "NO $(SCRIPTPATH)"; exit 1; \
fi
@if (test ! -d $(LINKPATH)) then \
echo "NO $(LINKPATH)"; exit 1; \
fi
@for script in $(SCRIPTS); do\
name=`basename $$script .sh` ; \
$(INSTALLSH) -c -o $(OWNER) -g $(GROUP) $$script $(SCRIPTPATH)/$$name || exit 1; \
ln -s $(SCRIPTPATH)/$$name $(LINKPATH)/K$(LINKPREFIX)$$name \
|| echo "Unable to link $(SCRIPTPATH)/$$name to $(LINKPATH)/K$(LINKPREFIX)$$name"; \
ln -s $(SCRIPTPATH)/$$name $(LINKPATH)/S$(LINKPREFIX)$$name \
|| echo "Unable to link $(SCRIPTPATH)/$$name to $(LINKPATH)/S$(LINKPREFIX)$$name"; \
done
@for config in $(CONFIGS); do\
$(INSTALLSH) -c -o $(OWNER) -g $(GROUP) $$config $(CONFIGPATH) || exit 1 ; \
done
remove:
@for config in $(CONFIGS); do\
rm -f $(CONFIGPATH)/$$config;\
done
@for script in $(SCRIPTS); do\
name=`basename $$script .sh` ; \
rm -f $(SCRIPTPATH)/$$name || exit 1; \
rm -f $(LINKPATH)/K$(LINKPREFIX)$$name \
|| echo "Unable to remove $(LINKPATH)/K$(LINKPREFIX)$$name"; \
rm -f $(LINKPATH)/S$(LINKPREFIX)$$name \
|| echo "Unable to remove $(LINKPATH)/S$(LINKPREFIX)$$name"; \
done

8
scripts/HP-UX/nut-drvctl Normal file
View file

@ -0,0 +1,8 @@
# NUT_START: Set to 1 to start NUT
# NUT_ARGS: Command line arguments to pass to NUT
#
# To configure the NUT environment:
NUT_START=1
UPSNAME= # Blank == all configured UPSs
RUNAS= # Blank == run as root

114
scripts/HP-UX/nut-drvctl.sh Executable file
View file

@ -0,0 +1,114 @@
#!/sbin/sh
#
# nut-drvctl: NUT ups model-specific drivers start-up and shutdown script
#
# Allowed exit values:
# 0 = success; causes "OK" to show up in checklist.
# 1 = failure; causes "FAIL" to show up in checklist.
# 2 = skip; causes "N/A" to show up in the checklist.
# Use this value if execution of this script is overridden
# by the use of a control variable, or if this script is not
# appropriate to execute for some other reason.
# 3 = reboot; causes the system to be rebooted after execution.
# Input and output:
# stdin is redirected from /dev/null
#
# stdout and stderr are redirected to the /etc/rc.log file
# during checklist mode, or to the console in raw mode.
umask 022
PATH=/usr/sbin:/usr/bin:/sbin
export PATH
WHAT='NUT UPS driver (Network UPS Tools -- http://www.exploits.org/nut)'
WHAT_PATH=/opt/nut/bin/upsdrvctl
WHAT_CONFIG=/etc/rc.config.d/nut-drvctl
# NOTE: If your script executes in run state 0 or state 1, then /usr might
# not be available. Do not attempt to access commands or files in
# /usr unless your script executes in run state 2 or greater. Other
# file systems typically not mounted until run state 2 include /var
# and /opt.
rval=0
# Check the exit value of a command run by this script. If non-zero, the
# exit code is echoed to the log file and the return value of this script
# is set to indicate failure.
set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "EXIT CODE: $x"
rval=1 # script FAILed
fi
}
case $1 in
'start_msg')
echo "Starting $WHAT"
;;
'stop_msg')
echo "Stopping $WHAT"
;;
'start')
if [ -f $WHAT_CONFIG ] ; then
. $WHAT_CONFIG
else
echo "ERROR: $WHAT_CONFIG defaults file MISSING"
fi
if [ "X$RUNAS" = "X" ] ; then
# no user set
if [ "$NUT_START" -eq 1 -a -x $WHAT_PATH ]; then
$WHAT_PATH start $UPSNAME && echo $WHAT started $UPSNAME
set_return
else
rval=2
fi
else
# start upsd as a specified user
if [ "$NUT_START" -eq 1 -a -x $WHAT_PATH ]; then
su $RUNAS -c $WHAT_PATH start $UPSNAME && echo $WHAT started $UPSNAME as user $RUNAS
set_return
else
rval=2
fi
fi
;;
'stop')
if [ "X$RUNAS" = "X" ] ; then
$WHAT_PATH stop $UPSNAME
if [ $? -eq 0 ]; then
echo "$WHAT stopped $UPSNAME"
else
rval=1
echo "Unable to stop $WHAT $UPSNAME"
fi
else
su $RUNAS -c $WHAT_PATH stop $UPSNAME
if [ $? -eq 0 ]; then
echo "$WHAT stopped $UPSNAME by user $RUNAS"
else
rval=1
echo "User $RUNAS unable to stop $WHAT $UPSNAME"
fi
fi
;;
*)
echo "usage: $0 {start|stop|start_msg|stop_msg}"
rval=1
;;
esac
exit $rval

8
scripts/HP-UX/nut-upsd Normal file
View file

@ -0,0 +1,8 @@
# NUT_START: Set to 1 to start NUT
# NUT_ARGS: Command line arguments to pass to NUT
#
# To configure the NUT environment:
NUT_START=1
UPSNAME= # Blank == all configured UPSs
RUNAS= # Blank == run as root

113
scripts/HP-UX/nut-upsd.sh Executable file
View file

@ -0,0 +1,113 @@
#!/sbin/sh
#
# nut-upsd: NUT upsd start-up and shutdown script
#
# Allowed exit values:
# 0 = success; causes "OK" to show up in checklist.
# 1 = failure; causes "FAIL" to show up in checklist.
# 2 = skip; causes "N/A" to show up in the checklist.
# Use this value if execution of this script is overridden
# by the use of a control variable, or if this script is not
# appropriate to execute for some other reason.
# 3 = reboot; causes the system to be rebooted after execution.
# Input and output:
# stdin is redirected from /dev/null
#
# stdout and stderr are redirected to the /etc/rc.log file
# during checklist mode, or to the console in raw mode.
umask 022
PATH=/usr/sbin:/usr/bin:/sbin
export PATH
WHAT='NUT UPS daemon (Network UPS Tools -- http://www.exploits.org/nut)'
WHAT_PATH=/opt/nut/sbin/upsd
WHAT_CONFIG=/etc/rc.config.d/nut-upsd
# NOTE: If your script executes in run state 0 or state 1, then /usr might
# not be available. Do not attempt to access commands or files in
# /usr unless your script executes in run state 2 or greater. Other
# file systems typically not mounted until run state 2 include /var
# and /opt.
rval=0
# Check the exit value of a command run by this script. If non-zero, the
# exit code is echoed to the log file and the return value of this script
# is set to indicate failure.
set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "EXIT CODE: $x"
rval=1 # script FAILed
fi
}
case $1 in
'start_msg')
echo "Starting $WHAT"
;;
'stop_msg')
echo "Stopping $WHAT"
;;
'start')
if [ -f $WHAT_CONFIG ] ; then
. $WHAT_CONFIG
else
echo "ERROR: $WHAT_CONFIG defaults file MISSING"
fi
if [ "X$RUNAS" = "X" ] ; then
# no user set
if [ "$NUT_START" -eq 1 -a -x $WHAT_PATH ]; then
$WHAT_PATH && echo $WHAT started
set_return
else
rval=2
fi
else
# start upsd as a specified user
if [ "$NUT_START" -eq 1 -a -x $WHAT_PATH ]; then
su $RUNAS -c $WHAT_PATH && echo $WHAT started as user $RUNAS
set_return
else
rval=2
fi
fi
;;
'stop')
if [ "X$RUNAS" = "X" ] ; then
$WHAT_PATH -c stop
if [ $? -eq 0 ]; then
echo "$WHAT stopped"
else
rval=1
echo "Unable to stop $WHAT"
fi
else
su $RUNAS -c "$WHAT_PATH -c stop"
if [ $? -eq 0 ]; then
echo "$WHAT stopped by user $RUNAS"
else
rval=1
echo "User $RUNAS unable to stop $WHAT"
fi
fi
;;
*)
echo "usage: $0 {start|stop|start_msg|stop_msg}"
rval=1
;;
esac
exit $rval

7
scripts/HP-UX/nut-upsmon Normal file
View file

@ -0,0 +1,7 @@
# NUT_START: Set to 1 to start NUT
# NUT_ARGS: Command line arguments to pass to NUT
#
# To configure the NUT environment:
NUT_START=1
UPSMON_ARGS=

92
scripts/HP-UX/nut-upsmon.sh Executable file
View file

@ -0,0 +1,92 @@
#!/sbin/sh
#
# nut-upsmon: NUT ups monitor start-up and shutdown script
#
# Allowed exit values:
# 0 = success; causes "OK" to show up in checklist.
# 1 = failure; causes "FAIL" to show up in checklist.
# 2 = skip; causes "N/A" to show up in the checklist.
# Use this value if execution of this script is overridden
# by the use of a control variable, or if this script is not
# appropriate to execute for some other reason.
# 3 = reboot; causes the system to be rebooted after execution.
# Input and output:
# stdin is redirected from /dev/null
#
# stdout and stderr are redirected to the /etc/rc.log file
# during checklist mode, or to the console in raw mode.
umask 022
PATH=/usr/sbin:/usr/bin:/sbin
export PATH
WHAT='NUT UPS monitor (Network UPS Tools -- http://www.exploits.org/nut)'
WHAT_PATH=/opt/nut/sbin/upsmon
WHAT_CONFIG=/etc/rc.config.d/nut-upsmon
# NOTE: If your script executes in run state 0 or state 1, then /usr might
# not be available. Do not attempt to access commands or files in
# /usr unless your script executes in run state 2 or greater. Other
# file systems typically not mounted until run state 2 include /var
# and /opt.
rval=0
# Check the exit value of a command run by this script. If non-zero, the
# exit code is echoed to the log file and the return value of this script
# is set to indicate failure.
set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "EXIT CODE: $x"
rval=1 # script FAILed
fi
}
case $1 in
'start_msg')
echo "Starting $WHAT"
;;
'stop_msg')
echo "Stopping $WHAT"
;;
'start')
if [ -f $WHAT_CONFIG ] ; then
. $WHAT_CONFIG
else
echo "ERROR: $WHAT_CONFIG defaults file MISSING"
fi
if [ "$NUT_START" -eq 1 -a -x $WHAT_PATH ]; then
$WHAT_PATH $UPSMON_ARGS && echo $WHAT $UPSMON_ARGS started
set_return
else
rval=2
fi
;;
'stop')
$WHAT_PATH -c stop
if [ $? -eq 0 ]; then
echo "$WHAT stopped"
else
rval=1
echo "Unable to stop $WHAT"
fi
;;
*)
echo "usage: $0 {start|stop|start_msg|stop_msg}"
rval=1
;;
esac
exit $rval