mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-27 19:23:24 +02:00
nut: Added status option, some installation fixed
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
var/ipfire/backup/addons/includes/nut
|
var/ipfire/backup/addons/includes/nut
|
||||||
|
var/state/ups
|
||||||
etc/rc.d/init.d/nut
|
etc/rc.d/init.d/nut
|
||||||
#etc/nut
|
#etc/nut
|
||||||
etc/nut/nut.conf.sample
|
etc/nut/nut.conf.sample
|
||||||
|
|||||||
1
lfs/nut
1
lfs/nut
@@ -82,6 +82,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
|
|||||||
--with-wrap=no --with-udev-dir=/etc/udev
|
--with-wrap=no --with-udev-dir=/etc/udev
|
||||||
cd $(DIR_APP) && make $(MAKETUNING)
|
cd $(DIR_APP) && make $(MAKETUNING)
|
||||||
cd $(DIR_APP) && make install
|
cd $(DIR_APP) && make install
|
||||||
|
-mkdir -p /var/state/ups
|
||||||
install -v -m 644 $(DIR_SRC)/config/backup/includes/nut \
|
install -v -m 644 $(DIR_SRC)/config/backup/includes/nut \
|
||||||
/var/ipfire/backup/addons/includes/nut
|
/var/ipfire/backup/addons/includes/nut
|
||||||
@rm -rf $(DIR_APP)
|
@rm -rf $(DIR_APP)
|
||||||
|
|||||||
65
src/initscripts/init.d/nut
Normal file → Executable file
65
src/initscripts/init.d/nut
Normal file → Executable file
@@ -1,17 +1,4 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: nut
|
|
||||||
# Required-Start: $local_fs $syslog $network
|
|
||||||
# Required-Stop: $local_fs $syslog $network
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: Network UPS Tools initscript
|
|
||||||
# Description: This script take care of starting and stopping the
|
|
||||||
# Network UPS Tools components. When needed, it also
|
|
||||||
# handle the UPS hardware shutdown.
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
# Author: Arnaud Quette <aquette@debian.org>
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@@ -47,21 +34,11 @@ if [ "x$MODE" = "xnone" ] ; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pid_dir=/var/run/nut
|
|
||||||
upsmon_pid=${pid_dir}/upsmon.pid
|
|
||||||
upsd_pid=${pid_dir}/upsd.pid
|
|
||||||
upsd=/usr/sbin/upsd
|
upsd=/usr/sbin/upsd
|
||||||
upsdrvctl=/usr/bin/upsdrvctl
|
upsdrvctl=/usr/bin/upsdrvctl
|
||||||
upsmon=/usr/sbin/upsmon
|
upsmon=/usr/sbin/upsmon
|
||||||
log=">/dev/null 2>/dev/null"
|
log=">/dev/null 2>/dev/null"
|
||||||
|
|
||||||
# Check if /var/run/nut exists and has the correct perms
|
|
||||||
check_var_directory() {
|
|
||||||
[ ! -d ${pid_dir} ] && mkdir -p ${pid_dir} \
|
|
||||||
&& chown root:nut ${pid_dir} \
|
|
||||||
&& chmod 770 ${pid_dir}
|
|
||||||
}
|
|
||||||
|
|
||||||
start_stop_server () {
|
start_stop_server () {
|
||||||
case "$MODE" in
|
case "$MODE" in
|
||||||
standalone|netserver)
|
standalone|netserver)
|
||||||
@@ -69,9 +46,11 @@ start_stop_server () {
|
|||||||
start)
|
start)
|
||||||
! $upsdrvctl start >/dev/null 2>&1 && boot_mesg "(upsdrvctl failed)"
|
! $upsdrvctl start >/dev/null 2>&1 && boot_mesg "(upsdrvctl failed)"
|
||||||
$upsd $UPSD_OPTIONS >/dev/null 2>&1
|
$upsd $UPSD_OPTIONS >/dev/null 2>&1
|
||||||
|
evaluate_retval
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
$upsd -c stop >/dev/null 2>&1
|
$upsd -c stop >/dev/null 2>&1
|
||||||
|
evaluate_retval
|
||||||
! $upsdrvctl stop >/dev/null 2>&1 && boot_mesg "(upsdrvctl failed)"
|
! $upsdrvctl stop >/dev/null 2>&1 && boot_mesg "(upsdrvctl failed)"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -88,9 +67,11 @@ start_stop_client () {
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
$upsmon $UPSMON_OPTIONS >/dev/null 2>&1
|
$upsmon $UPSMON_OPTIONS >/dev/null 2>&1
|
||||||
|
evaluate_retval
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
$upsmon -c stop >/dev/null 2>&1
|
$upsmon -c stop >/dev/null 2>&1
|
||||||
|
evaluate_retval
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
@@ -100,17 +81,39 @@ start_stop_client () {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_server () {
|
||||||
|
case "$MODE" in
|
||||||
|
standalone|netserver)
|
||||||
|
statusproc $upsd
|
||||||
|
statusproc $upsmon
|
||||||
|
;;
|
||||||
|
none|netclient|*)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
status_client () {
|
||||||
|
case "$MODE" in
|
||||||
|
standalone|netclient)
|
||||||
|
statusproc $upsmon
|
||||||
|
;;
|
||||||
|
none|*)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
||||||
start)
|
start)
|
||||||
boot_mesg "Starting $DESC"
|
boot_mesg "Starting $DESC ..."
|
||||||
check_var_directory
|
|
||||||
start_stop_server start
|
start_stop_server start
|
||||||
start_stop_client start
|
start_stop_client start
|
||||||
;;
|
;;
|
||||||
|
|
||||||
stop)
|
stop)
|
||||||
boot_mesg "Stopping $DESC"
|
boot_mesg "Stopping $DESC ..."
|
||||||
start_stop_server stop
|
start_stop_server stop
|
||||||
start_stop_client stop
|
start_stop_client stop
|
||||||
;;
|
;;
|
||||||
@@ -120,12 +123,16 @@ case "$1" in
|
|||||||
$upsmon -c reload >/dev/null 2>&1
|
$upsmon -c reload >/dev/null 2>&1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
status)
|
||||||
|
status_server
|
||||||
|
status_client
|
||||||
|
;;
|
||||||
|
|
||||||
restart|force-reload)
|
restart|force-reload)
|
||||||
boot_mesg "Restarting $DESC"
|
boot_mesg "Restarting $DESC ..."
|
||||||
start_stop_client stop
|
start_stop_client stop
|
||||||
start_stop_server stop
|
start_stop_server stop
|
||||||
sleep 5
|
sleep 5
|
||||||
check_var_directory
|
|
||||||
start_stop_server start
|
start_stop_server start
|
||||||
start_stop_client start
|
start_stop_client start
|
||||||
;;
|
;;
|
||||||
@@ -165,7 +172,7 @@ case "$1" in
|
|||||||
|
|
||||||
*)
|
*)
|
||||||
N=/etc/init.d/$NAME
|
N=/etc/init.d/$NAME
|
||||||
echo "Usage: $N {start|stop|reload|restart|force-reload|poweroff}" >&2
|
echo "Usage: $N {start|stop|status|reload|restart|force-reload|poweroff}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -28,4 +28,8 @@ restore_backup ${NAME}
|
|||||||
|
|
||||||
groupadd nut
|
groupadd nut
|
||||||
|
|
||||||
|
ln -svf ../init.d/nut /etc/rc.d/rc0.d/K20nut
|
||||||
|
ln -svf ../init.d/nut /etc/rc.d/rc3.d/S20nut
|
||||||
|
ln -svf ../init.d/nut /etc/rc.d/rc6.d/K20nut
|
||||||
|
|
||||||
start_service --background ${NAME}
|
start_service --background ${NAME}
|
||||||
|
|||||||
@@ -25,3 +25,5 @@
|
|||||||
stop_service ${NAME}
|
stop_service ${NAME}
|
||||||
make_backup ${NAME}
|
make_backup ${NAME}
|
||||||
remove_files
|
remove_files
|
||||||
|
|
||||||
|
rm -rf /etc/rc.d/rc*.d/*nut
|
||||||
Reference in New Issue
Block a user