Index: package_tags/invirt-console-host/0.0.3/debian/changelog
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/changelog	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/changelog	(revision 1214)
@@ -0,0 +1,120 @@
+invirt-console-host (0.0.3) unstable; urgency=low
+
+  * make initscript even shorter, with code now provided by sipb-xen-base
+
+ -- Greg Price <price@mit.edu>  Fri, 24 Oct 2008 07:07:46 -0400
+
+invirt-console-host (0.0.2) unstable; urgency=low
+
+  * make initscript start conserver on start/restart, not just reload
+  * drastically shorten initscript to current Invirt best practice,
+    in hopes that such dumb bugs can't hide so easily
+
+ -- Greg Price <price@mit.edu>  Fri, 24 Oct 2008 03:33:32 -0400
+
+invirt-console-host (0.0.1) unstable; urgency=low
+
+  * sipb-xen -> invirt
+  * -server -> -host while we're at it
+
+ -- Greg Price <price@mit.edu>  Fri, 24 Oct 2008 01:23:56 -0400
+
+sipb-xen-console-server (2.8) unstable; urgency=low
+
+  * Create a dummy console entry that exists by default so that conserver
+    won't quit if no consoles are defined.
+
+ -- Evan Broder <broder@mit.edu>  Tue, 14 Oct 2008 03:10:28 -0400
+
+sipb-xen-console-server (2.7) unstable; urgency=low
+
+  * Don't run conserver as root; use sudo instead
+
+ -- Evan Broder <broder@mit.edu>  Tue, 14 Oct 2008 02:38:46 -0400
+
+sipb-xen-console-server (2.06.3) unstable; urgency=low
+
+  * Running conserver as root so it can run xm console
+
+ -- Evan Broder <broder@mit.edu>  Tue, 14 Oct 2008 01:42:26 -0400
+
+sipb-xen-console-server (2.06.2) unstable; urgency=low
+
+  * No really - correctly divert conserver.cf
+
+ -- Evan Broder <broder@mit.edu>  Tue, 14 Oct 2008 01:39:09 -0400
+
+sipb-xen-console-server (2.06.1) unstable; urgency=low
+
+  * Correctly divert conserver.cf
+
+ -- Evan Broder <broder@mit.edu>  Tue, 14 Oct 2008 01:34:25 -0400
+
+sipb-xen-console-server (2.06) unstable; urgency=low
+
+  * generate config files using mako
+
+ -- Yang Zhang <y_z@mit.edu>  Thu, 14 Aug 2008 15:15:18 -0400
+
+sipb-xen-console-server (2.05) unstable; urgency=low
+
+  * use invirt.config rather than /etc/invirt/* directly
+  * get console-server hostname, db connection string from config
+  * generate conserver config piece needing console-server ip
+  * remove console 's_sipb-xen-dev', which doesn't work anyway
+  * all configured!
+
+ -- Greg Price <price@mit.edu>  Sat,  2 Aug 2008 18:58:59 -0400
+
+sipb-xen-console-server (2.04) unstable; urgency=low
+
+  * Get Kerberos realm from config rather than hardcoding.
+  * Don't hardcode host's hostname in conserver.cf.
+  * Update for current config-package-dev.
+
+ -- Greg Price <price@mit.edu>  Tue, 22 Jul 2008 01:32:04 -0400
+
+sipb-xen-console-server (2.03) unstable; urgency=low
+
+  * Multiplex consoles on multiple hosts.
+
+ -- Greg Price <price@mit.edu>  Sun, 13 Jul 2008 08:35:17 -0400
+
+sipb-xen-console-server (2.02) unstable; urgency=low
+
+  * And...xm isn't in the path, so give a full path
+
+ -- Evan Broder <broder@sipb-xen-dev.mit.edu>  Wed,  2 Apr 2008 04:48:53 -0400
+
+sipb-xen-console-server (2.01) unstable; urgency=low
+
+  * update-conserver script should reload, not restart
+
+ -- Evan Broder <broder@sipb-xen-dev.mit.edu>  Wed,  2 Apr 2008 04:43:12 -0400
+
+sipb-xen-console-server (2) unstable; urgency=low
+
+  * Use a python based update-conserver script that gets the list of
+    consoles from xm list
+  * Run the update-conserver script every 5 minutes to catch VMs that
+    are not started or stopped through the remctl interface
+
+ -- Evan Broder <broder@sipb-xen-dev.mit.edu>  Wed,  2 Apr 2008 04:32:58 -0400
+
+sipb-xen-console-server (1.0.2) unstable; urgency=low
+
+  * Also...make this package actually do something
+
+ -- Evan Broder <broder@sipb-xen-dev.mit.edu>  Wed,  2 Apr 2008 01:41:32 -0400
+
+sipb-xen-console-server (1.0.1) unstable; urgency=low
+
+  * Misnamed a file
+
+ -- Evan Broder <broder@sipb-xen-dev.mit.edu>  Wed,  2 Apr 2008 01:36:29 -0400
+
+sipb-xen-console-server (1) unstable; urgency=low
+
+  * Initial release.
+
+ -- SIPB Xen Project <sipb-xen@mit.edu>  Wed,  2 Apr 2008 00:27:12 -0400
Index: package_tags/invirt-console-host/0.0.3/debian/compat
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/compat	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/compat	(revision 1214)
@@ -0,0 +1,1 @@
+5
Index: package_tags/invirt-console-host/0.0.3/debian/control
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/control	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/control	(revision 1214)
@@ -0,0 +1,14 @@
+Source: invirt-console-host
+Section: servers
+Priority: important
+Maintainer: invirt@mit.edu
+Build-Depends: cdbs (>= 0.4.23-1.1), debhelper (>= 5), config-package-dev (>= 4.5~)
+Standards-Version: 3.7.2
+
+Package: invirt-console-host
+Architecture: all
+Provides: ${diverted-files}
+Conflicts: ${diverted-files}
+Depends: ${shlibs:Depends}, ${misc:Depends}, conserver-server, remctl-client, sipb-xen-base
+Description: SIPB Xen serial console server server
+  This configures the VMM for the server-side of the console server
Index: package_tags/invirt-console-host/0.0.3/debian/control.in
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/control.in	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/control.in	(revision 1214)
@@ -0,0 +1,14 @@
+Source: invirt-console-host
+Section: servers
+Priority: important
+Maintainer: invirt@mit.edu
+Build-Depends: @cdbs@
+Standards-Version: 3.7.2
+
+Package: invirt-console-host
+Architecture: all
+Provides: ${diverted-files}
+Conflicts: ${diverted-files}
+Depends: ${shlibs:Depends}, ${misc:Depends}, conserver-server, remctl-client, sipb-xen-base
+Description: SIPB Xen serial console server server
+  This configures the VMM for the server-side of the console server
Index: package_tags/invirt-console-host/0.0.3/debian/copyright
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/copyright	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/copyright	(revision 1214)
@@ -0,0 +1,16 @@
+This software was written as part of the Invirt project <invirt@mit.edu>.
+
+Copyright :
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+On Debian systems, the complete text of the GNU General Public License
+can be found in the file /usr/share/common-licenses/GPL.
Index: package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.cron.d
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.cron.d	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.cron.d	(revision 1214)
@@ -0,0 +1,8 @@
+#
+# cron-jobs for invirt-console-host
+# Refresh the list of active VM consoles
+#
+
+MAILTO=root
+
+*/5 * * * * root python /usr/sbin/invirt-update-conserver
Index: package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.init
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.init	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.init	(revision 1214)
@@ -0,0 +1,19 @@
+#! /bin/bash
+### BEGIN INIT INFO
+# Provides:          invirt-console-host
+# 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: conserver config from invirt-config for Invirt host
+# Description:       
+### END INIT INFO
+
+PACKAGE=invirt-console-host
+PARENTPACKAGE=conserver-server
+GEN_FILES=/etc/conserver/invirt-genconfig.cf
+
+dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0
+
+. /lib/init/config-init.sh
+config_init $1
Index: package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.install
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.install	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.install	(revision 1214)
@@ -0,0 +1,1 @@
+files/* .
Index: package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.postinst
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.postinst	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.postinst	(revision 1214)
@@ -0,0 +1,44 @@
+#!/bin/sh
+# postinst script for invirt-console-host
+#
+# 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
+
+
+case "$1" in
+    configure)
+        cat >>/etc/sudoers <<EOF
+### BEGIN invirt-console-host
+conservr ALL=(ALL) NOPASSWD: /usr/sbin/xm console d_*
+### END invirt-console-host
+EOF
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst 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
Index: package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.prerm
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.prerm	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/invirt-console-host.prerm	(revision 1214)
@@ -0,0 +1,39 @@
+#!/bin/sh
+# prerm script for invirt-console-host
+#
+# 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|upgrade|deconfigure)
+        perl -i.bak -ne 's%^### (BEGIN|END) invirt-console-host\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers
+    ;;
+
+    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
Index: package_tags/invirt-console-host/0.0.3/debian/rules
===================================================================
--- package_tags/invirt-console-host/0.0.3/debian/rules	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/debian/rules	(revision 1214)
@@ -0,0 +1,10 @@
+#!/usr/bin/make -f
+
+DEB_AUTO_UPDATE_DEBIAN_CONTROL = 1
+DEB_DIVERT_EXTENSION = .invirt
+DEB_DIVERT_FILES_invirt-console-host += \
+	/etc/conserver/conserver.cf.invirt \
+	/etc/conserver/server.conf.invirt
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/rules/config-package.mk
Index: package_tags/invirt-console-host/0.0.3/files/etc/conserver/conserver.cf.invirt
===================================================================
--- package_tags/invirt-console-host/0.0.3/files/etc/conserver/conserver.cf.invirt	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/files/etc/conserver/conserver.cf.invirt	(revision 1214)
@@ -0,0 +1,25 @@
+config * {
+	sslrequired yes;
+}
+
+# If no consoles are defined, as is the case when the host first boots
+# up, conserver will quit. This keeps it running.
+#
+# Should someone create a VM called dummy-console, their VM will
+# shadow over this one.
+console dummy-console {
+        master localhost;
+        type noop;
+}
+
+default * {
+	logfile /var/log/conserver/&.log;
+	timestamp "1lab";
+	rw *;
+	type exec;
+	exec sudo xm console d_f;
+	execsubst f=cs;
+}
+
+#include /etc/conserver/invirt-genconfig.cf
+#include /etc/conserver/invirt-consoles.cf
Index: package_tags/invirt-console-host/0.0.3/files/etc/conserver/invirt-genconfig.cf.mako
===================================================================
--- package_tags/invirt-console-host/0.0.3/files/etc/conserver/invirt-genconfig.cf.mako	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/files/etc/conserver/invirt-genconfig.cf.mako	(revision 1214)
@@ -0,0 +1,6 @@
+<% from invirt.config import structs as cfg %>\
+access * {
+       trusted 127.0.0.1;
+       trusted ${cfg.console.ip};
+       limited *;
+}
Index: package_tags/invirt-console-host/0.0.3/files/etc/conserver/server.conf.invirt
===================================================================
--- package_tags/invirt-console-host/0.0.3/files/etc/conserver/server.conf.invirt	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/files/etc/conserver/server.conf.invirt	(revision 1214)
@@ -0,0 +1,2 @@
+OPTS='-p 3109  '
+ASROOT=
Index: package_tags/invirt-console-host/0.0.3/files/usr/sbin/invirt-update-conserver
===================================================================
--- package_tags/invirt-console-host/0.0.3/files/usr/sbin/invirt-update-conserver	(revision 1214)
+++ package_tags/invirt-console-host/0.0.3/files/usr/sbin/invirt-update-conserver	(revision 1214)
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+import sipb_xen_database
+import subprocess
+import os
+import socket
+from invirt.config import structs as config
+
+sipb_xen_database.connect(config.db.uri)
+
+def live_vms():
+    p = subprocess.Popen(['/usr/sbin/xm', 'list'], stdout=subprocess.PIPE)
+    p.wait()
+    output = p.stdout.read()
+    vms = [x.split()[0][2:] for x in output.splitlines() if x.startswith('d_')]
+    return vms
+
+def reload_conserver():
+    p = subprocess.Popen(['/etc/init.d/conserver-server', 'reload'], stdout=subprocess.PIPE)
+    p.wait()
+
+if __name__ == '__main__':
+    hostname = socket.getfqdn().lower()
+    realm = config.authn[0].realm
+    principal = 'host/'+hostname+'@'+realm
+    conftext = '\n'.join('console %s { master %s; }' % (vm, hostname)
+                         for vm in live_vms())
+    f = open('/etc/conserver/invirt-consoles.cf', 'w')
+    f.write(conftext)
+    f.close()
+    reload_conserver()
+    subprocess.call(['/usr/bin/kinit', '-k', '-t', '/etc/krb5.keytab',
+                     principal])
+    subprocess.call(['/usr/bin/remctl', config.console.hostname,
+                     'console', 'update', conftext])
