Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/changelog
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/changelog	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/changelog	(revision 194)
@@ -0,0 +1,31 @@
+sipb-xen-remctl-auto (1.0.4) unstable; urgency=low
+
+  * Fix typos.
+
+ -- Anders Kaseorg <andersk@sipb-xen-dev.mit.edu>  Tue,  9 Oct 2007 04:47:37 -0400
+
+sipb-xen-remctl-auto (1.0.3) unstable; urgency=low
+
+  * Prepend d_ to database VMs.
+
+ -- Eric Price <ecprice@sipb-xen-dev.mit.edu>  Tue,  9 Oct 2007 02:34:56 -0400
+
+sipb-xen-remctl-auto (1.0.2) unstable; urgency=low
+
+  * Added web interface support code.
+  * Move things from /etc/remctl/sipb-xen-auto/bin to /usr/sbin
+  * Quoted lots of variables
+
+ -- Tim Abbott <tabbott@sipb-xen-dev.mit.edu>  Sun,  7 Oct 2007 17:23:40 -0400
+
+sipb-xen-remctl-auto (1.0.1) unstable; urgency=low
+
+  * Stop scaring me with unquoted variables.
+
+ -- Anders Kaseorg <andersk@mit.edu>  Sun, 05 Aug 2007 22:11:02 -0400
+
+sipb-xen-remctl-auto (1.0) unstable; urgency=low
+
+  * Initial release.
+
+ -- Tim Abbott <tabbott@mit.edu>  Sun, 15 Jul 2007 19:37:05 -0400
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/compat
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/compat	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/compat	(revision 194)
@@ -0,0 +1,1 @@
+4
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/control
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/control	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/control	(revision 194)
@@ -0,0 +1,12 @@
+Source: sipb-xen-remctl-auto
+Section: net
+Priority: extra
+Maintainer: SIPB Xen Project <sipb-xen@mit.edu>
+Build-Depends: cdbs (>= 0.4.23-1.1), debhelper (>= 4.1.0)
+Standards-Version: 3.7.2
+
+Package: sipb-xen-remctl-auto
+Architecture: all
+Depends: ${misc:Depends}, remctl-server
+Description: Installs the SIPB Xen automatic remctl management system
+ This is our automatic remctl configuration management system.
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/control.in
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/control.in	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/control.in	(revision 194)
@@ -0,0 +1,12 @@
+Source: sipb-xen-remctl-auto
+Section: net
+Priority: extra
+Maintainer: SIPB Xen Project <sipb-xen@mit.edu>
+Build-Depends: @cdbs@
+Standards-Version: 3.7.2
+
+Package: sipb-xen-remctl-auto
+Architecture: all
+Depends: ${misc:Depends}, remctl-server
+Description: Installs the SIPB Xen automatic remctl management system
+ This is our automatic remctl configuration management system.
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/copyright
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/copyright	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/copyright	(revision 194)
@@ -0,0 +1,3 @@
+This package was created for internal use of the SIPB Xen Project of
+the MIT Student Information Processing Board.  Ask tabbott@mit.edu if
+you have questions about redistribution.
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/rules
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/rules	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/rules	(revision 194)
@@ -0,0 +1,4 @@
+#!/usr/bin/make -f
+
+DEB_AUTO_UPDATE_DEBIAN_CONTROL = 1
+include /usr/share/cdbs/1/rules/debhelper.mk
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/sipb-xen-remctl-auto.install
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/sipb-xen-remctl-auto.install	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/debian/sipb-xen-remctl-auto.install	(revision 194)
@@ -0,0 +1,1 @@
+files/* .
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/cron.d/sipb-xen-remctl-auto
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/cron.d/sipb-xen-remctl-auto	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/cron.d/sipb-xen-remctl-auto	(revision 194)
@@ -0,0 +1,10 @@
+# /etc/cron.d/sipb-xen-remctl-auto: crontab entries for the sipb-xen-remctl-auto package
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+MAILTO=root
+UPDATE=/usr/sbin/remctl-update.sh
+
+@reboot         root    if [ -x "$UPDATE" ]; then nice -n10 "$UPDATE" all; fi
+* * * * */15       root    if [ -x "$UPDATE" ]; then nice -n10 "$UPDATE" all; fi
+
+# EOF
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/conf.d/sipb-xen-auto
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/conf.d/sipb-xen-auto	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/conf.d/sipb-xen-auto	(revision 194)
@@ -0,0 +1,1 @@
+include /etc/remctl/sipb-xen-auto/machine.d
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/conf.d/sipb-xen-web
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/conf.d/sipb-xen-web	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/conf.d/sipb-xen-web	(revision 194)
@@ -0,0 +1,10 @@
+web lvcreate /usr/sbin/sipb-xen-lvm /etc/remctl/acl/web
+web lvremove /usr/sbin/sipb-xen-lvm /etc/remctl/acl/web
+web lvrename /usr/sbin/sipb-xen-lvm /etc/remctl/acl/web
+web lvresize /usr/sbin/sipb-xen-lvm /etc/remctl/acl/web
+web vmboot /usr/sbin/sipb-xen-boot /etc/remctl/acl/web
+web register /usr/sbin/remctl-update.sh /etc/remctl/acl/web
+web moveregister /usr/sbin/remctl-update.sh /etc/remctl/acl/web
+web unregister /usr/sbin/remctl-update.sh /etc/remctl/acl/web
+web remctl-moira-update /usr/sbin/remctl-update.sh /etc/remctl/acl/web
+web listvms /usr/sbin/sipb-xen-listvms /etc/remctl/acl/web
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/README
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/README	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/README	(revision 194)
@@ -0,0 +1,66 @@
+This is Tim Abbott's initial draft at our automatic remctl
+configuration.
+
+/usr/sbin/remctl-update.sh is the magic script.  Run
+it with "all" as an argument, and it will update everything.
+
+The inputs to this system are as follows:
+
+/etc/remctl/sipb-xen-auto/acl/MACHINENAME
+
+  This directory contains files named MACHINENAME for each machine.
+These ACL files specify who is allowed to administer the machine.  You
+can use entries that are Kerberos principles, or entries of the form
+
+include /etc/remctl/sipb-xen-auto/moira-acl/sipb-xen
+
+to include AFS groups in ACLs.  To add a new machine to the system,
+you simply need to create /etc/remctl/sipb-xen-auto/acl/MACHINENAME
+and then run
+
+/usr/sbin/remctl-update.sh all
+
+Everything else is autogenerated from that information.
+
+
+Other files of interest:
+
+/etc/remctl/sipb-xen-auto/auto-machine-list
+
+  The list of machines that should have their remctl configuration
+files generated from the template.  This is generated from
+listing /etc/remctl/sipb-xen-auto/acl/*.
+ 
+/etc/remctl/sipb-xen-auto/auto-moira-list
+
+  The list of Athena AFS groups from which acl files should be
+generated.  The ACL files are placed in
+/etc/remctl/sipb-xen-auto/moira-acl/, and named GROUPNAME.  Ths list
+is generated by parsing the ACL files in /etc/remctl/sipb-xen-auto/acl/.
+
+
+This package also includes a crontab to run
+
+/usr/sbin/remctl-update.sh all
+
+every 15 minutes or so to keep our Moira mapping up to date.  One can
+request an update of our Moira mapping for group X by running
+
+/usr/sbin/remctl-update.sh moiragroup X
+
+The web interface should probably run this when it adds a group.  We
+may want to make this also available to users, but I've been lame.
+
+This package includes a remctl interface available to anyone to invoke
+the command:
+
+/usr/sbin/remctl-update.sh all
+
+using the following command from your favorite machine with remctl:
+
+remctl black-mesa.mit.edu remctl-auto-update all
+
+It requires no special permission to run; there is a potential DOS
+issue here, but I don't think it is serious.
+
+Thought should be put into how to ensure that the servers stay in sync.  
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/conf.template
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/conf.template	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/conf.template	(revision 194)
@@ -0,0 +1,9 @@
+create #MACHINENAME# #BINDIR#/dispatch.create.sh /etc/remctl/sipb-xen-auto/acl/#MACHINENAME#
+reboot #MACHINENAME# #BINDIR#/dispatch.reboot.sh /etc/remctl/sipb-xen-auto/acl/#MACHINENAME#
+destroy #MACHINENAME# #BINDIR#/dispatch.destroy.sh /etc/remctl/sipb-xen-auto/acl/#MACHINENAME#
+list #MACHINENAME# #BINDIR#/dispatch.list.sh /etc/remctl/sipb-xen-auto/acl/#MACHINENAME#
+shutdown #MACHINENAME# #BINDIR#/dispatch.shutdown.sh /etc/remctl/sipb-xen-auto/acl/#MACHINENAME#
+list-long #MACHINENAME# #BINDIR#/dispatch.list-long.sh /etc/remctl/sipb-xen-auto/acl/#MACHINENAME#
+vcpu-list #MACHINENAME# #BINDIR#/dispatch.vcpu-list.sh /etc/remctl/sipb-xen-auto/acl/#MACHINENAME#
+uptime #MACHINENAME# #BINDIR#/dispatch.uptime.sh /etc/remctl/sipb-xen-auto/acl/#MACHINENAME#
+vnc_get_port_auth #MACHINENAME# #BINDIR#/get_port /etc/remctl/acl/vnc
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.create.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.create.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.create.sh	(revision 194)
@@ -0,0 +1,1 @@
+link dispatch.sh
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.destroy.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.destroy.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.destroy.sh	(revision 194)
@@ -0,0 +1,1 @@
+link dispatch.sh
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.list-long.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.list-long.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.list-long.sh	(revision 194)
@@ -0,0 +1,1 @@
+link dispatch.sh
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.list.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.list.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.list.sh	(revision 194)
@@ -0,0 +1,1 @@
+link dispatch.sh
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.reboot-with-cdrom.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.reboot-with-cdrom.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.reboot-with-cdrom.sh	(revision 194)
@@ -0,0 +1,1 @@
+link dispatch.sh
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.reboot.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.reboot.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.reboot.sh	(revision 194)
@@ -0,0 +1,1 @@
+link dispatch.sh
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.sh	(revision 194)
@@ -0,0 +1,38 @@
+#!/bin/sh
+# dispatch-ACTION.sh MACHINE
+#
+# remctl should have already verified that the user is authorized to
+# control the machine.  So, we just need to execute the action requested.
+#
+# $0 and $1 come from the trusted remctl source.
+#
+# $2 and so on are user-provided, and thus sketchy.  I don't think we
+# need them for this script.
+
+ACTION=$(echo "$0" | awk -F'.' '{print $2}')
+ORIGMACHINE="$1"
+MACHINE="d_$ORIGMACHINE"
+
+case "$ACTION" in
+    list|vcpu-list|destroy|create|uptime|shutdown)
+        xm "$ACTION" "$MACHINE"
+	;;
+    reboot-with-cdrom)
+	xm shutdown "$MACHINE"
+	xm create sipb-database machine_name="$ORIGMACHINE" cdrom_image="$2"
+	;;
+    reboot)
+	if [ -n "$2" ]; then
+	    /usr/sbin/dispatch.reboot-with-cdrom.sh "$ORIGMACHINE" "$2" &
+	else
+	    xm reboot "$MACHINE"
+	fi
+	;;
+    list-long)
+	xm list --long "$MACHINE"
+	;;
+    *)
+        echo "ERROR: Invalid Command"
+        exit 1
+        ;;
+esac
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.shutdown.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.shutdown.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.shutdown.sh	(revision 194)
@@ -0,0 +1,1 @@
+link dispatch.sh
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.uptime.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.uptime.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.uptime.sh	(revision 194)
@@ -0,0 +1,1 @@
+link dispatch.sh
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.vcpu-list.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.vcpu-list.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/dispatch.vcpu-list.sh	(revision 194)
@@ -0,0 +1,1 @@
+link dispatch.sh
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/remctl-update.sh
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/remctl-update.sh	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/remctl-update.sh	(revision 194)
@@ -0,0 +1,124 @@
+#!/bin/sh
+DIR=/etc/remctl/sipb-xen-auto
+TEMPLATE=$DIR/conf.template
+MACHINEDIR=$DIR/machine.d
+MOIRADIR=$DIR/moira-acl
+MOIRATMP=$DIR/moira-tmp
+MACHINETMP=$DIR/machine-list-tmp
+AUTOMACHINELIST=$DIR/auto-machine-list
+AUTOMOIRALIST=$DIR/auto-moira-list
+BINDIR=/usr/sbin
+ACLDIR=$DIR/acl
+
+update_machine()
+{
+    machine="$1"
+    sed "s/#MACHINENAME#/$machine/g" "$TEMPLATE" | \
+	sed "s,#BINDIR#,$BINDIR,g" >| "$MACHINETMP"
+    if ! cmp -s "$MACHINEDIR/$machine" "$MACHINETMP"; then
+	mv "$MACHINETMP" "$MACHINEDIR/$machine"
+    else
+	rm -f "$MACHINETMP"
+    fi
+}
+
+update_moiragroup()
+{
+    group="$1"
+    # Should perhaps replace with LDAP, but fine for now.
+
+    # We should do more careful error checking so we don't take away
+    # all bits and delete the moira-acl files whenever there's an AFS
+    # outage.
+    pts membership system:"$group" -noauth | tail -n+2 | \
+	sed 's/\./\//' | \
+	sed 's/^  //' | \
+	sed 's/$/@ATHENA.MIT.EDU/g' >| "$MOIRATMP"
+    if test -s "$MOIRATMP"; then
+	if ! cmp -s "$MOIRADIR/$group" "$MOIRATMP"; then
+	    mv "$MOIRATMP" "$MOIRADIR/$group"
+	fi
+    else
+	if test -e "$MOIRADIR/$group"; then
+	    rm "$MOIRADIR/$group"
+	fi
+    fi
+    rm -f "$MOIRATMP"
+}
+
+check_machine_name()
+{
+    machinename="$1"
+    if ! perl -0e 'exit($ARGV[0] !~ /^[A-Za-z0-9][A-Za-z0-9._-]*$/)' -- "$machinename"; then
+	echo "Bad machine name"
+	exit 1
+    fi
+}
+
+case "$1" in
+    moiragroup)
+	update_moiragroup "$2"
+	;;
+
+    all_machines)
+        # update the remctl.conf definitions
+	for machine in `cat "$AUTOMACHINELIST"`; do
+	    update_machine "$machine"
+	done
+	;;
+    all_moira)
+        # update our moira ACL lists
+	for group in `cat "$AUTOMOIRALIST"`; do
+	    update_moiragroup "$group"
+	done
+	;;
+    auto_machine_list)
+        # update the list of maintained machines
+	/bin/ls "$ACLDIR" >| "$AUTOMACHINELIST"
+	;;
+    auto_moira_list)
+        # update the moira list-of-lists
+        # /bin/ls "$MOIRADIR" >| "$AUTOMOIRALIST" # BAD IDEA in case of outage
+
+	# This extracts the list of all moira lists we care about, and updates those.
+	grep -R moira "$ACLDIR/" /etc/remctl/acl/ | perl -pe 's/.*moira-acl\/(.*)/$1/g' >| "$AUTOMOIRALIST"
+	;;
+    unregister)
+	machine="$2"
+	check_machine_name "$machine"
+	rm -f "$ACLDIR"/"$machine"
+	rm -f "$MACHINEDIR"/"$machine"
+	"$0" web
+	;;
+    moveregister)
+        oldmachine="$2"
+        newmachine="$3"
+	check_machine_name "$oldmachine"
+	check_machine_name "$newmachine"
+        mv "$ACLDIR"/"$oldmachine" "$ACLDIR"/"$newmachine"
+        rm -f "$MACHINEDIR"/"$oldmachine"
+        "$0" web
+	;;
+    register)
+	machine="$2"
+	check_machine_name "$machine"
+	if [ -e "$ACLDIR"/"$machine" ]; then
+	    echo "Machine already registered"
+	    exit 1
+	fi
+	echo "include /etc/remctl/acl/web" > "$ACLDIR/$machine"
+	"$0" web
+	;;
+    web)
+	"$0" auto_machine_list
+	"$0" all_machines
+	;;	
+    remctl-moira-update|all)
+    	"$0" auto_machine_list
+	"$0" all_machines
+	"$0" auto_moira_list
+	"$0" all_moira
+	;;
+esac
+
+exit 0
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-boot
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-boot	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-boot	(revision 194)
@@ -0,0 +1,9 @@
+#!/bin/sh
+machine="$2"
+cdrom="$3"
+
+if [ -n "$cdrom" ]; then
+        xm create sipb-database machine_name="$machine" cdrom_image="$cdrom"
+else
+        xm create sipb-database machine_name="$machine"
+fi
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-listvms
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-listvms	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-listvms	(revision 194)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+xm uptime | sed -n 's/^d_// p'
Index: /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-lvm
===================================================================
--- /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-lvm	(revision 194)
+++ /package_tags/sipb-xen-remctl-auto/1.0.4/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-lvm	(revision 194)
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+import sys
+import os.path
+from subprocess import call, PIPE, Popen
+
+def check(b):
+    if not b:
+        exit(1)
+
+vg = "xenvg"
+prefix = "d_"
+
+subcommand = sys.argv[1]
+
+def ensureoff(machine):
+    # Make sure the machine is off, but we don't care about errors if it is already off.
+    rv = call(["/usr/sbin/xm", "destroy", prefix + machine],
+              stderr=PIPE)
+
+if subcommand == "lvcreate-all":
+    from sipb_xen_database import *
+    import re
+    connect('postgres://sipb-xen@sipb-xen-dev.mit.edu/sipb_xen')
+    for d in Disk.select():
+        check(re.match('^[A-Za-z0-9]+$', d.guest_device_name))
+        machine = Machine.get(d.machine_id)
+        check(re.match('^[A-Za-z0-9][A-Za-z0-9._-]*$', machine.name))
+        lvname = prefix + machine.name + "_" + d.guest_device_name
+        if not os.path.exists("/dev/%s/%s" % (vg, lvname)):
+            # LV doesn't exist
+            print >>sys.stderr, "Creating LV %s..." % (lvname,)
+            rv = call(["/sbin/lvcreate", "-L", str(d.size) + "M", "-n", lvname, vg])
+            if rv != 0:
+                print >>sys.stderr, "Error creating LV %s\n" %(lvname,)
+                sys.exit(1)
+else:
+    machine = sys.argv[2]
+    disk = sys.argv[3]
+    lvname = prefix + machine + "_" + disk
+    lvpath = "/dev/" + vg + "/" + lvname
+if subcommand == "lvremove":
+    rv = call(["/sbin/lvremove", "--force", lvpath])
+    ensureoff(machine)
+    if rv != 0:
+        print >>sys.stderr, "Error removing LV %s\n" %(lvname,)
+        sys.exit(1)
+elif subcommand == "lvresize":
+    size = sys.argv[4]
+    ensureoff(machine)
+    p = Popen(["/sbin/lvresize", "-L", size + "M", lvpath],
+              stdin=PIPE, stderr=PIPE)
+    print >> p.stdin, 'y'
+    err = p.stderr.read()
+    if p.wait() != 0 and 'matches existing size' not in err:
+        print >> sys.stderr, "Error resizing LV %s:\n" %(lvname,)
+        print >> sys.stderr, err
+        sys.exit(1)
+    print >> sys.stderr, err
+elif subcommand == "lvrename":
+    newmachine = sys.argv[4]
+    newlvname = prefix + newmachine + "_" + disk
+    ensureoff(machine)
+    ensureoff(newmachine)    
+    rv = call(["/sbin/lvrename", vg, lvname, newlvname])
+    if rv != 0:
+        print >>sys.stderr, "Error renaming LV %s\n" %(lvname,)
+        sys.exit(1)
+elif subcommand == "lvcreate":
+    size = sys.argv[4]
+    rv = call(["/sbin/lvcreate", "-L", size + "M", "-n", lvname, vg])
+    if rv != 0:
+        print >>sys.stderr, "Error creating LV %s\n" %(lvname,)
+        sys.exit(1)
+    
+
