Merge invirt-database-server into invirt-database. 0.2.0
authorEvan Broder <broder@mit.edu>
Sat, 28 Feb 2009 00:48:30 +0000 (19:48 -0500)
committerEvan Broder <broder@mit.edu>
Sat, 28 Feb 2009 00:48:30 +0000 (19:48 -0500)
I...think this works, but I'm not making any promises.

svn path=/trunk/packages/invirt-database/; revision=2218

12 files changed:
debian/changelog
debian/control
debian/invirt-database-server.init [new file with mode: 0644]
debian/invirt-database-server.install [new file with mode: 0644]
debian/invirt-database-server.postinst [new file with mode: 0644]
debian/invirt-database-server.prerm [new file with mode: 0644]
debian/invirt-database.install [new file with mode: 0644]
debian/rules
debian/transform_postgresql.conf.invirt [new file with mode: 0755]
invirt-database-tables [new file with mode: 0755]
pg_hba.conf.mako [new file with mode: 0644]
postgresql-8.3.invirt [new file with mode: 0755]

index 8d71f91..58ee681 100644 (file)
@@ -1,3 +1,9 @@
+invirt-database (0.2.0) unstable; urgency=low
+
+  * Merge invirt-database-server into invirt-database.
+
+ -- Evan Broder <broder@mit.edu>  Fri, 27 Feb 2009 19:38:55 -0500
+
 invirt-database (0.1.9) unstable; urgency=low
 
   * Make get*Quotas idempotent
index f491215..a3369d7 100644 (file)
@@ -3,8 +3,9 @@ Section: net
 Priority: extra
 Maintainer: Invirt project <invirt@mit.edu>
 Build-Depends: cdbs (>= 0.4.23-1.1), debhelper (>= 4.2.0),
- python-all-dev (>=2.3.5-11), python-support (>= 0.5.3),
- python-setuptools, python-debian, python-apt
+ config-package-dev, postgresql-8.3, python-all-dev (>=2.3.5-11),
+ python-support (>= 0.5.3), python-setuptools, python-debian,
+ python-apt
 Standards-Version: 3.8.0
 
 Package: invirt-database
@@ -15,3 +16,13 @@ Provides: ${python:Provides}
 XB-Python-Version: ${python:Versions}
 Description: Installs the Invirt database schema files
  This contains the Python modules to access the Invirt database
+
+Package: invirt-database-server
+Architecture: all
+Depends: ${misc:Depends}, ${python:Depends}, postgresql-8.3,
+ python-sqlalchemy, python-psycopg2, invirt-database, adduser,
+ invirt-base
+Provides: ${diverted-files}
+Conflicts: ${diverted-files}
+Description: Installs the Invirt database server
+ This tracks all the user VMs and is accessed from the VM host
diff --git a/debian/invirt-database-server.init b/debian/invirt-database-server.init
new file mode 100644 (file)
index 0000000..f3074ca
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides:          invirt-database-server
+# Required-Start:    $local_fs $remote_fs
+# Required-Stop:     $local_fs $remote_fs
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Invirt database server
+# Description:       
+### END INIT INFO
+
+PACKAGE=invirt-database-server
+PARENTPACKAGE=postgresql-8.3
+GEN_FILES=/etc/postgresql/8.3/main/pg_hba.conf
+
+dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0
+
+. /lib/init/config-init.sh
+config_init "$1"
diff --git a/debian/invirt-database-server.install b/debian/invirt-database-server.install
new file mode 100644 (file)
index 0000000..89661c5
--- /dev/null
@@ -0,0 +1,3 @@
+postgresql-8.3.invirt etc/init.d
+pg_hba.conf.mako etc/postgresql/8.3/main
+invirt-database-tables usr/bin
diff --git a/debian/invirt-database-server.postinst b/debian/invirt-database-server.postinst
new file mode 100644 (file)
index 0000000..79fe70c
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/sh
+# postinst script for invirt-database-server
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+# Note that by moving this above our generated code we could run into significant problems
+# if we happened to start a daemon, and use debconf
+# We move this up here because we need the diversion of postgresql.conf to happen before we create tables
+
+#DEBHELPER#
+
+
+case "$1" in
+    configure)
+        #Don't create users on upgrade
+        if [ -z "$2" ]; then
+            # Don't fail if the user/database already exists
+            su postgres -c 'createuser invirt -S -d -R'    || true
+            su postgres -c 'createdb invirt -O invirt'   || true
+            adduser --system invirt
+        fi
+       invoke-rc.d postgresql-8.3 restart
+        su invirt -s /bin/sh -c 'invirt-database-tables create'
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+exit 0
+
+
diff --git a/debian/invirt-database-server.prerm b/debian/invirt-database-server.prerm
new file mode 100644 (file)
index 0000000..e27d6eb
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+# prerm script for invirt-database-server
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|deconfigure)
+
+        # This will destroy data -- do we want to do this?
+        # su postgres -c 'dropdb invirt'
+        # su postgres -c 'dropuser invirt'
+        deluser invirt
+    ;;
+
+    upgrade|failed-upgrade)
+    ;;
+
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
diff --git a/debian/invirt-database.install b/debian/invirt-database.install
new file mode 100644 (file)
index 0000000..84cc1ed
--- /dev/null
@@ -0,0 +1 @@
+debian/tmp/* .
index 89a5fd6..d2e9b8f 100755 (executable)
@@ -2,8 +2,17 @@
 
 DEB_PYTHON_SYSTEM=pysupport
 
+DEB_DIVERT_EXTENSION = .invirt
+
+DEB_TRANSFORM_FILES_invirt-database-server += \
+       /etc/postgresql/8.3/main/postgresql.conf.invirt
+
+DEB_DIVERT_FILES_invirt-database-server += \
+       /etc/init.d/postgresql-8.3.invirt
+
 include /usr/share/cdbs/1/rules/debhelper.mk
 include /usr/share/cdbs/1/class/python-distutils.mk
+include /usr/share/cdbs/1/rules/config-package.mk
 
 clean::
        rm -rf invirt.database.egg-info
diff --git a/debian/transform_postgresql.conf.invirt b/debian/transform_postgresql.conf.invirt
new file mode 100755 (executable)
index 0000000..57ea82a
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/perl -0p
+
+s/^#?listen_addresses = '[^']*'(.*)$/listen_addresses = '*'$1/m or die;
+s/^#?port = [0-9]*(.*)$/port = 5432$1/m or die;
diff --git a/invirt-database-tables b/invirt-database-tables
new file mode 100755 (executable)
index 0000000..78c7ab4
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+from invirt import database
+import sys
+
+def usage():
+    print >>sys.stderr, "Usage: %s [create|drop]" %(sys.argv[0],)
+    sys.exit(-1)
+
+if len(sys.argv) == 1:
+    usage()
+
+def create():
+    database.meta.create_all()
+    session = database.session()
+    session.begin()
+    if not database.Type.query.get('linux-hvm'):
+        session.save(database.Type(type_id='linux-hvm', description='HVM',
+                                   hvm='t', apic='t', acpi='t', pae='t'))
+    if not database.Type.query.get('linux'):
+        session.save(database.Type(type_id='linux', description='ParaVM',
+                                   hvm='f', apic='f', acpi='f', pae='f'))
+    session.commit()
+
+database.connect()
+
+if sys.argv[1] == "create":
+    create()
+elif sys.argv[1] == "drop":
+    database.meta.drop_all()
+else:
+    usage()
diff --git a/pg_hba.conf.mako b/pg_hba.conf.mako
new file mode 100644 (file)
index 0000000..c79e124
--- /dev/null
@@ -0,0 +1,83 @@
+<% from invirt.config import structs as cfg %>\
+# PostgreSQL Client Authentication Configuration File
+# ===================================================
+#
+# Refer to the PostgreSQL Administrator's Guide, chapter "Client
+# Authentication" for a complete description.  A short synopsis
+# follows.
+#
+# This file controls: which hosts are allowed to connect, how clients
+# are authenticated, which PostgreSQL user names they can use, which
+# databases they can access.  Records take one of these forms:
+#
+# local      DATABASE  USER  METHOD  [OPTION]
+# host       DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
+# hostssl    DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
+# hostnossl  DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
+#
+# (The uppercase items must be replaced by actual values.)
+#
+# The first field is the connection type: "local" is a Unix-domain socket,
+# "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an
+# SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket.
+#
+# DATABASE can be "all", "sameuser", "samerole", a database name, or
+# a comma-separated list thereof.
+#
+# USER can be "all", a user name, a group name prefixed with "+", or
+# a comma-separated list thereof.  In both the DATABASE and USER fields
+# you can also write a file name prefixed with "@" to include names from
+# a separate file.
+#
+# CIDR-ADDRESS specifies the set of hosts the record matches.
+# It is made up of an IP address and a CIDR mask that is an integer
+# (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that specifies
+# the number of significant bits in the mask.  Alternatively, you can write
+# an IP address and netmask in separate columns to specify the set of hosts.
+#
+# METHOD can be "trust", "reject", "md5", "crypt", "password",
+# "krb5", "ident", or "pam".  Note that "password" sends passwords
+# in clear text; "md5" is preferred since it sends encrypted passwords.
+#
+# OPTION is the ident map or the name of the PAM service, depending on METHOD.
+#
+# Database and user names containing spaces, commas, quotes and other special
+# characters must be quoted. Quoting one of the keywords "all", "sameuser" or
+# "samerole" makes the name lose its special character, and just match a
+# database or username with that name.
+#
+# This file is read on server startup and when the postmaster receives
+# a SIGHUP signal.  If you edit the file on a running system, you have
+# to SIGHUP the postmaster for the changes to take effect.  You can use
+# "pg_ctl reload" to do that.
+
+# Put your actual configuration here
+# ----------------------------------
+#
+# If you want to allow non-local connections, you need to add more
+# "host" records. In that case you will also need to make PostgreSQL listen
+# on a non-local interface via the listen_addresses configuration parameter,
+# or via the -i or -h command line switches.
+#
+
+
+
+
+# DO NOT DISABLE!
+# If you change this first entry you will need to make sure that the
+# database
+# super user can access the database using some other method.
+# Noninteractive
+# access to all databases is required during automatic maintenance
+# (autovacuum, daily cronjob, replication, and similar tasks).
+#
+# Database administrative login by UNIX sockets
+local   all         postgres                          ident sameuser
+
+# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
+
+# "local" is for Unix domain socket connections only
+local   all         all                               ident sameuser
+% for m in cfg.hosts + [cfg.db, cfg.remote, cfg.console]:
+host   ${cfg.db.dbname}        ${cfg.db.user}  ${m.ip}/32      trust
+% endfor
diff --git a/postgresql-8.3.invirt b/postgresql-8.3.invirt
new file mode 100755 (executable)
index 0000000..1e8ca4d
--- /dev/null
@@ -0,0 +1,29 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          postgresql postgresql-8.3
+# Required-Start:    $local_fs $remote_fs $network $time
+# Required-Stop:     $local_fs $remote_fs $network $time
+# Should-Start:      $syslog
+# Should-Stop:       $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: PostgreSQL 8.3 RDBMS server
+# Description:       This script proxies requests to the default postgresql-8.3,
+#                    except for restart, which it translates to a stop request,
+#                    and then a start request, so that PostgreSQL is shut down
+#                    with a fast shutdown
+### END INIT INFO
+
+case "$1" in
+  restart)
+        invoke-rc.d postgresql-8.3.invirt-orig stop
+        invoke-rc.d postgresql-8.3.invirt-orig start
+        exit $?
+       ;;
+  *)
+        invoke-rc.d postgresql-8.3.invirt-orig "$1"
+        exit $?
+       ;;
+esac
+
+: