Create xvm-iscsi-config package
[invirt/packages/xvm-iscsi-config.git] / debian / xvm-iscsi-config.postinst
1 #!/bin/sh
2 # postinst script for xvm-iscsi-config
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
8 # Source debconf library
9 . /usr/share/debconf/confmodule
10
11 # summary of how this script can be called:
12 #        * <postinst> `configure' <most-recently-configured-version>
13 #        * <old-postinst> `abort-upgrade' <new version>
14 #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
15 #          <new-version>
16 #        * <postinst> `abort-remove'
17 #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
18 #          <failed-install-package> <version> `removing'
19 #          <conflicting-package> <version>
20 # for details, see http://www.debian.org/doc/debian-policy/ or
21 # the debian-policy package
22
23
24 case "$1" in
25     configure)
26         db_get xvm-iscsi-config/address
27         ADDRESS="$RET"
28         db_get xvm-iscsi-config/username
29         USERNAME="$RET"
30         db_get xvm-iscsi-config/password
31         PASSWORD="$RET"
32         
33         cat >/etc/invirt/conf.d/iscsi <<EOF
34 iscsi:
35  address: $ADDRESS
36  username: $USERNAME
37  password: $PASSWORD
38 EOF
39         invoke-rc.d xvm-iscsi-config restart
40         invoke-rc.d open-iscsi restart
41         iscsiadm -m discovery -t st -p $(invirt-getconf iscsi.address):3260
42     ;;
43
44     abort-upgrade|abort-remove|abort-deconfigure)
45     ;;
46
47     *)
48         echo "postinst called with unknown argument \`$1'" >&2
49         exit 1
50     ;;
51 esac
52
53 # dh_installdeb will replace this with shell code automatically
54 # generated by other debhelper scripts.
55
56 #DEBHELPER#
57
58 exit 0