#!/bin/sh # postinst script for phpmyadmin set -e lighttpd_install() { if [ ! -f /etc/lighttpd/conf-available/50-phpmyadmin.conf ] ; then if [ ! -x /usr/sbin/lighty-enable-mod ] ; then echo "Lighttpd not installed, skipping" else ln -s ../../phpmyadmin/lighttpd.conf /etc/lighttpd/conf-available/50-phpmyadmin.conf # We also need auth to protect setup.php /usr/sbin/lighty-enable-mod phpmyadmin auth fi fi } apache_install() { webserver=$1 if [ -d /etc/$webserver/conf.d ] && [ ! -e /etc/$webserver/conf.d/phpmyadmin.conf ]; then ln -s ../../phpmyadmin/apache.conf /etc/$webserver/conf.d/phpmyadmin.conf fi } if [ "$1" = "configure" ]; then # Generate secret for cookie encryption if [ ! -f /var/lib/phpmyadmin/blowfish_secret.inc.php ]; then touch /var/lib/phpmyadmin/blowfish_secret.inc.php chgrp www-data /var/lib/phpmyadmin/blowfish_secret.inc.php chmod 640 /var/lib/phpmyadmin/blowfish_secret.inc.php printf "> /var/lib/phpmyadmin/blowfish_secret.inc.php fi . /usr/share/debconf/confmodule db_version 2.0 # The following only on a new install if [ "$2" = "" ]; then # Generate an htpasswd file for the web based setup if [ ! -f /etc/phpmyadmin/htpasswd.setup ]; then touch /etc/phpmyadmin/htpasswd.setup chgrp www-data /etc/phpmyadmin/htpasswd.setup chmod 0640 /etc/phpmyadmin/htpasswd.setup db_get phpmyadmin/setup-username setup_username=${RET:-admin} db_get phpmyadmin/setup-password if [ -n "$RET" ]; then setup_password=`perl -le 'print crypt($ARGV[0], join("", map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..2)))' "$RET"` else setup_password="*" fi echo "$setup_username:$setup_password" > /etc/phpmyadmin/htpasswd.setup db_reset phpmyadmin/setup-username || true db_reset phpmyadmin/setup-password || true if [ ! -f /var/lib/phpmyadmin/config.inc.php ]; then touch /var/lib/phpmyadmin/config.inc.php chgrp www-data /var/lib/phpmyadmin/config.inc.php chmod 0640 /var/lib/phpmyadmin/config.inc.php fi fi fi # Fixup permissions chmod 0640 /var/lib/phpmyadmin/config.inc.php # Configure Apache db_get phpmyadmin/reconfigure-webserver webservers="$RET" for webserver in $webservers; do webserver=${webserver%,} if [ "$webserver" = "lighttpd" ] ; then lighttpd_install else apache_install $webserver fi # Reload webserver in any case, configuration might have changed # Redirection of 3 is needed because Debconf uses it and it might # be inherited by webserver. See bug #446324. if [ -x /usr/sbin/invoke-rc.d ]; then invoke-rc.d $webserver reload 3>/dev/null || true else /etc/init.d/$webserver reload 3>/dev/null || true fi done # warn about old pre-lenny symlink. Remove post-lenny. if dpkg --compare-versions "$2" lt-nl "4:2.10.1-1" \ && [ -L /var/www/phpmyadmin ] \ && [ `readlink -n /var/www/phpmyadmin` = "/usr/share/phpmyadmin" ]; then echo "You have a symlink /var/www/phpmyadmin still present. This was needed " echo "in older versions of the phpMyAdmin package to make it web-accessible. " echo "It can now be removed because the package is configured directly " echo "within the webserver." echo fi fi exit 0