#! /bin/sh # postinst script for uri # # see: dh_installdeb(1) set -e get_config() { db_get mtop/mysql_server mysql_server="$RET" db_get mtop/mysql_port mysql_port="$RET" db_get mtop/root root_mysql="$RET" db_get mtop/password root_passwd="$RET" } create_user() { ${mysqlcmd} -e " CONNECT mysql; grant select on test.* to mysqltop; grant select on test.* to mysqltop@localhost; update user set process_priv='y' where user='mysqltop'; flush privileges; " } # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-deconfigure' `in-favour' # `removing' # # for details, see /usr/share/doc/packaging-manual/ # # quoting from the policy: # Any necessary prompting should almost always be confined to the # post-installation script, and should be protected with a conditional # so that unnecessary prompting doesn't happen if a package's # installation fails and the `postinst' is called with `abort-upgrade', # `abort-remove' or `abort-deconfigure'. case "$1" in configure) # Source debconf library . /usr/share/debconf/confmodule db_version 2.0 get_config password=`dd if=/dev/random bs=512 count=1 2> /dev/null| md5sum` if [ "$root_passwd" != 'none' ]; then mysqlpwd="-p${root_passwd}" fi mysqlcmd="mysql -h ${mysql_server} -P ${mysql_port} -u${root_mysql} ${mysqlpwd}" if ${mysqlcmd} -B -e 'select user from user' mysql | grep -q "^mysqltop$" then echo "User already exists"; else create_user fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 0 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. exit 0