debian/littlebird-tc-sql.postinst
changeset 9 26608f45a5c6
parent 7 c34f5210c656
child 11 24417d8949b5
equal deleted inserted replaced
4:60a9d558f2a9 9:26608f45a5c6
       
     1 #!/bin/sh
       
     2 # postinst script for littlebird
       
     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 	db_get littlebird-tc/db/adminuser && adminuser="$RET" || true
       
    24 	db_get littlebird-tc/db/adminpass && adminpass="$RET" || true
       
    25 	db_get littlebird-tc/db/user && user="$RET" || true
       
    26 	db_get littlebird-tc/db/pass && pass="$RET" || true
       
    27 	db_get littlebird-tc/db/host && host="$RET" || true
       
    28 	db_get littlebird-tc/db/name && name="$RET" || true
       
    29 
       
    30 #	cat <<EOF
       
    31 #$@
       
    32 #adminuser/pass: $adminuser/$adminpass
       
    33 #user/pass: $user/$pass
       
    34 #db@host: $name@$host
       
    35 #EOF
       
    36 	# only init the db if there is no previous version
       
    37 	if test -z "$2" && test -n "$adminpass"; then
       
    38 
       
    39 	    if test "$host" = "localhost"; then client="localhost"
       
    40 	    else client="%"
       
    41 	    fi
       
    42 
       
    43 	    mysql -h"$host" -u"$adminuser" -p"$adminpass" <<EOF
       
    44 		CREATE DATABASE IF NOT EXISTS $name;
       
    45 		GRANT ALL ON $name.* TO '$user'@'$client' IDENTIFIED BY '$pass';
       
    46 		FLUSH PRIVILEGES;
       
    47 EOF
       
    48 	    (	set -e
       
    49 		cd /usr/share/littlebird/tc-sql
       
    50 		./install_test_iteration_2011-06.sh \
       
    51 		    "$host" "$name" \
       
    52 		    "$adminuser" "$adminpass" \
       
    53 		    "$user" "$pass"
       
    54 	    )
       
    55 	fi
       
    56     ;;
       
    57 
       
    58     abort-upgrade|abort-remove|abort-deconfigure)
       
    59     ;;
       
    60 
       
    61     *)
       
    62         echo "postinst called with unknown argument \`$1'" >&2
       
    63         exit 1
       
    64     ;;
       
    65 esac
       
    66 
       
    67 # dh_installdeb will replace this with shell code automatically
       
    68 # generated by other debhelper scripts.
       
    69 
       
    70 #DEBHELPER#
       
    71 
       
    72 exit 0