-
Notifications
You must be signed in to change notification settings - Fork 75
/
OCTOPUS.sh.txt
executable file
·294 lines (241 loc) · 6.54 KB
/
OCTOPUS.sh.txt
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
#!/bin/bash
###----------------------------------------###
###
### Octopus Aegir Installer
###
### Copyright (C) 2010-2024 Omega8.cc
### [email protected] www.omega8.cc
###
### This program is free software. You can
### redistribute it and/or modify it under
### the terms of the GNU GPL as published by
### the Free Software Foundation, version 2
### or later.
###
### This program is distributed in the hope
### that it will be useful, but WITHOUT ANY
### WARRANTY; without even the implied
### warranty of MERCHANTABILITY or FITNESS
### FOR A PARTICULAR PURPOSE. See the GNU GPL
### for more details.
###
### You should have received a copy of the
### GNU GPL along with this program.
### If not, see http://www.gnu.org/licenses/
###
### Code: https://github.com/omega8cc/boa
###
###----------------------------------------###
export PATH=/usr/local/bin:/usr/local/sbin:/opt/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
export SHELL=/bin/bash
###
### Default values for main Octopus instance variables
###
_USER=o1
_MY_EMAIL="[email protected]"
_CLIENT_EMAIL="[email protected]"
_CLIENT_OPTION=POWER
_CLIENT_SUBSCR=M
_CLIENT_CORES=1
###
### Required by AegirSetupA script, running in
### the same env, to avoid chicken/egg race.
###
export _USER="${_USER}"
###
### Drush and Redis Variables
###
export _DRUSH_VERSION=8.4.12.9
export _REDIS_C_VERSION=com-19-04-2021
export _REDIS_L_VERSION=7.x-3.19.1
export _REDIS_N_VERSION=com-19-04-2021
export _REDIS_T_VERSION=8.x-1.8.2
###
### Drupal Core Versions
###
export _SMALLCORE10_0_V=10.0.11
export _SMALLCORE10_1_V=10.1.8
export _SMALLCORE10_2_V=10.2.10
export _SMALLCORE10_3_V=10.3.6
export _SMALLCORE10_4_V=10.4.x-dev
export _SMALLCORE6_V=6.60.1
export _SMALLCORE7_V=7.101.1
export _SMALLCORE9_V=9.5.11
###
### Drupal Core Variables
###
export _DRUPAL6="pressflow-${_SMALLCORE6_V}"
export _DRUPAL7="drupal-${_SMALLCORE7_V}"
export _DRUPAL9="drupal-${_SMALLCORE9_V}"
export _DRUPAL10_0="drupal-${_SMALLCORE10_0_V}"
export _DRUPAL10_1="drupal-${_SMALLCORE10_1_V}"
export _DRUPAL10_2="drupal-${_SMALLCORE10_2_V}"
export _DRUPAL10_3="drupal-${_SMALLCORE10_3_V}"
export _DRUPAL10_4="drupal-${_SMALLCORE10_4_V}"
export _DRUPAL6_D="${_DRUPAL6}-dev"
export _DRUPAL6_P="${_DRUPAL6}-prod"
export _DRUPAL6_S="${_DRUPAL6}-stage"
export _DRUPAL7_D="${_DRUPAL7}-dev"
export _DRUPAL7_P="${_DRUPAL7}-prod"
export _DRUPAL7_S="${_DRUPAL7}-stage"
export _DRUPAL9_D="${_DRUPAL9}-dev"
export _DRUPAL9_P="${_DRUPAL9}-prod"
export _DRUPAL9_S="${_DRUPAL9}-stage"
export _DRUPAL10_0_D="${_DRUPAL10_0}-dev"
export _DRUPAL10_0_P="${_DRUPAL10_0}-prod"
export _DRUPAL10_0_S="${_DRUPAL10_0}-stage"
export _DRUPAL10_1_D="${_DRUPAL10_1}-dev"
export _DRUPAL10_1_P="${_DRUPAL10_1}-prod"
export _DRUPAL10_1_S="${_DRUPAL10_1}-stage"
export _DRUPAL10_2_D="${_DRUPAL10_2}-dev"
export _DRUPAL10_2_P="${_DRUPAL10_2}-prod"
export _DRUPAL10_2_S="${_DRUPAL10_2}-stage"
export _DRUPAL10_3_D="${_DRUPAL10_3}-dev"
export _DRUPAL10_3_P="${_DRUPAL10_3}-prod"
export _DRUPAL10_3_S="${_DRUPAL10_3}-stage"
export _DRUPAL10_4_D="${_DRUPAL10_4}-dev"
export _DRUPAL10_4_P="${_DRUPAL10_4}-prod"
export _DRUPAL10_4_S="${_DRUPAL10_4}-stage"
export _SPINNER=NO
export _T_BUILD=SRC
export _USRG=users
export _WEBG=www-data
if [ -n "${STY+x}" ]; then
export _SPINNER=NO
fi
export _F_TIME=$(date 2>&1)
###
### Instance specific variables
###
export _WEB="${_USER}.web"
export _DOMAIN="${_USER}.$(uname -n 2>&1)"
export _ROOT="/data/disk/${_USER}"
export _THIS_DB_PORT=3306
export _octCnf="/root/.${_USER}.octopus.cnf"
export _octInc="${_ROOT}/config/includes"
export _octTpl="${_ROOT}/.drush/sys/provision/http/Provision/Config/Nginx"
export _octSetTpl="${_ROOT}/.drush/sys/provision/Provision/Config/Drupal"
###
### Helper variables
###
export _bldPth="/opt/tmp/boa"
export _crlGet="-L --max-redirs 3 -k -s --retry 9 --retry-delay 9 -A iCab"
export _wgetGet="--max-redirect=3 --no-check-certificate -q --tries=9 --wait=9 --user-agent='iCab'"
export _filIncO="octopus.sh.cnf"
export _gCb="git clone --branch"
export _gitHub="https://github.com/omega8cc"
export _gitLab="https://gitlab.com/omega8cc"
export _libFnc="${_bldPth}/lib/functions"
export _tocIncO="${_filIncO}.${_USER}"
export _vBs="/var/backups"
###
### Avoid too many questions
###
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
if [ -z "${TERM+x}" ]; then
export TERM=vt100
fi
###
### Clean pid files on exit
###
_clean_pid_exit() {
echo "REASON ${e} on $(date 2>&1)" >> /root/.octopus.sh.exit.exceptions.log
[ -e "/run/boa_wait.pid" ] && rm -f /run/boa_wait.pid
[ -e "/run/boa_run.pid" ] && rm -f /run/boa_run.pid
service cron start &> /dev/null
exit 1
}
###
### Panic on missing include
###
_panic_exit() {
echo
echo " EXIT: Required lib file not available?"
echo " EXIT: $1"
echo " EXIT: Cannot continue"
echo " EXIT: Bye (0)"
echo
_clean_pid_exit _panic_exit_a
}
###
### Include default settings and basic functions
###
if [ -e "${_vBs}/${_tocIncO}" ]; then
source "${_vBs}/${_tocIncO}"
_tInc="${_vBs}/${_tocIncO}"
elif [ -e "${_vBs}/${_filIncO}" ]; then
source "${_vBs}/${_filIncO}"
_tInc="${_vBs}/${_filIncO}"
else
_panic_exit "${_tInc}"
fi
###
### Download helpers and libs
###
_download_helpers_libs
###
### Include shared functions
###
_FL="helper dns satellite"
for f in ${_FL}; do
[ -r "${_libFnc}/${f}.sh.inc" ] || _panic_exit "${f}"
source "${_libFnc}/${f}.sh.inc"
done
###
### Welcome msg
###
echo " "
_msg "Skynet Agent v.${_X_VERSION} on $(dmidecode -s system-manufacturer 2>&1) welcomes you aboard!"
echo " "
sleep 3
###
### Turn Off AppArmor while running octopus
###
_turn_off_apparmor_in_octopus
###
### Switch to bash while running octopus
###
_switch_to_bash_in_octopus
###
### More local default variables
###
_LASTNUM=001
_LAST_HMR=001
_LAST_ALL=001
_DISTRO=001
_HM_DISTRO=001
_ALL_DISTRO=001
_STATUS=INIT
###
### Misc checks
###
_satellite_check_php_compatibility
_satellite_check_octopus_vs_barracuda_ver
_satellite_if_head_github_connection_test
_satellite_if_sql_exception_test
_satellite_if_running_as_root_octopus
_satellite_check_sanitize_user_name
_satellite_if_localhost_mode_magic
_satellite_check_sanitize_domain_name
_satellite_detect_vm_family
_check_git_repos
###
### Main procedures
###
_satellite_cnf
_satellite_if_init_or_upgrade
_satellite_if_major_upgrade
_satellite_if_check_dns
_satellite_checkpoint
_satellite_pre_cleanup
_satellite_make
_satellite_post_cleanup
exit 0
###----------------------------------------###
###
### Octopus Aegir Installer
### Copyright (C) 2010-2024 Omega8.cc
### [email protected] www.omega8.cc
###
###----------------------------------------###