From 70a670d245ccfc6d7e5ee156e649dc4beaaf69b2 Mon Sep 17 00:00:00 2001
From: Greg Price <price@mit.edu>
Date: Wed, 1 Oct 2008 19:31:23 -0400
Subject: [PATCH] sipb-xen-database-server: fix init script, expand
 pg_hba.conf

svn path=/trunk/packages/sipb-xen-database/; revision=989
---
 debian/changelog                                |    7 +++
 debian/sipb-xen-database-server.init            |   66 +++++------------------
 server/etc/postgresql/8.3/main/pg_hba.conf.mako |    5 +-
 3 files changed, 23 insertions(+), 55 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 657db3e..abde326 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+sipb-xen-database (10.25) unstable; urgency=low
+
+  * add remote and console to pg_hba.conf template
+  * fix init script so it works
+
+ -- Greg Price <price@mit.edu>  Wed, 01 Oct 2008 19:30:26 -0400
+
 sipb-xen-database (10.24) unstable; urgency=low
 
   * Update postgresql.conf for Hardy
diff --git a/debian/sipb-xen-database-server.init b/debian/sipb-xen-database-server.init
index be4831b..8c9a4b3 100644
--- a/debian/sipb-xen-database-server.init
+++ b/debian/sipb-xen-database-server.init
@@ -9,69 +9,31 @@
 # Description:       
 ### END INIT INFO
 
-# Author: SIPB Xen Project <sipb-xen@mit.edu>
-
-# Do NOT "set -e"
-
-# PATH should only include /usr/* if it runs after the mountnfs.sh script
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
-DESC="The sipb-xen database server"
-NAME=sipb-xen-database-server
-
-
-
-SCRIPTNAME=/etc/init.d/$NAME
+PACKAGE=sipb-xen-database-tables
 
 # Exit if the package is not installed
-[ -x "/usr/bin/sipb-xen-database-tabales" ] || exit 0
-
-# Read configuration variable file if it is present
-[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+[ -x "/usr/bin/sipb-xen-database-tables" ] || exit 0
 
-# Load the VERBOSE setting and other rcS variables
 . /lib/init/vars.sh
-
-# Define LSB log_* functions.
-# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
 . /lib/lsb/init-functions
 
 gen_config()
 {
-    for i in /etc/postgresql/8.3/main/pg_hba.conf
-             ; do
-        mako-render $i.mako > $i
-    done
-}
-
-do_reload()
-{
-	gen_config
-
+  for i in /etc/postgresql/8.3/main/pg_hba.conf
+  do mako-render $i.mako > $i
+  done
 }
 
 case "$1" in
-  start)
-	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
-gen_config
-	;;
+  start|reload|force-reload|restart)
+    log_begin_msg "Reloading config for $PACKAGE"
+    gen_config
+    log_end_msg $?
+    /etc/init.d/postgresql-8.3 "$1"
+    ;;
   stop)
-	;;
-  reload|force-reload)
-	log_daemon_msg "Reloading $DESC" "$NAME"
-	do_reload
-	log_end_msg $?
-	;;
-  restart)
-	  *)
-	  	# Failed to stop
-		log_end_msg 1
-		;;
-	esac
-	;;
+    ;;
   *)
-	echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
-	exit 3
-	;;
+    log_success_msg "Usage: /etc/init.d/$PACKAGE {start|reload|force-reload|restart|stop}"
+    ;;
 esac
-
-:
diff --git a/server/etc/postgresql/8.3/main/pg_hba.conf.mako b/server/etc/postgresql/8.3/main/pg_hba.conf.mako
index cc02053..ea5fde5 100644
--- a/server/etc/postgresql/8.3/main/pg_hba.conf.mako
+++ b/server/etc/postgresql/8.3/main/pg_hba.conf.mako
@@ -82,7 +82,6 @@ local   all         all                               ident sameuser
 host    all         all         127.0.0.1/32          md5
 # IPv6 local connections:
 host    all         all         ::1/128               md5
-host	${cfg.db.dbname}	${cfg.db.user}	${cfg.db.ip}/32	trust
-% for h in cfg.hosts:
-host	${cfg.db.dbname}	${cfg.db.user}	${h.ip}/32	trust
+% for m in cfg.hosts + [cfg.db, cfg.remote, cfg.console]:
+host	${cfg.db.dbname}	${cfg.db.user}	${m.ip}/32	trust
 % endfor
-- 
1.7.9.5