guneysus
1/13/2015 - 11:19 AM

Drupal7 Quick Install via command line (mysql and drush required)

Drupal7 Quick Install via command line (mysql and drush required)

#!/usr/bin/env bash
# This shell script is used for initializing a fresh and up-to-date
# Drupal environment. Downloads stable versions of modules
# Copyright (C) 2015 Ahmed Seref Guneysu
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ------------------------------------------------------------------------------
# TODO simple drupal installation
# Create database from command line
# http://stackoverflow.com/a/2428451/1766716 (*)
# https://www.drupal.org/documentation/install/developers (**)
#

# 0. GET DRUPAL AND FUNDAMENTAL (!) MODULES ;)
#--------------------------------------------------------------------------------
# drush dl drupal \
    # taxonomy_manager references jquery_update ctools vbo \
    # ajax_markup bueditor markdowneditor markdown date ds css_injector \
    # elysia_cron entity libraries ff module_dep_toggle pathauto progress \
    # publish_button revisioning token transliteration flag devel migrate \
    # import performance similarterms views_bulk_operations views_data_export \
    # services_token_access wsclient chosen rules i18n node_export oauth boost \
    # entitycache smtp page_title google_analytics page_theme variable \
    # workbench xmlsitemap coffee advagg

mkdir -p sites/default/files
chown www-data sites/default/files -R

# 1. DB CREATE
#--------------------------------------------------------------------------------
# All of nearly equivalent
# echo "create database drupal7_data" | mysql -u drupal7_data -p #
mysqladmin -u drupal7_data -p create drupal7_data
# cat filename.sql | mysql -u drupal7 -p # type mysql password when asked for it
#
# 2. GRANT PRIVILEGES
#--------------------------------------------------------------------------------

# echo "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, \
#    CREATE TEMPORARY TABLES, LOCK TABLES \
#    ON drupal7_data.* \
#    TO 'drupal7@localhost' IDENTIFIED BY '1';" | mysql -u root -p
mysql -u root -p1 -e \
      "create database drupal7_data; GRANT ALL PRIVILEGES ON drupal7_data.* TO drupal7_data@localhost IDENTIFIED BY '1'"

# 3. DRUPAL INSTALL
#--------------------------------------------------------------------------------
# I can not install drupal with drush
# You can install with web-gui and reset with this script
# drush site-install minimal \
#      --db-url='mysql://drupal7_data:11@localhost/drupal7_data' \
#      --site-name='Minimal Drupal7 Installation' \
#      --account-name=admin --account-pass=1
# Resetting site
drush site-install minimal --site-name='Example Drupal Site'  \
    --account-name=admin --account-pass=1