wok rev 8354

wordpress:improve install
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Thu Feb 03 17:10:57 2011 +0100 (2011-02-03)
parents 9ece8f68b694
children 8131542f626c
files wordpress/receipt
line diff
     1.1 --- a/wordpress/receipt	Thu Feb 03 17:09:38 2011 +0100
     1.2 +++ b/wordpress/receipt	Thu Feb 03 17:10:57 2011 +0100
     1.3 @@ -5,7 +5,7 @@
     1.4  CATEGORY="misc"
     1.5  SHORT_DESC="Blog Tool and Publishing Platform."
     1.6  MAINTAINER="slaxemulator@gmail.com"
     1.7 -DEPENDS="php mysql"
     1.8 +DEPENDS="php mysql php-mysql"
     1.9  SUGGESSTED="apache cherokee"
    1.10  TARBALL="$PACKAGE-$VERSION.tar.gz"
    1.11  WEB_SITE="http://wordpress.org"
    1.12 @@ -17,6 +17,62 @@
    1.13  	src=$WOK/$PACKAGE/$PACKAGE
    1.14  	mkdir -p $fs/var/www/wordpress
    1.15  	cp -a $src/* $fs/var/www/wordpress
    1.16 -	chown -R 80.80 $fs/var/www/wordpress
    1.17 +	chown -R www.www $fs/var/www/wordpress
    1.18  }
    1.19  
    1.20 +post_install()
    1.21 +{
    1.22 +	local db=wordpress
    1.23 +	local db_user=wordpress
    1.24 +	local db_password=wordpress
    1.25 +	
    1.26 +	# Minimal config for wordpress.
    1.27 +	if [ -z $1 ]; then
    1.28 +		if ( ! mysqladmin -s ping > /dev/null ); then
    1.29 +			echo "Starting MySQL server"
    1.30 +			( /etc/init.d/mysql start ; status  ) || exit 
    1.31 +			sleep 4 #let the mysql daemon start
    1.32 +		fi
    1.33 +		if ( ! mysql -u root -Be 'show databases' | grep -q $db ); then
    1.34 +			echo -n "Create $db database"
    1.35 +			mysql -Be "create database $db" ; status
    1.36 +			# We suppose that $DB_USER user does not exist.
    1.37 +			# It may be false.
    1.38 +			echo  -n "Create user $db_user with password $db_password"
    1.39 +			mysql -Be "grant all privileges on $db.* to '"$db_user"'@'localhost' 
    1.40 +				identified by '"$db_password"'" ; status
    1.41 +			# At last create the database for $PACKAGE.
    1.42 +			echo -n "Create $db database schema."
    1.43 +			#mysql -u glpi -pglpi -D glpi < /usr/share/glpi/install/mysql/glpi-${VERSION}-empty.sql ; status
    1.44 +		fi
    1.45 +	fi
    1.46 +	
    1.47 +}
    1.48 +
    1.49 +post_remove()
    1.50 +{
    1.51 +		local db=wordpress
    1.52 +		local db_user=wordpress
    1.53 +		local db_password=wordpress
    1.54 +	
    1.55 +		echo -n "Would you like to remove data and database files.(y/n) "
    1.56 +		read answer
    1.57 +
    1.58 +		case $answer in 
    1.59 +		y|Y)
    1.60 +			echo -n "Removing data directories..."
    1.61 +			rm -rf /var/lib/wordpress ; status
    1.62 +			if ( mysql -u root -Be 'show databases' | grep -q $db ); then
    1.63 +				echo -n "Deleting $db database"
    1.64 +				mysql -Be "drop database $db" ; status
    1.65 +				# We suppose that glpi user does not exist.
    1.66 +				# It may be false.
    1.67 +				echo  -n "Delete user $db_user"
    1.68 +				mysql -Be "delete from mysql.db where user='"$db_user"'" ; status
    1.69 +			fi
    1.70 +			unset $answer
    1.71 +			;;
    1.72 +		*)
    1.73 +			;;
    1.74 +		esac
    1.75 +}