# Makefile template
#
# Copyright (C) 1999-2002 Riccardo Facchetti <riccardo@master.oasi.gpa.it>
#
# Default variables
@VARIABLES@
# TOP source directory.
topdir = @topdir@
top_builddir = $(topdir)
# Include the default make targets: to be put before the all-targets: rule.
@TARGETS@
all-targets: Makefile
#
# By the time this 'install' target is called, the @sysconfdir@
# directory has been created and the apccontrol[.sh] and apcupsd.conf
# files have been copied. (The latter will be named apcupsd.conf if
# a previous version already existed.
#
install:
@echo "NetBSD distribution installation"
$(INSTALL_PROGRAM) -m 744 apcupsd /etc/rc.apcupsd
@-today="`date +%Y%m%d%H%M`"; \
grep -q '# TAG_APCUPSD' /etc/rc.shutdown; \
if [ $$? -eq 0 ]; then \
echo "/etc/rc.shutdown already patched"; \
else \
echo "patching /etc/rc.shutdown"; \
rm -f /etc/rc.shutdown.$$today; \
cp -p /etc/rc.shutdown /etc/rc.shutdown.$$today; \
( echo "# Do not remove the 'TAG_APCUPSD' text, below"; \
echo "if [ -f @PWRFAILDIR@/powerfail ]; then # TAG_APCUPSD";\
echo " powerdown=YES # TAG_APCUPSD"; \
echo " echo '' # TAG_APCUPSD"; \
echo " echo 'Please ensure that the UPS has powered off before' # TAG_APCUPSD"; \
echo " echo 'rebooting. Otherwise, the UPS may cut the power' # TAG_APCUPSD"; \
echo " echo 'during the reboot.' # TAG_APCUPSD"; \
echo " echo '' # TAG_APCUPSD"; \
echo "fi # TAG_APCUPSD"; \
) >> /etc/rc.shutdown; \
fi; \
grep -q /etc/rc.apcupsd /etc/rc.local; \
if [ $$? -eq 0 ]; then \
echo "/etc/rc.local already patched"; \
else \
rm -f /etc/rc.local.$$today; \
cp -p /etc/rc.local /etc/rc.local.$$today; \
( echo "# Start the UPS daemon. Do not remove the 'TAG_APCUPSD' text"; \
echo "# if [ -x /etc/rc.apcupsd ]; then # TAG_APCUPSD"; \
echo "# /etc/rc.apcupsd start # TAG_APCUPSD"; \
echo "# fi # TAG_APCUPSD"; \
) >> /etc/rc.local; \
echo ""; \
( echo "While /etc/rc.local has been patched to run apcupsd,";\
echo "the commands are currently commented out. You should"; \
echo "examine the @sysconfdir@/apcupsd.conf file to ensure"; \
echo "that it is suitable for your site. Then run"; \
echo "/etc/rc.apcupsd manually to ensure sane operation."; \
echo "Once you are satisfied, uncomment the appropriate"; \
echo "lines in /etc/rc.local" ) | /usr/bin/fmt; \
fi
uninstall:
@echo "NetBSD distribution uninstall"
rm -f /etc/rc.apcupsd
@-today="`date +%Y%m%d%H%M`"; \
for f in /etc/rc.local /etc/rc.shutdown; do \
grep -q '# TAG_APCUPSD' $$f; \
if [ $$? -eq 0 ]; then \
echo "removing apcupsd lines from $$f"; \
rm -f $$f.$$today; \
cp -p $$f $$f.$$today; \
$(SED) -e '/TAG_APCUPSD/d;' \
< $$f.$$today > $$f; \
chmod 644 $$f; \
fi; \
done
clean:
distclean:
@rm -f apccontrol.sh apcupsd apcupsd.conf Makefile
@rm -rf CVS
syntax highlighted by Code2HTML, v. 0.9.1