[csw-devel] SF.net SVN: gar:[7070] csw/mgar/pkg/denyhosts/trunk

bensons at users.sourceforge.net bensons at users.sourceforge.net
Mon Nov 2 09:42:21 CET 2009


Revision: 7070
          http://gar.svn.sourceforge.net/gar/?rev=7070&view=rev
Author:   bensons
Date:     2009-11-02 08:42:21 +0000 (Mon, 02 Nov 2009)

Log Message:
-----------
denyhosts: initial package version

Modified Paths:
--------------
    csw/mgar/pkg/denyhosts/trunk/Makefile

Added Paths:
-----------
    csw/mgar/pkg/denyhosts/trunk/files/cswdenyhosts

Modified: csw/mgar/pkg/denyhosts/trunk/Makefile
===================================================================
--- csw/mgar/pkg/denyhosts/trunk/Makefile	2009-11-01 22:18:24 UTC (rev 7069)
+++ csw/mgar/pkg/denyhosts/trunk/Makefile	2009-11-02 08:42:21 UTC (rev 7070)
@@ -1,6 +1,3 @@
-# TODO
-# - Integrate into SMF, do we need daemon-control-dist at all?
-# - Test the package
 GARNAME = denyhosts
 GARVERSION = 2.6
 CATEGORIES = python
@@ -26,6 +23,7 @@
 DISTFILES  = $(DISTNAME).tar.gz
 LICENSE = LICENSE.txt
 ARCHALL = 1
+INITSMF = /etc/opt/csw/init.d/cswdenyhosts
 
 # We define upstream file regex so we can be notifed of new upstream software release
 UFILES_REGEX = $(GARNAME)-(\d+(?:\.\d+)*).tar.gz
@@ -49,6 +47,7 @@
 post-install-modulated:
 	ginstall -d $(DOCDEST)
 	ginstall -d $(DESTDIR)$(sysconfdir)
+	ginstall -d $(DESTDIR)$(sysconfdir)/init.d
 	ginstall -d $(DESTDIR)$(localstatedir)/$(GARNAME)
 	mv $(DESTDIR)$(bindir)/denyhosts.py $(DESTDIR)$(bindir)/denyhosts
 	rm $(DESTDIR)$(datadir)/$(GARNAME)/README.txt
@@ -57,17 +56,18 @@
 	mv $(DESTDIR)$(datadir)/$(GARNAME)/CHANGELOG.txt $(DOCDEST)/changelog
 	mv $(DESTDIR)$(datadir)/$(GARNAME)/denyhosts.cfg-dist \
 		$(DESTDIR)$(sysconfdir)/denyhosts.cfg
+	ginstall -m 0755 $(FILEDIR)/cswdenyhosts $(DESTDIR)$(sysconfdir)/init.d
 
 	#Adjust config to match Solaris paths + our package paths
 	gsed -i \
 		-e 's,/var/log/secure,path to ssh log,' \
 		-e 's,/usr/share/denyhosts/data,$(localstatedir)/$(GARNAME),' \
-		-e 's,/var/lock/subsys/denyhosts,/var/run/denyhosts.pid,' \
-		-e 's,/var/log/denyhosts,$(localestatedir)/$(GARNAME)/$(GARNAME).log,' \
+		-e 's,/var/lock/subsys/denyhosts,/var/opt/csw/run/denyhosts.pid,' \
+		-e 's,/var/log/denyhosts,$(localstatedir)/$(GARNAME)/$(GARNAME).log,' \
 		$(DESTDIR)$(sysconfdir)/denyhosts.cfg
 
 	gsed -i \
-		-e 's,denyhosts.cfg,$(sysconfdir)/denyhosts.cfg' \
+		-e 's,denyhosts.cfg,$(sysconfdir)/denyhosts.cfg,' \
 		$(DESTDIR)/opt/csw/lib/python/site-packages/DenyHosts/constants.py
 
 	#Adjust daemon-control-dist wrapper script to match our package paths

Added: csw/mgar/pkg/denyhosts/trunk/files/cswdenyhosts
===================================================================
--- csw/mgar/pkg/denyhosts/trunk/files/cswdenyhosts	                        (rev 0)
+++ csw/mgar/pkg/denyhosts/trunk/files/cswdenyhosts	2009-11-02 08:42:21 UTC (rev 7070)
@@ -0,0 +1,67 @@
+#! /bin/sh 
+#
+# Init script for denyhosts
+#
+
+PATH=/opt/csw/bin:$PATH
+NAME=denyhosts
+PROG=/opt/csw/bin/$NAME
+PYTHON=/opt/csw/bin/python
+PIDFILE=/var/opt/csw/run/denyhosts.pid
+CONFIG=/etc/opt/csw/denyhosts.cfg
+FLAGS="--purge --config=$CONFIG"
+
+# start denyhosts
+start() {
+  test -x $PYTHON || exit 5
+  test -f $CONFIG || { 
+    echo "$CONFIG does not exist!" 
+    exit 1
+  }
+
+  HOSTS_DENY=`grep '^HOSTS_DENY' $CONFIG  | cut -d = -f 2`
+  test -f $HOSTS_DENY || touch $HOSTS_DENY
+
+  if [ -f $PIDFILE ]; then
+    pid=`cat $PIDFILE`
+    if kill -0 "$pid" > /dev/null; then
+      echo "$NAME already running"
+      return
+    else
+      echo "Removing stale PID file $PIDFILE."
+      rm -f $PIDFILE
+    fi
+  fi
+  $PYTHON $PROG --daemon --purge --config=$CONFIG
+  [ $? -eq 0 ] && echo "started $NAME" || echo "start $NAME failed"
+}
+
+# stop denyhosts
+stop() {
+  if [ -f $PIDFILE ]; then
+    pid=`cat $PIDFILE`
+    if kill -0 "$pid" > /dev/null; then
+       kill `cat $PIDFILE`
+       [ $? -eq 0 ] && echo "stopped $NAME" || echo "stop $NAME failed"
+    else
+       echo "stop $NAME failed"
+       rm -f $PIDFILE
+    fi
+  fi
+}
+
+# start or stop denyhosts
+case "$1" in
+  start)
+        start
+        ;;
+  stop)
+        stop
+        ;;
+  *)
+        echo "Usage: $NAME {start|stop}" >&2
+        exit 3
+        ;;
+esac
+
+exit 0


Property changes on: csw/mgar/pkg/denyhosts/trunk/files/cswdenyhosts
___________________________________________________________________
Added: svn:executable
   + *


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list