## ## This script is ran the first time a user logs in ## ## use: called by vm.cfg ## ## ## background: http://www.wepoca.net/doc/drupal-lamp-virtual-server ## ## created by doka@wepoca.net ## 2009-02-15 ## www.wepoca.net ## ## echo "" echo "" echo "This script runs the first time a user logs in" #configure the mysql server root password echo "" echo "1. Setting the mysql server root password" sudo dpkg-reconfigure mysql-server-5.0 #install and configure phpmyadmin echo "" echo "2. install and configure phpmyadmin" sudo apt-get install phpmyadmin #download and prepare Drupal source echo "" echo "3. Download and prepare the Drupal source" VERSION="drupal-6.10" echo "Please, enter the Drupal version! [$VERSION]" read NEWVERSION if [ "$NEWVERSION" = "" ]; then echo "using default $VERSION" else VERSION=$NEWVERSION echo "using $VERSION" fi # install into the home of the first user USER=`ls /home | grep -v 'lost+found'` wget http://ftp.drupal.org/files/projects/$VERSION.tar.gz tar -zxpf $VERSION.tar.gz sudo mv $VERSION drupal6 sudo cp /home/$USER/drupal6/sites/default/default.settings.php /home/$USER/drupal6/sites/default/settings.php sudo mkdir /home/$USER/drupal6/sites/default/files sudo chmod a+w /home/$USER/drupal6/sites/default/files sudo chmod a+w /home/$USER/drupal6/sites/default/settings.php # some Apache modules for clean URLs and virtual hosts echo "" echo "4. Prepare Apache for Drupal" sudo a2enmod vhost_alias sudo a2enmod rewrite # Drupal6 catch-all vhost config file echo " ServerAdmin webmaster@localhost ServerName d6 ServerAlias d6 *.d6 DocumentRoot /home/$USER/drupal6 Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all ErrorLog /var/log/apache2/error.log LogLevel warn CustomLog /var/log/apache2/access.log combined " >> ~/d6 sudo mv d6 /etc/apache2/sites-available/. sudo a2ensite d6 # PHP memory increase to 64M echo "" echo "5. Prepare PHP for Drupal" sudo sed -i 's/memory_limit = 16M/memory_limit = 64M/' /etc/php5/apache2/php.ini # Apache needs to be restarted echo "" echo "6. restart Apache" sudo /etc/init.d/apache2 restart # Drupal user and database in MySQL echo "" echo "7. Prepare MySQL for Drupal" echo "Please, enter your MySQL root password!" read PWD DBU=drupaluser echo "Please, enter the database user for Drupal [$DBU]" read NEWDBU if [ "$NEWDBU" = "" ]; then echo using default $DBU else DBU=$NEWDBU echo using $DBU fi DBPWD=drupalpwd echo "Please, enter the database user for Drupal [$DBPWD]" read NEWDBPWD if [ "$NEWDBPWD" = "" ]; then echo using default $DBPWD else DBPWD=$NEWDBPWD echo using $DBPWD fi DB=drupaldb echo "Please, enter the database user for Drupal [$DB]" read NEWDB if [ "$NEWDB" = "" ]; then echo using default $DB else DB=$NEWDB echo using $DB fi mysql -uroot -p$PWD -e "CREATE DATABASE $DB CHARACTER SET 'utf8'" mysql -uroot -p$PWD -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON $DB.* TO '$DBU'@'localhost' IDENTIFIED BY '$DBPWD'" mysql -uroot -p$PWD -e "FLUSH PRIVILEGES" # It's ready to use IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'` echo "" echo "Your appliance is now ready for Drupal." echo "" echo "Use phpMyAdmin: http://$IP/phpmyadmin" echo "Add this line to /etc/hosts file in your HOST: $IP YOURDOMAIN.d6" echo "and type in your browser: http://YOURDOMAIN.d6" echo ""