]> git.madduck.net Git - code/molly-guard.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

factor out destination directories to Makefile 0.4.1
authormartin f. krafft <madduck@madduck.net>
Sun, 20 Apr 2008 12:53:40 +0000 (14:53 +0200)
committermartin f. krafft <madduck@madduck.net>
Sun, 20 Apr 2008 12:53:40 +0000 (14:53 +0200)
.gitignore
Makefile
shutdown.in [moved from shutdown with 90% similarity]

index 5e060df242c4f421b1e2584c337167560824d103..a3d9318b7f9e162d322ec0e85c07f19798a7aa70 100644 (file)
@@ -1,4 +1,5 @@
 /build-stamp
 /configure-stamp
 .*.sw?
-/molly-guard.8
+/molly-guard.8*
+/shutdown
index 242c36e6adc4bc54085cbc973e9c631756e67ac5..c0d34f4f13c215d5bbc58143fad4b9876b0b3151 100644 (file)
--- 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
similarity index 90%
rename from shutdown
rename to shutdown.in
index 3ffacc9fe126bffb747cb39e4458062ea39d232d..32ba58d8fc299c970889cddc2c7bcacbb1dc680e 100755 (executable)
--- a/shutdown
@@ -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