2 # Create a new Drupal project
4 # Copyright (C) 2017 Antonio Ospite <ao2@ao2.it>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 usage: drin $(basename "$0" .sh) [-h|--help] <destdir>
25 Create a new Drupal project in the 'destdir' directory.
28 -h, --help display this usage message and exit
40 echo "Error: Unknown option '${1}'" 1>&2
49 [ "x$1" = "x" ] && { usage 1>&2; exit 1; }
51 [ -d "$1" ] && { echo "Aborting, project directory already exists." 1>&2; exit 1; }
55 command -v composer &> /dev/null || { echo "Aborting, 'composer' not available." 1>&2; exit 1; }
56 command -v git &> /dev/null || { echo "Aborting, 'git' not available." 1>&2; exit 1; }
58 # Create a new project keeping the VCS metadata so it's easier to bring in
59 # updates to drupal-composer/drupal-project itself.
60 echo "Creating a new Drupal project..."
61 composer create-project drupal-composer/drupal-project:8.x-dev@dev "$DESTDIR" --keep-vcs --stability dev --no-interaction
65 git remote rename origin upstream
66 git checkout -b master
68 # Add some patches, use sed until composer can do that from the command line
69 # (e.g. composer config ...)
70 sed -i -e 's@"extra": {@"extra": {\
71 "patches-file": "composer.patches.json",@' composer.json
73 cat > composer.patches.json <<EOF
77 "drupal-do_not_disable_MultiViews_htaccess": "https://www.drupal.org/files/issues/drupal-do_not_disable_MultiViews_htaccess-2619250-24.patch"
86 # Add a template config file for the bootstrap script
87 cat > bootstrap.conf <<EOF
88 #DB_NAME="drupal_test_database"
89 #DB_USER="drupal_test_user"
90 #DB_PASS="drupal_test_password"
94 #ACCOUNT_MAIL="admin@example.com"
97 #SITE_MAIL="admin@example.com"
99 #SITE_BASE_PATH="/~${USER}/$(basename "${PWD}")/web"
101 #WEB_SERVER_GROUP="www-data"
103 #INSTALLATION_PROFILE="standard"
111 #MYSQL_ROOT_PASSWORD="password"
114 cat > .gitignore <<EOF
115 # Ignore the configuration for the bootstrap script
120 echo "Uncomment and customize the values in the bootstrap.conf file."
122 # Add some basic access control to protect sensitive files like bootstrap.conf
123 cat > .htaccess <<EOF
125 SetEnvIf Request_URI "/web(/.*)?$" access_granted
127 Allow from env=access_granted
131 echo "Double check the provided .htaccess file to make sure that access to"
132 echo "'$PWD' is restricted by the web server."