-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrigger
executable file
·170 lines (140 loc) · 4.95 KB
/
trigger
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
#!/bin/bash
#===============================================================================
#
# FILE: trigger
# DESCRIPTION: this bash file must be executed from the root of a Drupal
# installation.
#===============================================================================
#-------------------------------------------------------------------------------
# includes
#-------------------------------------------------------------------------------
source sites/all/scripts/tasks/includes/paths
source sites/all/scripts/tasks/includes/variables
#-------------------------------------------------------------------------------
# run tasks
#-------------------------------------------------------------------------------
while getopts ":t:h" OPTION; do
case $OPTION in
t)
#--------------
# RELEASE TASK
#--------------
if [ "$OPTARG" == "releases" ]; then
TASK=$OPTARG
while getopts ":r:" TR
do
case $TR in
r)
RELEASE=$OPTARG
if [ "$RELEASE" == "all" ]; then
echo -e "\033[36mNOTICE:\033[0m releases less than the current release will be skipped." >&2
for f in $TASKS_PATH/releases/*.rse;
do
RELEASE_NORM=`echo ${f//[^0-9]/}`
./$f -r $RELEASE_NORM
done
exit
elif [ "$RELEASE" == "status" ]; then
$DRUSH vget $VGET_RELEASE
exit
elif [ "$RELEASE" == "update" ]; then
VGET=`$DRUSH vget $VGET_RELEASE`
CURRENT_RELEASE=`echo ${VGET//[^0-9]/}`
CURRENT_RELEASE=`printf %04d ${CURRENT_RELEASE%}`
echo -e "\033[36mNOTICE:\033[0m updating your installation to the most current release." >&2
declare -a RSE_FILES
RSE_FILES=($TASKS_PATH/releases/*.rse)
pos=$(( ${#RSE_FILES[*]} - 1 ))
last=${RSE_FILES[$pos]}
for f in "${RSE_FILES[@]}"; do
if [[ $f == $last ]]; then
RELEASE_UPDATE_COMPLETE="TRUE"
fi
RELEASE_NORM=`echo ${f//[^0-9]/}`
if [ $RELEASE_NORM -ge $CURRENT_RELEASE ]; then
./$f -r $RELEASE_NORM -l $RELEASE_UPDATE_COMPLETE
fi
done
exit
fi
;;
:)
echo -e "\033[31mWARNING:\033[0m option -$OPTARG requires an argument." >&2
exit 1
;;
?)
echo -e "\033[31mERROR:\033[0m Invalid option: -$OPTARG" >&2
more $TASKS_PATH/releases/includes/help
exit
;;
esac
done
if [ -z $RELEASE ]; then
echo -e "\033[31mERROR:\033[0m The \033[1mreleases\033[0m tasks requires a release number to be run." >&2
exit
fi
if [ ! -f $TASKS_PATH/$TASK/$RELEASE.rse ]; then
echo -e "\033[31mERROR:\033[0m The release $RELEASE.rse was not found." >&2
exit
fi
./$TASKS_PATH/$TASK/$RELEASE.rse -r $RELEASE
#------------------
# INTALLATION TASK
#------------------
elif [ "$OPTARG" == "install" ]; then
id -u
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo "Not running as root"
exit
fi
while getopts ":u:p:n:" DB_CONFIG; do
case $DB_CONFIG in
u) DB_USER=$OPTARG ;;
p) DB_PASS=$OPTARG ;;
n) DB_NAME=$OPTARG ;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
h)
echo -e `cat $TASKS_PATH/install/includes/help` >&2
exit
;;
esac
done
if [[ -z $DB_USER ]] || [[ -z $DB_NAME ]]; then
more $TASKS_PATH/install/includes/help
exit
fi
cp sites/default/default.settings.php sites/default/settings.php
$DRUSH si minimal --db-url=mysql://$DB_USER:$DB_PASS@localhost/$DB_NAME
$DRUSH upwd admin --password="admin"
cat sites/all/scripts/settings.php/local.settings.php >> sites/default/settings.php
exit
# run all the releases
./$TASKS_PATH/trigger -t releases -r update
mkdir $FILES_PATH/cache
echo "cache dir created in $FILES_PATH"
mkdir $FILES_PATH/cache/third_party_mod
echo "third_party_mod dir created in $FILES_PATH"
fi
;;
:)
echo -e "\033[31mWARNING:\033[0m option -$OPTARG requires an argument." >&2
exit 1
;;
h)
more $TASKS_PATH/includes/help
exit
;;
?)
echo -e "\033[31mERROR:\033[0m Invalid option: -$OPTARG" >&2
more $TASKS_PATH/includes/help
exit
;;
esac
done
exit