Sistema di setup

Leonardo Robol [2010-05-20 14:32]
Sistema di setup
Filename
README
pywhois
pywhoisd.conf
pywhoisd.db
pywhoisd.py
setup.py
diff --git a/README b/README
new file mode 100644
index 0000000..6dbdfc7
--- /dev/null
+++ b/README
@@ -0,0 +1,14 @@
+Pywhoisd is a damone that act like a whois server. It is designed for a
+small network that don't need a complex database.
+
+It can be installed system-wide with the command:
+
+  python setup.py install
+
+and then it can be run at boot time with (in Debian or Ubuntu)
+
+  update-rc.d pywhois defaults
+
+Improvements are welcome. :)
+
+Leonardo Robol <leo@robol.it>
\ No newline at end of file
diff --git a/pywhois b/pywhois
new file mode 100755
index 0000000..f4d15f8
--- /dev/null
+++ b/pywhois
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides:          pywhoisd
+# Required-Start:    $local_fs $network$ $syslog$
+# Required-Stop:
+# Default-Start:     S
+# Default-Stop:
+# Short-Description: pywhoisd
+# Description:       Whois daemon
+### END INIT INFO
+
+. /lib/lsb/init-functions
+
+[ -f /etc/default/rcS ] && . /etc/default/rcS
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+PROGRAM="/usr/bin/pywhoisd.py"
+PIDFILE="/var/run/pywhoisd.pid"
+
+test -x $PROGRAM || exit 0
+
+case "$1" in
+  start)
+	log_begin_msg "Starting pywhoisd"
+	start-stop-daemon --exec $PROGRAM --make-pidfile -p $PIDFILE --start --background
+	log_end_msg $?
+	;;
+  stop)
+	log_begin_msg "Stopping pywhoisd"
+	start-stop-daemon --stop -p $PIDFILE
+	log_end_msg $?
+	;;
+  force-reload|restart)
+	$0 stop
+	$0 start
+	;;
+  *)
+	log_success_msg "Usage: /etc/init.d/sensors {start|stop|restart|force-reload}"
+	exit 1
+esac
+
+exit 0
diff --git a/pywhoisd.conf b/pywhoisd.conf
index e729322..12b5f07 100644
--- a/pywhoisd.conf
+++ b/pywhoisd.conf
@@ -7,7 +7,7 @@

 # This sets the file with the definition of the net
 # to be served
-database_file = pywhoisd.db;
+database_file = /etc/pywhoisd.db;

 # This sets the welcome banner that will be displayed to user
 # contacting us on port 43
diff --git a/pywhoisd.db b/pywhoisd.db
index e7aad32..d21afa7 100644
--- a/pywhoisd.db
+++ b/pywhoisd.db
@@ -32,7 +32,7 @@ net 6.15.1.0/24 {
   ns = 6.20.10.1;
 };

-net 6.11.1.0/24 {
+net 6.11.0.0/24 {
   name = Freschi GNet;
   owner = Luca Freschi <l.freschi@yahoo.it>;
   ns = 6.20.10.1;
@@ -40,7 +40,7 @@ net 6.11.1.0/24 {

 net 6.0.0.0/8 {
   name = GNET;
-  owner = undefined;
+  owner = GNET;
   ns = 6.20.10.1, 6.22.22.22;
 };

@@ -51,6 +51,12 @@ domain leo.gnet {
   ns = 6.20.10.1;
 };

+
+
+#
+# Configurazione dei domini
+#
+
 domain ineff.gnet {
   name = Ineff Gnet;
   owner = Giorgio Mossa <mossa@ineff.gnet>;
@@ -71,6 +77,6 @@ domain lf.gnet {

 domain gnet {
   name = GNET;
-  owner = Undefined;
+  owner = GNET;
   ns = 6.20.10.1, 6.22.22.22;
 };
diff --git a/pywhoisd.py b/pywhoisd.py
index a51add4..a91ae37 100755
--- a/pywhoisd.py
+++ b/pywhoisd.py
@@ -14,7 +14,7 @@ if __name__ == "__main__":
     parser.add_option("-v", "--verbose", action="store_true",
                       default = False, help = "Print syslog to screen")
     parser.add_option("-c", "--config", dest="config_file",
-                      default="pywhoisd.conf",
+                      default="/etc/pywhoisd.conf",
                       help = "Set config file", metavar="CONFIG_FILE")
     parser.add_option("-p", "--port", dest="port",
                       help = "The listening port of the daemon", default = "43")
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..b0b43d9
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+
+from distutils.core import setup
+
+setup(name = 'pywhoisd',
+      version = '0.1',
+      description = 'pywhois daemon',
+      author = 'Leonardo Robol',
+      author_email = 'leo@robol.it',
+      url = 'http://poisson.phc.unipi.it/~robol/wordpress/pywhoisd/',
+      py_modules = [ 'pywhois', 'ipcalc' ],
+      data_files = [('/etc/init.d', ['pywhois']),
+                    ('/etc', ['pywhoisd.conf', 'pywhoisd.db']),
+                    ('/usr/bin', ['pywhoisd.py']) ],
+      )
ViewGit