|
|
@@ -1,35 +1,41 @@
|
|
|
#!/bin/sh
|
|
|
##
|
|
|
-## drupal-setup
|
|
|
+## drupal-setup.sh -- Drupal RDBMS Setup Utility
|
|
|
##
|
|
|
|
|
|
-# determine MySQL administrator username/password
|
|
|
-username=`grep "^user" @l_prefix@/etc/mysql/my.pwd |\
|
|
|
+# database configuration
|
|
|
+db_name="drupal"
|
|
|
+db_user="drupal"
|
|
|
+db_pass="drupal"
|
|
|
+
|
|
|
+# determine RDBMS-specific details
|
|
|
+db_suser=`grep "^user" @l_prefix@/etc/mysql/my.pwd |\
|
|
|
sed -e 's;^user[^=]*= *;;' -e 's; *$;;'`
|
|
|
-password=`grep "^password" @l_prefix@/etc/mysql/my.pwd |\
|
|
|
+db_spass=`grep "^password" @l_prefix@/etc/mysql/my.pwd |\
|
|
|
sed -e 's;^password[^=]*= *;;' -e 's; *$;;'`
|
|
|
|
|
|
-# create the MySQL database for Drupal
|
|
|
-@l_prefix@/bin/mysqladmin --user=$username --password=$password create drupal
|
|
|
-@l_prefix@/bin/mysql --user=$username --password=$password mysql <<EOF
|
|
|
-GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES \
|
|
|
- ON drupal.* \
|
|
|
- TO drupal@localhost IDENTIFIED BY 'drupal';
|
|
|
-FLUSH PRIVILEGES;
|
|
|
-EOF
|
|
|
-
|
|
|
-# configure settings.php accordingly
|
|
|
-@l_prefix@/lib/openpkg/shtool subst --quiet \
|
|
|
- -e 's|^\( *\$db_url\) *=.*$|\1 = "mysql://drupal:drupal@localhost/drupal";|' \
|
|
|
- @l_prefix@/share/drupal/sites/default/settings.php
|
|
|
+# dispatch operation
|
|
|
+cmd="${1:-"install"}"
|
|
|
+case "$cmd" in
|
|
|
+ install )
|
|
|
+ # create the database
|
|
|
+ @l_prefix@/bin/mysqladmin --user="$db_suser" --password="$db_spass" create "$db_name"
|
|
|
+ ( echo "GRANT ALL PRIVILEGES ON $db_name.* TO $db_user@localhost IDENTIFIED BY '$db_pass';"
|
|
|
+ echo "FLUSH PRIVILEGES;"
|
|
|
+ ) | @l_prefix@/bin/mysql --user="$db_suser" --password="$db_spass" mysql
|
|
|
|
|
|
-# check php script memory limit
|
|
|
-d=`sed <@l_prefix@/etc/apache/apache-php.ini -e 's/ *;.*$//' | awk -F= '/^memory_limit/ { print $2 }' | sed -e 's/M//'`
|
|
|
-[ $d -lt 16 ] && echo "please consider increasing memory_limit to 16M or more in @l_prefix@/etc/apache/apache-php.ini"
|
|
|
+ # activate configuration directory
|
|
|
+ # (is automatically deactivated by installer afterwards)
|
|
|
+ chmod 777 @l_prefix@/share/drupal/sites/default
|
|
|
+ ;;
|
|
|
+ uninstall )
|
|
|
+ # remove the database
|
|
|
+ ( echo "DROP DATABASE $db_name;"
|
|
|
+ ) | @l_prefix@/bin/mysql --user="$db_suser" --password="$db_spass" mysql
|
|
|
|
|
|
-# further instructions for the user
|
|
|
-d=`awk <@l_prefix@/etc/drupal/drupal-apache.conf '/^Listen/ { print $2 }'`
|
|
|
-echo "configure IP address in \"@l_prefix@/etc/drupal/drupal-apache.conf\""
|
|
|
-echo "run \"@l_prefix@/bin/openpkg rc drupal start\""
|
|
|
-echo "visit http://$d/install.php"
|
|
|
+ # remove the generated configuration
|
|
|
+ rm -f @l_prefix@/share/drupal/sites/default/settings.php
|
|
|
+ rm -f @l_prefix@/var/drupal/files/*
|
|
|
+ ;;
|
|
|
+esac
|
|
|
|