forked from infiniteluke/todo_restful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade
executable file
·193 lines (160 loc) · 6.39 KB
/
upgrade
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
#!/bin/bash
################################################################################
#
# This script will upgrade a working copy of the Installation Profile.
#
# Do not change the content of this file,
# all configuration variables are in the config.sh file.
#
################################################################################
# Define the root of the GIT repository.
cd ${0%/*}
ROOT=$(pwd)
cd $ROOT
# Load the colors.
source $ROOT/scripts/helper-colors.sh
# Load the helpers.
source $ROOT/scripts/helper-functions.sh
# Load the configuration.
load_config_file
# Check config
check_config_file
##
# Function to explain the script arguments.
##
function arguments_usage {
TITLE=$(fill_string_spaces "Upgrade $PROFILE_TITLE" 61)
USAGE=$(fill_string_spaces "Usage: $0 [options]" 61)
echo
echo -e "${BGCYAN} ${RESTORE}"
echo -e "${BGLCYAN} $TITLE ${RESTORE}"
echo -e "${BGCYAN} This will upgrade the Drupal core and Contrib modules. ${RESTORE}"
echo -e "${BGCYAN} This will run the database update trough Drush. ${RESTORE}"
echo -e "${BGCYAN} ${RESTORE}"
echo -e "${BGCYAN} $USAGE ${RESTORE}"
echo -e "${BGCYAN} ${RESTORE}"
echo -e "${BGCYAN} OPTIONS: ${RESTORE}"
echo -e "${BGCYAN} -h Show this message ${RESTORE}"
echo -e "${BGCYAN} -d Load or update demo content after the installation ${RESTORE}"
echo -e "${BGCYAN} -l Open a new tab in your default browser and login to ${RESTORE}"
echo -e "${BGCYAN} your project as the Administrator. ${RESTORE}"
echo -e "${BGCYAN} -y Answer automatically yes to the confirmation questions. ${RESTORE}"
echo -e "${BGCYAN} ${RESTORE}"
echo
}
# Check and process arguments.
# See http://rsalveti.wordpress.com/2007/04/03/bash-parsing-arguments-with-getopts/
while getopts "hdly" OPTION
do
case $OPTION in
h)
arguments_usage
exit 1
;;
d)
DEMO_CONTENT=1
;;
l)
AUTO_LOGIN=1
;;
y)
UNATTENDED=1
;;
?)
arguments_usage
exit
;;
esac
done
# Check if we have a working Drupal bootstrap.
cd $ROOT/www
BOOTSTRAP_SUCCESS=`drush status grep "Drupal bootstrap" | grep "Successful"`
cd $ROOT
if [ ! "$BOOTSTRAP_SUCCESS" ]; then
echo
echo -e "${BGRED} ${RESTORE}"
echo -e "${BGLRED} No working Drupal installation! ${RESTORE}"
echo -e "${BGRED} > Drupal Bootstrap could not complete successfully. ${RESTORE}"
echo -e "${BGRED} > An upgrade can only be run on a working environment. ${RESTORE}"
echo -e "${BGRED} ${RESTORE}"
echo -e "${BGRED} Run the ${BGLRED}./install${BGRED} command to install the platform. ${RESTORE}"
echo -e "${BGRED} ${RESTORE}"
echo
exit 1
fi
# Always ask confirmation before updating Files!
TITLE=$(fill_string_spaces "Upgrade $PROFILE_TITLE" 61)
echo
echo -e "${BGBLUE} ${RESTORE}"
echo -e "${BGLBLUE} $TITLE ${RESTORE}"
echo -e "${BGBLUE} ${RESTORE}"
echo -e "${BGBLUE} > This will upgrade core and contrib modules & themes. ${RESTORE}"
echo -e "${BGBLUE} > This will run the update db command (drush updb). ${RESTORE}"
if [ $DEMO_CONTENT ] || [ $AUTO_LOGIN ]; then
echo -e "${BGBLUE} ${RESTORE}"
fi
if [ $DEMO_CONTENT ]; then
echo -e "${BGBLUE} • Demo content will be loaded into the platform. ${RESTORE}"
fi
if [ $AUTO_LOGIN ]; then
echo -e "${BGBLUE} • A browser tab will open and log you in as Administrator. ${RESTORE}"
fi
echo -e "${BGBLUE} ${RESTORE}"
echo
if [ ! $UNATTENDED ]; then
echo -e -n "${LRED}Are you sure?${RESTORE} (Y/n) "
read -e -n 1 -r
if [[ ! $REPLY =~ ^[Y]$ ]]; then
echo
echo -e "${BGYELLOW} ${RESTORE}"
echo -e "${BGLYELLOW} Upgrade aborted! ${RESTORE}"
echo -e "${BGYELLOW} ${RESTORE}"
echo
exit 0
fi
echo
fi
# Cleanup contrib modules, themes & libraries from the profile directory.
delete_profile_contrib
# Run the build script (drush make + extra's).
drupal_make
# Symlink extra modules (if any).
symlink_externals
# Update the database.
echo -e "${LBLUE}> Run the Update Database script (drush -y updb)${RESTORE}"
cd $ROOT/www
drush -y updb
cd $ROOT
echo
if [ $DEMO_CONTENT ]; then
import_demo_content
fi
# Run post script (if any).
run_post_script "upgrade"
# Check if we have a working bootstrap.
cd $ROOT/www
BOOTSTRAP_SUCCESS=`drush status grep "Drupal bootstrap" | grep "Successful"`
cd $ROOT
if [ ! "$BOOTSTRAP_SUCCESS" ]; then
echo
echo -e "${BGRED} ${RESTORE}"
echo -e "${BGLRED} Upgrade failure! ${RESTORE}"
echo -e "${BGRED} > Drupal Bootstrap could not complete successfully. ${RESTORE}"
echo -e "${BGRED} ${RESTORE}"
echo
exit 1
fi
# If we managed to get here then the upgrade was a success!
LINK_INFO=$(fill_string_spaces "> Visit the site : ${BGLGREEN}$BASE_DOMAIN_URL${BGGREEN}" 89)
echo
echo -e "${BGGREEN} ${RESTORE}"
echo -e "${BGLGREEN} Upgrade complete! ${RESTORE}"
echo -e "${BGGREEN} $LINK_INFO ${RESTORE}"
echo -e "${BGGREEN} ${RESTORE}"
echo
# Auto Login?
if [ $AUTO_LOGIN ]; then
drupal_login
fi
# DONE!
exit 0