debian/postinst
changeset 48 9f66fe44239c
parent 45 377edad75934
child 49 2272c9e2eaf7
equal deleted inserted replaced
45:377edad75934 48:9f66fe44239c
     1 #!/bin/bash
       
     2 # postinst script for ha-sync
       
     3 #
       
     4 # see: dh_installdeb(1)
       
     5 set -e
       
     6 . /usr/share/debconf/confmodule
       
     7 
       
     8 # summary of how this script can be called:
       
     9 #        * <postinst> `configure' <most-recently-configured-version>
       
    10 #        * <old-postinst> `abort-upgrade' <new version>
       
    11 #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
       
    12 #          <new-version>
       
    13 #        * <postinst> `abort-remove'
       
    14 #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
       
    15 #          <failed-install-package> <version> `removing'
       
    16 #          <conflicting-package> <version>
       
    17 # for details, see http://www.debian.org/doc/debian-policy/ or
       
    18 # the debian-policy package
       
    19 
       
    20 
       
    21 case "$1" in
       
    22     configure)
       
    23 
       
    24 	{
       
    25 	    update-rc.d ha-hostname defaults >/dev/null
       
    26 	    update-rc.d ha-config defaults >/dev/null
       
    27 
       
    28 	    test -f /etc/ha-sync/id_rsa || {
       
    29 		    ssh-keygen -N "" -C "ha-sync@`hostname`" -f /etc/ha-sync/id_rsa >&2
       
    30 		    chmod u=r,go= /etc/ha-sync/id_rsa
       
    31 	    }
       
    32 
       
    33 	} >&2
       
    34 
       
    35 
       
    36 	TMP=`tempfile`; trap "rm -f $TMP" EXIT
       
    37 
       
    38 	## Config file 
       
    39 	{
       
    40 	    echo "# see /usr/share/doc/ha-sync/examples/ha-sync.conf.ex for"
       
    41 	    echo "# example"
       
    42 	    echo ""
       
    43 
       
    44 	    db_get ha-sync/dir
       
    45 	    echo DIR="'$RET'"
       
    46 
       
    47 	    db_get ha-sync/nodes
       
    48 	    echo "$RET" | while read a b; do 
       
    49 		    echo NODE_A="'$a'"
       
    50 		    echo NODE_B="'$b'"
       
    51 	    done 
       
    52 
       
    53 	    db_get ha-sync/fs
       
    54 	    echo FILESYSTEMS="'${RET//,/}'"
       
    55 
       
    56 	    db_get ha-sync/exclude
       
    57 	    echo EXCLUDE="'$RET'"
       
    58 
       
    59 	} >> $TMP
       
    60 	ucf --debconf-ok $TMP /etc/ha-sync/ha-sync.conf
       
    61 
       
    62 	## Exclude list
       
    63 	ucf --debconf-ok /usr/share/doc/ha-sync/examples/exclude.ex /etc/ha-sync/exclude
       
    64 
       
    65 	## noch Verzeichnisse
       
    66 	source /etc/ha-sync/ha-sync.conf
       
    67 	install -d "$DIR";
       
    68 	for node in $NODE_A $NODE_B; do
       
    69 	    install -d $DIR/$node.etc
       
    70 	done
       
    71 
       
    72     ;;
       
    73 
       
    74     abort-upgrade|abort-remove|abort-deconfigure)
       
    75     ;;
       
    76 
       
    77     *)
       
    78         echo "postinst called with unknown argument \`$1'" >&2
       
    79         exit 1
       
    80     ;;
       
    81 esac
       
    82 
       
    83 # dh_installdeb will replace this with shell code automatically
       
    84 # generated by other debhelper scripts.
       
    85 
       
    86 #DEBHELPER#
       
    87 
       
    88 exit 0
       
    89 
       
    90 
       
    91 # vim:sts=4 sw=4 aw ai sm: