UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / platforms / freebsd / Makefile
blob8c1341a6eb902407cf4981e2bb7f25ab13203fca
1 topdir:=../..
3 SUBDIRS =
4 include $(topdir)/autoconf/targets.mak
6 all-install: install-freebsd
7 all-uninstall: uninstall-freebsd
9 install-freebsd:
10 $(call DISTINST,FreeBSD)
11 $(call MKDIR,/etc)
12 $(call INSTPROG,744,apcupsd,/etc/rc.apcupsd)
13 $(VV)-today="`date +%Y%m%d%H%M`"; \
14 grep -q '# TAG_APCUPSD' /etc/rc.shutdown; \
15 if [ $$? -ne 0 ]; then \
16 echo " PATCH $(DESTDIR)/etc/rc.shutdown"; \
17 rm -f $(DESTDIR)/etc/rc.shutdown.$$today; \
18 cp -p /etc/rc.shutdown $(DESTDIR)/etc/rc.shutdown.$$today; \
19 $(SED) -e '/exit 0/d'< $(DESTDIR)/etc/rc.shutdown.$$today > $(DESTDIR)/etc/rc.shutdown; \
20 ( echo "# Do not remove the 'TAG_APCUPSD' text, below"; \
21 echo "if [ -f $(PWRFAILDIR)/powerfail ]; then # TAG_APCUPSD";\
22 echo " powerdown=YES # TAG_APCUPSD"; \
23 echo " echo '' # TAG_APCUPSD"; \
24 echo " echo 'Please ensure that the UPS has powered off before' # TAG_APCUPSD"; \
25 echo " echo 'rebooting. Otherwise, the UPS may cut the power' # TAG_APCUPSD"; \
26 echo " echo 'during the reboot.' # TAG_APCUPSD"; \
27 echo " echo '' # TAG_APCUPSD"; \
28 echo "fi # TAG_APCUPSD"; \
29 echo "exit 0"; \
30 ) >> $(DESTDIR)/etc/rc.shutdown; \
31 chmod 744 $(DESTDIR)/etc/rc.shutdown; \
32 fi; \
33 grep -q /etc/rc.apcupsd /etc/rc.local; \
34 if [ $$? -ne 0 ]; then \
35 echo " PATCH $(DESTDIR)/etc/rc.local"; \
36 rm -f $(DESTDIR)/etc/rc.local.$$today; \
37 cp -p /etc/rc.local $(DESTDIR)/etc/rc.local.$$today; \
38 ( echo "# Start the UPS daemon. Do not remove the 'TAG_APCUPSD' text"; \
39 echo "# if [ -x /etc/rc.apcupsd ]; then # TAG_APCUPSD"; \
40 echo "# /etc/rc.apcupsd start # TAG_APCUPSD"; \
41 echo "# fi # TAG_APCUPSD"; \
42 ) >> $(DESTDIR)/etc/rc.local; \
43 echo ""; \
44 ( echo "While /etc/rc.local has been patched to run apcupsd,";\
45 echo "the commands are currently commented out. You should"; \
46 echo "examine the $(sysconfdir)/apcupsd.conf file to ensure"; \
47 echo "that it is suitable for your site. Then run"; \
48 echo "/etc/rc.apcupsd manually to ensure sane operation."; \
49 echo "Once you are satisfied, uncomment the appropriate"; \
50 echo "lines in /etc/rc.local" ) | /usr/bin/fmt; \
53 uninstall-freebsd:
54 $(call DISTUNINST,FreeBSD)
55 -$(call UNINST,/etc/rc.apcupsd)
56 $(VV)-today="`date +%Y%m%d%H%M`"; \
57 for f in $(DESTDIR)/etc/rc.local $(DESTDIR)/etc/rc.shutdown; do \
58 grep -q '# TAG_APCUPSD' $$f; \
59 if [ $$? -eq 0 ]; then \
60 echo " PATCH $$f"; \
61 rm -f $$f.$$today; \
62 cp -p $$f $$f.$$today; \
63 $(SED) -e '/TAG_APCUPSD/d;' \
64 < $$f.$$today > $$f; \
65 chmod 644 $$f; \
66 fi; \
67 done