Created
March 14, 2013 00:05
-
-
Save stovak/5157687 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export LOGFILE="/tmp/apigee-drupal-install.log" | |
export DRUPAL_WEBAPP="/var/www/html" | |
export DOCS_DB_SOURCE="/tmp/apigee-drupal/db/docs_r20_2013-03-13.sql" | |
export DOCS_HOSTNAME="docs.local" | |
export PORTAL_DB_SOURCE="/tmp/apigee-drupal/db/portal_r20_2013-03-13.sql" | |
export PORTAL_HOSTNAME="portal.local" | |
echo "*******************************************************************************" | |
echo "" | |
echo " This script will install a default Apigee Portal & Docs here:" | |
echo " $DRUPAL_WEBAPP" | |
echo " as a drupal multisite serving both sites" | |
echo " for more information on drupal multisites, please see this url:" | |
echo " http://drupal.org/documentation/install/multi-site" | |
echo "" | |
echo " PRESS RETURN TO CONTINUE" | |
echo "" | |
echo "*******************************************************************************" | |
read $value | |
# Clean up function called if signal caught | |
function cleanup_error(){ | |
#echo "drop DATABASE IF EXISTS $MYDBNAME;" | mysql -u $MYADMINUSER --password=$MYADMINPASS -h $MYHOST | |
echo "===> Exiting, ERROR!" | |
echo "*******************************************************************************" | |
echo "" | |
echo " The actions of this installer are written to a log here: ${LOGFILE}" | |
echo " If you need support during this installation, " | |
echo " please include the logfile in your communication" | |
echo "" | |
echo "*******************************************************************************" | |
echo "" | |
echo "" | |
exit | |
} | |
function cleanup_noerror() { | |
echo "*******************************************************************************" | |
echo " GREAT SUCCESS! you're good to go. " | |
echo "*******************************************************************************" | |
echo "*******************************************************************************" | |
echo "" | |
echo " The actions of this installer are written to a log here: ${LOGFILE}" | |
echo " If you need support during this installation, " | |
echo " please include the logfile in your communication" | |
echo "" | |
echo "*******************************************************************************" | |
echo "" | |
echo "" | |
exit | |
} | |
# Set signal trap to call above cleanup function | |
trap cleanup_error ERR | |
trap clearup_noerror TERM HUP | |
echo "Downloading Cert from fedoraproject..." | |
rpm -ivh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm >> $LOGFILE 2>&1 | |
echo "*******************************************************************************" | |
echo " Installing Packages from various repos (this may take a few minutes)..." | |
echo "*******************************************************************************" | |
sudo yum install -y httpd mysql mysql-server git php php-mysql php-xml gd gd-devel php-gd php-pear openssl openssl-devel ImageMagick ImageMagick-devel >> $LOGFILE 2>&1 | |
echo "*******************************************************************************" | |
echo " Restarting Apache..." | |
echo "*******************************************************************************" | |
sudo service httpd start >> $LOGFILE 2>&1 | |
echo "*******************************************************************************" | |
echo " Restarting MySQL..." | |
echo "*******************************************************************************" | |
sudo service mysqld start >> $LOGFILE 2>&1 | |
echo "*******************************************************************************" | |
echo " Making sure MySQL and Apache run at startup..." | |
echo "*******************************************************************************" | |
chkconfig --levels 35 mysqld on >> $LOGFILE 2>&1 | |
chkconfig --levels 35 httpd on >> $LOGFILE 2>&1 | |
# there are extra libraries in here meant for development and diagnosis of php issues | |
# installing them all doesn't hurt anything | |
echo "*******************************************************************************" | |
echo " Adding PEAR Channels..." | |
echo "*******************************************************************************" | |
sudo pear config-set auto_discover 1 >> $LOGFILE 2>&1 | |
sudo pear channel-discover pear.drush.org >> $LOGFILE 2>&1 | |
sudo pear channel-discover pear.phing.info >> $LOGFILE 2>&1 | |
sudo pear channel-update pear.php.net >> $LOGFILE 2>&1 | |
sudo pear channel-discover pear.phpunit.de >> $LOGFILE 2>&1 | |
sudo pear channel-update pear.phpunit.de >> $LOGFILE 2>&1 | |
sudo pear channel-discover components.ez.no >> $LOGFILE 2>&1 | |
sudo pear channel-update components.ez.no >> $LOGFILE 2>&1 | |
sudo pear channel-discover pear.symfony-project.com >> $LOGFILE 2>&1 | |
sudo pear channel-update pear.symfony-project.com >> $LOGFILE 2>&1 | |
sudo pear channel-discover saucelabs.github.com/pear >> $LOGFILE 2>&1 | |
sudo pear channel-update saucelabs.github.com/pear >> $LOGFILE 2>&1 | |
echo "*******************************************************************************" | |
echo " Installing PEAR libs and DRUSH (This may take a few minutes)..." | |
echo "*******************************************************************************" | |
sudo pear install -f -a pear/Services_Amazon_S3-0.3.5 >> $LOGFILE 2>&1 | |
sudo pear install -f -a pear/VersionControl_Git-0.4.4 >> $LOGFILE 2>&1 | |
sudo pear upgrade -f -a Console_Getopt >> $LOGFILE 2>&1 | |
sudo pear upgrade -f -a pear >> $LOGFILE 2>&1 | |
sudo pear upgrade-all >> $LOGFILE 2>&1 | |
sudo pear install -a drush/drush >> $LOGFILE 2>&1 | |
sudo pear install pear.phpqatools.org/phpqatools pear.netpirates.net/phpDox >> $LOGFILE 2>&1 | |
sudo pear install -a phing/phing >> $LOGFILE 2>&1 | |
sudo pear install -a ezc/eZComponents >> $LOGFILE 2>&1 | |
sudo pear install -f -a phpunit/DbUnit-1.0.3 >> $LOGFILE 2>&1 | |
sudo pear install -f -a phpunit/File_Iterator-1.2.6 >> $LOGFILE 2>&1 | |
sudo pear install -f -a phpunit/PHPUnit_MockObject-1.0.9 >> $LOGFILE 2>&1 | |
sudo pear install -f -a phpunit/PHP_CodeCoverage-1.0.5 >> $LOGFILE 2>&1 | |
sudo pear install -f -a phpunit/PHP_Invoker-1.0.0 >> $LOGFILE 2>&1 | |
sudo pear install -f -a phpunit/PHP_Timer-1.0.2 >> $LOGFILE 2>&1 | |
sudo pear install -f -a phpunit/PHP_TokenStream-1.0.1 >> $LOGFILE 2>&1 | |
sudo pear install -f -a phpunit/Text_Template-1.1.0 >> $LOGFILE 2>&1 | |
sudo pear install -a saucelabs/PHPUnit_Selenium_SauceOnDemand >> $LOGFILE 2>&1 | |
echo "*******************************************************************************" | |
echo " Cloning the Apigee-Drupal release into /tmp/apigee-drupal..." | |
echo "*******************************************************************************" | |
git clone -b releases git://github.com/apigee/apigee-drupal /tmp/apigee-drupal >> $LOGFILE 2>&1 | |
echo "*******************************************************************************" | |
echo " Copying the webapp folder into /var/www/html ... " | |
echo "*******************************************************************************" | |
cp -R '/tmp/apigee-drupal/webapp/*' '/tmp/apigee-drupal/webapp/.ht*' -t $DRUPAL_WEBAPP >> $LOGFILE 2>&1 | |
echo "<?php \n" > "/var/www/html/sites/sites.php" | |
echo "*******************************************************************************" | |
echo " Installing the portal..." | |
echo "*******************************************************************************" | |
export PORTAL_DB_PASSWORD=`openssl rand -base64 12` | |
export PORTAL_DB_RANDUSER=`openssl rand -base64 8` | |
export PORTAL_DB_USERNAME="user-$PORTAL_DB_RANDUSER" | |
mkdir "$DRUPAL_WEBAPP/sites/portal" | |
mkdir "$DRUPAL_WEBAPP/sites/portal/public" | |
mkdir "$DRUPAL_WEBAPP/sites/portal/tmp" | |
mkdir "$DRUPAL_WEBAPP/sites/portal/private" | |
mysqladmin -u root create portal; | |
mysql -u root -e "grant all on portal.* to '$PORTAL_DB_USERNAME'@'locahost' identified by '$PORTAL_DB_PASSWORD'" portal | |
mysql -u root portal < $PORTAL_DB_SOURCE | |
# Create drupal site config | |
( | |
echo '<?php' | |
echo '$databases = array(' | |
echo " 'default' =>" | |
echo " array (" | |
echo " 'default' =>" | |
echo " array (" | |
echo " 'database' => 'db_portal'," | |
echo " 'username' => '$PORTAL_DB_USERNAME'," | |
echo " 'password' => '$PORTAL_DB_PASSWORD'," | |
echo " 'host' => 'localhost'," | |
echo " 'port' => ''," | |
echo " 'driver' => 'mysql'," | |
echo " 'prefix' => ''," | |
echo " )," | |
echo " )," | |
echo ");" | |
echo '$update_free_access = FALSE;' | |
echo '$'"drupal_hash_salt = '';" | |
echo "ini_set('session.gc_probability', 1);" | |
echo "ini_set('session.gc_divisor', 100);" | |
echo "ini_set('session.gc_maxlifetime', 200000);" | |
echo "ini_set('session.cookie_lifetime', 2000000);" | |
echo "" | |
echo '$'"conf['404_fast_paths_exclude'] = '/\/(?:styles)\//';" | |
echo '$'"conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i';" | |
echo '$'"conf['404_fast_html'] = '<!DOCTYPE HTML><html lang="'"'"en"'"'"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "'"'"@path"'"'" was not found on this server.</p></body></html>';" | |
echo '?>' | |
) > "$DRUPAL_WEBAPP/sites/portal/settings.php" | |
# Add FQDN to sites/sites.php | |
( | |
echo "\$sites['$PORTAL_HOSTNAME'] = 'portal';" | |
) >> "$DRUPAL_WEBAPP/sites/sites.php" | |
echo "*******************************************************************************" | |
echo " Installing the documentation..." | |
echo "*******************************************************************************" | |
export DOCS_DB_PASSWORD=`openssl rand -base64 12` | |
export DOCS_DB_RANDUSER=`openssl rand -base64 8` | |
export DOCS_DB_USERNAME="user-$PORTAL_DB_RANDUSER" | |
mkdir "$DRUPAL_WEBAPP/sites/docs" | |
mkdir "$DRUPAL_WEBAPP/sites/docs/public" | |
mkdir "$DRUPAL_WEBAPP/sites/docs/tmp" | |
mkdir "$DRUPAL_WEBAPP/sites/docs/private" | |
mysqladmin -u root create docs; | |
mysql -u root -e "grant all on portal.* to '$DOCS_DB_USERNAME'@'locahost' identified by '$DOCS_DB_PASSWORD'" docs | |
mysql -u root portal < $DOCS_DB_SOURCE | |
# Create drupal site config | |
( | |
echo '<?php' | |
echo '$databases = array(' | |
echo " 'default' =>" | |
echo " array (" | |
echo " 'default' =>" | |
echo " array (" | |
echo " 'database' => 'db_portal'," | |
echo " 'username' => '$DOCS_DB_USERNAME'," | |
echo " 'password' => '$DOCS_DB_PASSWORD'," | |
echo " 'host' => 'localhost'," | |
echo " 'port' => ''," | |
echo " 'driver' => 'mysql'," | |
echo " 'prefix' => ''," | |
echo " )," | |
echo " )," | |
echo ");" | |
echo '$update_free_access = FALSE;' | |
echo '$'"drupal_hash_salt = '';" | |
echo "ini_set('session.gc_probability', 1);" | |
echo "ini_set('session.gc_divisor', 100);" | |
echo "ini_set('session.gc_maxlifetime', 200000);" | |
echo "ini_set('session.cookie_lifetime', 2000000);" | |
echo "" | |
echo '$'"conf['404_fast_paths_exclude'] = '/\/(?:styles)\//';" | |
echo '$'"conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i';" | |
echo '$'"conf['404_fast_html'] = '<!DOCTYPE HTML><html lang="'"'"en"'"'"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "'"'"@path"'"'" was not found on this server.</p></body></html>';" | |
echo '?>' | |
) > "$DRUPAL_WEBAPP/sites/portal/settings.php" | |
# Add FQDN to sites/sites.php | |
( | |
echo "\$sites['$DOCS_HOSTNAME'] = 'docs';" | |
) >> "$DRUPAL_WEBAPP/sites/sites.php" | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment