From: martin f. krafft Date: Sun, 20 Apr 2008 12:53:40 +0000 (+0200) Subject: factor out destination directories to Makefile X-Git-Tag: 0.4.1 X-Git-Url: https://git.madduck.net/code/molly-guard.git/commitdiff_plain/842c0f9058ada9b8d7ccca624333803d1404bb22?hp=946cdc2f1df4ba60775d48f9d652344e29ec4186 factor out destination directories to Makefile --- diff --git a/.gitignore b/.gitignore index 5e060df..a3d9318 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /build-stamp /configure-stamp .*.sw? -/molly-guard.8 +/molly-guard.8* +/shutdown diff --git a/Makefile b/Makefile index 242c36e..c0d34f4 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,47 @@ -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 diff --git a/shutdown b/shutdown.in similarity index 90% rename from shutdown rename to shutdown.in index 3ffacc9..32ba58d 100755 --- a/shutdown +++ b/shutdown.in @@ -9,7 +9,8 @@ set -eu ME=molly-guard VERSION=0.4 -SCRIPTSDIR=/etc/molly-guard/run.d + +SCRIPTSDIR="@ETC_PREFIX@/etc/$ME/run.d" CMD="${0##*/}" EXEC="/sbin/$CMD" @@ -17,16 +18,16 @@ 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 @@ -103,7 +104,7 @@ 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