From e4b3f2f94ce1675ff7311ee9ed543f8ba6b794d6 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sat, 1 Nov 2008 04:41:45 -0400 Subject: [PATCH] Create xvm-iscsi-config package svn path=/trunk/packages/xvm-iscsi-config/; revision=1496 --- debian/changelog | 5 ++ debian/compat | 1 + debian/control | 13 +++++ debian/copyright | 4 ++ debian/rules | 16 ++++++ debian/transform_iscsid.conf.xvm.mako | 28 ++++++++++ debian/xvm-iscsi-config.config | 16 ++++++ debian/xvm-iscsi-config.init | 99 +++++++++++++++++++++++++++++++++ debian/xvm-iscsi-config.install | 1 + debian/xvm-iscsi-config.postinst | 58 +++++++++++++++++++ debian/xvm-iscsi-config.prerm | 41 ++++++++++++++ debian/xvm-iscsi-config.templates | 14 +++++ 12 files changed, 296 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100755 debian/transform_iscsid.conf.xvm.mako create mode 100755 debian/xvm-iscsi-config.config create mode 100755 debian/xvm-iscsi-config.init create mode 100644 debian/xvm-iscsi-config.install create mode 100755 debian/xvm-iscsi-config.postinst create mode 100755 debian/xvm-iscsi-config.prerm create mode 100644 debian/xvm-iscsi-config.templates diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..f81ee75 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +xvm-iscsi-config (0.0.1) unstable; urgency=low + + * Initial Release. + + -- Evan Broder Thu, 23 Oct 2008 22:16:55 -0400 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..9be4c61 --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: xvm-iscsi-config +Section: servers +Priority: extra +Maintainer: SIPB XVM Project +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 index 0000000..e5cc6d8 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,4 @@ +This package was created for the XVM project 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 index 0000000..9d05696 --- /dev/null +++ b/debian/rules @@ -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 index 0000000..14075b0 --- /dev/null +++ b/debian/transform_iscsid.conf.xvm.mako @@ -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 index 0000000..e3f15bd --- /dev/null +++ b/debian/xvm-iscsi-config.config @@ -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 index 0000000..e792497 --- /dev/null +++ b/debian/xvm-iscsi-config.init @@ -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 + +# 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 index 0000000..1b41226 --- /dev/null +++ b/debian/xvm-iscsi-config.install @@ -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 index 0000000..7c743da --- /dev/null +++ b/debian/xvm-iscsi-config.postinst @@ -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: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# 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 <&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 index 0000000..8bd57ab --- /dev/null +++ b/debian/xvm-iscsi-config.prerm @@ -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: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# 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 index 0000000..1ffadc6 --- /dev/null +++ b/debian/xvm-iscsi-config.templates @@ -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? -- 1.7.9.5