--- /dev/null
+xvm-iscsi-config (0.0.1) unstable; urgency=low
+
+ * Initial Release.
+
+ -- Evan Broder <broder@mit.edu> Thu, 23 Oct 2008 22:16:55 -0400
--- /dev/null
+Source: xvm-iscsi-config
+Section: servers
+Priority: extra
+Maintainer: SIPB XVM Project <xvm@mit.edu>
+Build-Depends: cdbs, debhelper (>= 5), config-package-dev, open-iscsi
+Standards-Version: 3.8.0
+
+Package: xvm-iscsi-config
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, invirt-base, open-iscsi
+Description: iSCSI configuration for SIPB's XVM project
+ This package should be installed on all XVM host machines to
+ configure the iSCSI shared storage array.
--- /dev/null
+This package was created for the XVM project <xvm@mit.edu> of the MIT
+Student Information Processing Board.
+
+You may use it, etc, under the GNU GPL, version 2 or later.
--- /dev/null
+#!/usr/bin/make -f
+
+DEB_DIVERT_EXTENSION = .xvm
+
+DEB_DIVERT_FILES_xvm-iscsi-config += \
+ /etc/iscsi/iscsid.conf.xvm
+
+DEB_UPDATE_RCD_PARAMS_xvm-iscsi-config += defaults 20 80
+
+include /usr/share/cdbs/1/rules/config-package.mk
+include /usr/share/cdbs/1/rules/debhelper.mk
+
+common-build-indep:: debian/iscsid.conf.xvm.mako
+
+debian/iscsid.conf.xvm.mako: $(call debian_check_files,/etc/iscsi/iscsid.conf)
+ debian/transform_iscsid.conf.xvm.mako < $< > $@
--- /dev/null
+#!/usr/bin/perl -n
+BEGIN {
+ print <<'EOF';
+<%
+from invirt.config import structs as cfg
+%>
+EOF
+}
+
+s/^node.startup = manual/node.startup = automatic/m;
+# mako just generally doesn't deal well with lines that start with
+# hashes, so we'll strip them
+#
+# And empty lines too, just for cleanliness
+s/^#.*$//m;
+print unless /^$/;
+
+END {
+ print <<'EOF';
+node.session.auth.authmethod = CHAP
+node.session.auth.username = ${cfg.iscsi.username}
+node.session.auth.password = ${cfg.iscsi.password}
+
+discovery.sendtargets.auth.authmethod = CHAP
+discovery.sendtargets.auth.username = ${cfg.iscsi.username}
+discovery.sendtargets.auth.password = ${cfg.iscsi.password}
+EOF
+}
--- /dev/null
+#!/bin/sh
+
+set -e
+
+# Source debconf library
+. /usr/share/debconf/confmodule
+
+# Get IP address
+db_input high xvm-iscsi-config/address || true
+db_go || true
+# Get username
+db_input high xvm-iscsi-config/username || true
+db_go || true
+# Get password
+db_input high xvm-iscsi-config/password || true
+db_go || true
--- /dev/null
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: xvm-iscsi-config
+# 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: XVM iSCSI config
+# Description: Re-generate the iSCSI config for XVM's shared storage
+### END INIT INFO
+
+# Author: SIPB XVM Project <xvm@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="Re-generate the iSCSI config"
+NAME=xvm-iscsi-config
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# 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
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ for i in /etc/iscsi/iscsid.conf.xvm
+ do mako-render $i.mako > $i
+ done
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ restart|force-reload)
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
--- /dev/null
+debian/iscsid.conf.xvm.mako etc/iscsi
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+# postinst script for xvm-iscsi-config
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# Source debconf library
+. /usr/share/debconf/confmodule
+
+# 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)
+ db_get xvm-iscsi-config/address
+ ADDRESS="$RET"
+ db_get xvm-iscsi-config/username
+ USERNAME="$RET"
+ db_get xvm-iscsi-config/password
+ PASSWORD="$RET"
+
+ cat >/etc/invirt/conf.d/iscsi <<EOF
+iscsi:
+ address: $ADDRESS
+ username: $USERNAME
+ password: $PASSWORD
+EOF
+ invoke-rc.d xvm-iscsi-config restart
+ invoke-rc.d open-iscsi restart
+ iscsiadm -m discovery -t st -p $(invirt-getconf iscsi.address):3260
+ ;;
+
+ 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
--- /dev/null
+#!/bin/sh
+# prerm script for xvm-iscsi-config
+#
+# 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)
+ rm /etc/invirt/conf.d/iscsi
+ ;;
+
+ 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
+
+
--- /dev/null
+Template: xvm-iscsi-config/address
+Type: string
+Description: iSCSI IP Address
+ What is the IP address of the iSCSI shared storage array?
+
+Template: xvm-iscsi-config/username
+Type: string
+Description: iSCSI username
+ What is the username for the iSCSI shared storage array?
+
+Template: xvm-iscsi-config/password
+Type: password
+Description: iSCSI password
+ What is the password for the iSCSI shared storage array?