Create xvm-iscsi-config package
authorEvan Broder <broder@mit.edu>
Sat, 1 Nov 2008 08:41:45 +0000 (04:41 -0400)
committerEvan Broder <broder@mit.edu>
Sat, 1 Nov 2008 08:41:45 +0000 (04:41 -0400)
svn path=/trunk/packages/xvm-iscsi-config/; revision=1496

12 files changed:
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/transform_iscsid.conf.xvm.mako [new file with mode: 0755]
debian/xvm-iscsi-config.config [new file with mode: 0755]
debian/xvm-iscsi-config.init [new file with mode: 0755]
debian/xvm-iscsi-config.install [new file with mode: 0644]
debian/xvm-iscsi-config.postinst [new file with mode: 0755]
debian/xvm-iscsi-config.prerm [new file with mode: 0755]
debian/xvm-iscsi-config.templates [new file with mode: 0644]

diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..f81ee75
--- /dev/null
@@ -0,0 +1,5 @@
+xvm-iscsi-config (0.0.1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Evan Broder <broder@mit.edu>  Thu, 23 Oct 2008 22:16:55 -0400
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..9be4c61
--- /dev/null
@@ -0,0 +1,13 @@
+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.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..e5cc6d8
--- /dev/null
@@ -0,0 +1,4 @@
+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.
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..9d05696
--- /dev/null
@@ -0,0 +1,16 @@
+#!/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 < $< > $@
diff --git a/debian/transform_iscsid.conf.xvm.mako b/debian/transform_iscsid.conf.xvm.mako
new file mode 100755 (executable)
index 0000000..14075b0
--- /dev/null
@@ -0,0 +1,28 @@
+#!/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
+}
diff --git a/debian/xvm-iscsi-config.config b/debian/xvm-iscsi-config.config
new file mode 100755 (executable)
index 0000000..e3f15bd
--- /dev/null
@@ -0,0 +1,16 @@
+#!/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
diff --git a/debian/xvm-iscsi-config.init b/debian/xvm-iscsi-config.init
new file mode 100755 (executable)
index 0000000..e792497
--- /dev/null
@@ -0,0 +1,99 @@
+#! /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
+
+:
diff --git a/debian/xvm-iscsi-config.install b/debian/xvm-iscsi-config.install
new file mode 100644 (file)
index 0000000..1b41226
--- /dev/null
@@ -0,0 +1 @@
+debian/iscsid.conf.xvm.mako etc/iscsi
\ No newline at end of file
diff --git a/debian/xvm-iscsi-config.postinst b/debian/xvm-iscsi-config.postinst
new file mode 100755 (executable)
index 0000000..7c743da
--- /dev/null
@@ -0,0 +1,58 @@
+#!/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
diff --git a/debian/xvm-iscsi-config.prerm b/debian/xvm-iscsi-config.prerm
new file mode 100755 (executable)
index 0000000..8bd57ab
--- /dev/null
@@ -0,0 +1,41 @@
+#!/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
+
+
diff --git a/debian/xvm-iscsi-config.templates b/debian/xvm-iscsi-config.templates
new file mode 100644 (file)
index 0000000..1ffadc6
--- /dev/null
@@ -0,0 +1,14 @@
+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?