Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kzoltan/3e6e3273979dec968304 to your computer and use it in GitHub Desktop.
Save kzoltan/3e6e3273979dec968304 to your computer and use it in GitHub Desktop.
Drupal site install script to install Drupal database and core. Enable and disable favorable contrib modules. Installing Drupal using Drush in the command line.
#!/bin/sh
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PASSWORD=root
# modules to enable
CONTRIB_MODULES="admin_menu better_watchdog_ui cacheflush mailcontrol module_filter devel coffee search_krumo"
NEW_DIRS="sites/all/modules/contrib sites/all/modules/custom sites/all/themes/contrib sites/all/themes/custom sites/default/files"
echo "================================================"
echo "This is the script for installing a fresh Drupal"
echo "================================================"
echo -n "Enter your project name (please use only one word, lowercase, without special characters) and press [ENTER]: "
read DRUPAL_PROJECTNAME
echo "================================================"
echo "Downloading Drupal"
drush dl drupal --drupal-project-rename="$DRUPAL_PROJECTNAME"
cd "$DRUPAL_PROJECTNAME" || exit 1 # go to directory (create if doesn't exist)
echo "================================================"
echo "Configure and install"
mkdir -v $NEW_DIRS # create proper folder structure
# echo "================================================"
# echo "Creating database"
# mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -e "create database drupal_$DRUPAL_PROJECTNAME";
echo "================================================"
echo "Installing site"
drush -y site-install standard --site-name=$DRUPAL_PROJECTNAME --account-name=admin --account-pass=admin --db-url=mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST/drupal_$DRUPAL_PROJECTNAME
echo "================================================"
echo "Changing folder permissions"
chmod g+w "sites/default/files"
echo "================================================"
echo "Downloading contrib modules"
drush dl $CONTRIB_MODULES
echo "================================================"
echo "Enabling contrib modules"
drush en -y $CONTRIB_MODULES
echo "================================================"
echo "Disable overlay and toolbar module"
drush dis -y overlay toolbar
drush en -y admin_menu_toolbar
drush en -y devel_generate, views_ui
echo "================================================"
echo "Clearing the cache"
drush cc all
echo "================================================"
echo "Everything done. Your new site is ready."
#get current instalation path without /var/www
SITE_URL=http://localhost/$(pwd | cut -d'/' -f 4-)
#open up in the browser
sensible-browser $SITE_URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment