forked from oxyc/Drupal-Build
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrupal
More file actions
executable file
·351 lines (291 loc) · 9.34 KB
/
drupal
File metadata and controls
executable file
·351 lines (291 loc) · 9.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#!/bin/bash
# TODO
# Figure out how to import WYSIWYG settings
#
# ERROR (Check modules)
# Warning: Division by zero in theme_image_style_preview() (line 786 of /home/oxy/Projects/Drupal/dev/modules/image/image.admin.inc).
# Warning: array_intersect_key(): Argument #1 is not an array in theme_image_style_preview() (line 788 of /home/oxy/Projects/Drupal/dev/modules/image/image.admin.inc).)))))
# Notice: Undefined index: fields in field_info_fields() (line 592 of /home/oxy/Projects/Drupal/dev/modules/field/field.info.inc).
# Warning: Invalid argument supplied for foreach() in field_info_fields() (line 592 of /home/oxy/Projects/Drupal/dev/modules/field/field.info.inc).
# Notice: Undefined index: fields in field_info_fields() (line 592 of /home/oxy/Projects/Drupal/dev/modules/field/field.info.inc).
# Warning: Invalid argument supplied for foreach() in field_info_fields() (line 592 of /home/oxy/Projects/Drupal/dev/modules/field/field.info.inc).
PROGNAME=${0##*/}
PROGVERSION=0.1
# Drush Configuration
DRUSH_ALIAS_DIR="$HOME/.drush/aliases" # remember to add the dir in your drushrc.php
DRUSH_MAKE_FILE="$HOME/.drush/drush_make/base.make"
DRUSH_MAKE_FLAGS=
# Development station
DEV_ROOT="$HOME/Projects/Drupal" # root directory where drupal projects are stored
DEV_DB_URL="mysql://root@localhost/" # used to create the database and grant privileges
DEV_DB_USER="oxy" # user account drupal will use to connect to db
DEV_HOST="http://oxy.zapto.org/Drupal" # URL to the local host root, domain will be a subdir
# User ID 1 Configuration
USER="admin"
PASS="admin"
MAIL="[email protected]"
# Extra
PUBLIC_KEY="$HOME/.ssh/id_rsa.pub"
SENDKEY= # transfer your public key during deployment
INSTALL_ROOT="`pwd`" # setup drupal in current working dir
# Variables set through user input
SITE_ID= # unique identifier used for the domain
SITE_PATH=
SITE_TITLE=
SITE_LANG=
SITE_PROFILE="minimal"
# Live station, variables set through user input
LIVE_ROOT="public_html" # root directory
LIVE_DB_PROTOCOL="mysql://"
LIVE_DB_USER=
LIVE_DB_PASSWORD=
LIVE_DB=
LIVE_USER=
LIVE_PASSWORD=
LIVE_HOST=
STYLUS_DIR="sites/all/themes/base/stylus"
CSS_DIR="sites/all/themes/base/css"
# Enabled by default
# block field field_sql_storage filter node options system text user
#
# @TODO
# Toolbar needs to be added for moderators only
MODULES_CORE=(
menu field_ui taxonomy
contextual dashboard shortcut help overlay path
file image list number
)
MODULES_CONTRIB=(
libraries
variable variable_admin variable_realm variable_store
entity token entity_token
ctools views views_ui bean bean_admin_ui
pathauto page_title metatag metatag_ui
date date_api date_popup date_popup_authored date_views
media media_browser_plus smartcrop colorbox colorbox_file
devel admin_menu admin_menu_toolbar admin_devel
elements html5_tools blocktheme semanticviews
wysiwyg invisimail menu_block transliteration
features
googleanalytics
misc_hooks stylus
agrcache backports chrome_frame simplified_menu_admin styleguide addanother
views_slideshow views_slideshow_cycle
)
MODULES_FEATURES=(
feature_core feature_content feature_bean feature_development
)
MODULES_THEME=(
base
)
MODULES_I18N=(
translation translation_helpers
i18n i18n_block i18n_field i18n_node i18n_menu i18n_path i18n_redirect
i18n_select i18n_string i18n_sync i18n_translation i18n_variable l10n_update
)
MODULES_DISABLE=(
)
# Use `drush vget` and look through for what you find interesting
declare -A VARIABLES=(
["blocktheme_show_custom_block_theme"]=1
["blocktheme_themes"]="min|Minimalism"
["admin_menu_tweak_tabs"]=1
["configurable_timezones"]=0
["date_default_timezone"]="Europe/Helsinki"
["date_first_day"]="1"
["date_format_html5_tools_iso8601"]="c"
["date_format_ymd"]="Y-m-d"
["html5_tools_override_views_field_rewrite_elements"]=1
["ie6nomore_ie"]="lt IE 7"
["image_jpeg_quality"]="100"
["menu_block_suppress_core"]=1
["pathauto_node_pattern"]="[node:title]"
["pathauto_reduce_ascii"]=1
["pathauto_transliterate"]=1
["pathauto_update_action"]="2"
["site_default_country"]="FI"
["user_admin_role"]="3"
["user_cancel_method"]="user_cancel_block"
["user_default_timezone"]="0"
["user_email_verification"]=0
["user_register"]="0"
["admin_theme"]="seven"
["node_admin_theme"]=1
["i18n_select_missing_translation"]=1
["i18n_hide_translation_links"]=1
["devel_rebuild_theme_registry"]=1
)
# Help info
usage() {
cat << EOF
Usage: $PROGNAME [options]
$PROGNAME -o <version> -c
Drupal make script. Creates a new directory with the domain name within the
specified path.
Options:
EOF
cat << EOF | column -s\& -t
-h | help & show this output
-v | version & show version information
-d | deploy
-s | sync with remote host
-m | make the drupal project
EOF
}
# Drupal make, gathers user input and invokes drush make
make() {
doing "Making Drupal site"
echo -n "Enter the domain identifier: "
read SITE_ID
echo -n "Enter the title of the website: "
read SITE_TITLE
echo -n "Enter the language(s) to be included in the install separated by a comma: "
read SITE_LANG
SITE_PATH=${INSTALL_ROOT}/${SITE_ID}
# Check to see if the install directory already exists
if [ -d $SITE_PATH ]; then
echo -e "$SITE_PATH already exists."
exit 1
fi
setup
}
# Deploy the site to remote host
deploy() {
doing "Deploy website to remote host"
echo -n "Enter the domain identifier: "
read DOMAIN_ID
echo -n "Enter the remote host address: "
read LIVE_HOST
echo -n "Enter the remote user: "
read LIVE_USER
echo -n "Enter the remote user password: "
read LIVE_PASSWORD
echo -n "Enter the remote DB user: "
read LIVE_DB_USER
echo -n "Enter the remote DB password: "
read LIVE_DB_PASSWORD
echo -n "Enter the remote DB name: "
read LIVE_DB
createAlias
if [ $SENDKEY ]; then
sendKey
fi
sync
}
# Sync local and remote host
sync() {
doing "Pushing site live"
}
# Create the Drupal site with info supplied from the make function
setup() {
doing "Setting up the install at ${SITE_PATH}"
if [ [ $SITE_LANG != "en" ] || [ $SITE_LANG ] ]; then
drush make ${DRUSH_MAKE_FLAGS} --translations=${SITE_LANG} ${DRUSH_MAKE_FILE} ${SITE_PATH}
else
drush make ${MAKE_FLAGS} ${DRUSH_MAKE_FILE} ${SITE_PATH}
fi
cd $SITE_PATH
doing "Installing Drupal…"
local DB="--db-url=${DEV_DB_URL}${SITE_ID}"
drush -y site-install ${SITE_PROFILE} ${DB} --locale=${SITE_LANG} --site-name=${SITE_TITLE} --account-name=${USER} --account-pass=${PASS} --account-mail=${MAIL}
doing "Granting privileges to database user"
mysql -uroot -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON ${SITE_ID}.* TO '${DEV_DB_USER}'@'localhost';"
mysql -uroot -e "FLUSH PRIVILEGES;"
# Enable desired modules
enableModules ${MODULES_CORE[@]} ${MODULES_CONTRIB[@]} ${MODULES_FEATURES[@]} ${MODULES_THEME[@]}
#setVariables VARIABLES
doing "Allow write access to files folder"
chmod -R a+w ./sites/default/files
doing "Finished the installation!"
google-chrome `drush --uri=${DEV_HOST}/${SITE_ID} user-login`
}
# Enable modules
enableModules() {
for arg in $*; do
for module in "${arg[@]}"; do
drush -y pm-enable $module
done
done
}
# Set variables.
# Pass the array name as a string
# TODO: Looking for a non-evil solution with an actual array reference
# http://stackoverflow.com/questions/4069188/how-to-pass-an-associative-array-as-argument-to-a-function-in-bash
setVariables() {
for arg in $*; do
for var in $(eval echo \${!${arg}[@]}); do
drush vset --always-set ${var} $(eval echo \${${arg}["$var"]})
done
done
}
# Create an alias file for the current drupal build
createAlias() {
cat > ${DRUSH_ALIAS_DIR}/${DOMAIN_ID}.aliases.drushrc.php << EOF
\$aliases['dev'] = array(
'root' => '${DEV_ROOT}/${DIR}',
'uri' => '${DEV_HOST}/${DIR}
);
\$aliases['live'] = array(
'root' => '${LIVE_ROOT}',
'uri' => '${LIVE_HOST}'
'db-url' => '${LIVE_DB_PROTOCOL}${LIVE_DB_USER}:${LIVE_DB_PASSWORD}@localhost/${LIVE_DB}
'remote-host' => '${LIVE_HOST}',
'remote-user' => '${LIVE_USER}',
)
);
EOF
}
# Send Public key over ssh to remote host
sendKey() {
local DOMAIN=$LIVE_HOST | awk '{gsub("http://|www.|/.*","")}1'
ssh -q -t -l ${LIVE_USER} ${DOMAIN} "umask 077; mkdir -p .ssh && cat >> .ssh/authorized_keys" < ${PUBLIC_KEY}
}
stylusWatch() {
stylus --watch --line-numbers ${INSTALL_ROOT}/${STYLUS_DIR} --out ${INSTALL_ROOT}/${CSS_DIR}
}
# Streamline echoing status
doing() {
echo -e "\n$1"
}
# Check command flags invoked and store possible argumets
while getopts ":depmshvV" opt; do
case $opt in
d) #deploy
deploy
;;
p) #publickey
SENDKEY=1
;;
m) #make
make
exit 0
;;
s) #sync
sync
exit 0
;;
e) #enable modules
enableModules ${MODULES_CORE[@]} ${MODULES_CONTRIB[@]} ${MODULES_FEATURES[@]} ${MODULES_THEME[@]}
;;
V) #set variables
#setVariables VARIABLES
;;
# base flags
h)
usage
exit 0
;;
v)
echo "$PROGVERSION"
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done