-DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl
-XP=xsltproc -''-nonet
+prefix?=/usr/local
+etc_prefix?=$(prefix)
+DST=$(DEST)$(prefix)
+ETCDIR=$(DEST)$(etc_prefix)/etc/molly-guard
-MANPAGE=molly-guard.8
-
-all: $(MANPAGE)
+all: molly-guard.8.gz shutdown
+%.8: DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl
+%.8: XP=xsltproc -''-nonet
%.8: %.xml
$(XP) $(DB2MAN) $<
-man: $(MANPAGE)
+%.gz: %
+ gzip -9 $<
+
+man: molly-guard.8
man -l $<
.PHONY: man
clean:
- rm -f $(MANPAGE)
+ rm -f shutdown
+ rm -f molly-guard.8 molly-guard.8.gz
.PHONY: clean
+shutdown: shutdown.in
+ sed -e 's,@ETC_PREFIX@,$(etc_prefix),g' $< > $@
+
+install: shutdown molly-guard.8.gz
+ mkdir -m755 --parent $(DST)/share/molly-guard
+ install -m755 -oroot -oroot shutdown $(DST)/share/molly-guard
+
+ mkdir -m755 --parent $(DST)/sbin
+ ln -s ../share/molly-guard/shutdown $(DST)/sbin/poweroff
+ ln -s ../share/molly-guard/shutdown $(DST)/sbin/halt
+ ln -s ../share/molly-guard/shutdown $(DST)/sbin/reboot
+ ln -s ../share/molly-guard/shutdown $(DST)/sbin/shutdown
+
+ mkdir -m755 --parent $(ETCDIR)
+ install -m644 -oroot -oroot rc $(ETCDIR)
+ cp -r run.d $(ETCDIR) \
+ && chown root.root $(ETCDIR)/run.d && chmod 755 $(ETCDIR)/run.d
+
+ mkdir -m755 --parent $(ETCDIR)/messages.d
+
+ mkdir -m755 --parent $(DST)/share/man/man8
+ install -m644 -oroot -groot molly-guard.8.gz $(DST)/share/man/man8
+.PHONY: install
ME=molly-guard
VERSION=0.4
-SCRIPTSDIR=/etc/molly-guard/run.d
+
+SCRIPTSDIR="@ETC_PREFIX@/etc/$ME/run.d"
CMD="${0##*/}"
EXEC="/sbin/$CMD"
case "$CMD" in
halt|reboot|shutdown|poweroff)
if [ ! -f $EXEC ]; then
- echo "E: $ME: not a regular file: $EXEC" >&2
+ echo "E: not a regular file: $EXEC" >&2
exit 4
fi
if [ ! -x $EXEC ]; then
- echo "E: $ME: not an executable: $EXEC" >&2
+ echo "E: not an executable: $EXEC" >&2
exit 3
fi
;;
*)
- echo "E: $ME: unsupported command: $CMD" >&2
+ echo "E: unsupported command: $CMD" >&2
exit 1
;;
esac
MOLLYGUARD_CMD=$CMD; export MOLLYGUARD_CMD
MOLLYGUARD_DO_NOTHING=$DO_NOTHING; export MOLLYGUARD_DO_NOTHING
-MOLLYGUARD_SETTINGS="/etc/molly-guard/rc"; export MOLLYGUARD_SETTINGS
+MOLLYGUARD_SETTINGS="@ETC_PREFIX@/etc/$ME/rc"; export MOLLYGUARD_SETTINGS
for script in $(run-parts --test $SCRIPTSDIR); do
ret=0