-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfunctions
More file actions
571 lines (507 loc) · 19.3 KB
/
Copy pathfunctions
File metadata and controls
571 lines (507 loc) · 19.3 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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
#!/usr/bin/env bash
# These functions have been adapted from
# https://github.com/dokku/dokku/blob/master/plugins/common/functions
# DPkg lock-wait tiers, activated by EE_APT_LOCK_WAIT. Duplicated from
# setup.sh so the tier vars stay defined (no-op) when this file is sourced
# standalone by migrate.sh / remote-migrate — note those scripts' own
# apt-get calls and remote (ssh) installs do not inherit the wait.
# Any non-empty EE_APT_LOCK_WAIT (e.g. =1) enables the dpkg lock-wait; it is an
# on/off flag, not a duration (the timeouts below are fixed). Tier variables
# are left empty (no-op) when unset.
if [ -n "${EE_APT_LOCK_WAIT:-}" ]; then
_EE_APT_LOCK_LIGHT_INSTALL="-o DPkg::Lock::Timeout=900"
_EE_APT_LOCK_INSTALL="-o DPkg::Lock::Timeout=1800"
else
_EE_APT_LOCK_LIGHT_INSTALL="${_EE_APT_LOCK_LIGHT_INSTALL:-}"
_EE_APT_LOCK_INSTALL="${_EE_APT_LOCK_INSTALL:-}"
fi
ee_apt_update() {
local i err
for i in $(seq 1 30); do
if err="$(apt-get update 2>&1)"; then printf '%s\n' "$err"; return 0; fi
printf '%s\n' "$err" >&2
printf '%s' "$err" | grep -qiE "Could not get lock|Unable to lock" || return 1
ee_log_info2 "apt lists lock busy; retrying in 10s"
sleep 10
done
apt-get update
}
has_tty() {
declare desc="return 0 if we have a tty"
if [[ "$(/usr/bin/tty || true)" == "not a tty" ]]; then
return 1
else
return 0
fi
}
ee_log_quiet() {
declare desc="log quiet formatter"
if [[ -z "$EE_QUIET_OUTPUT" ]]; then
echo "$*"
fi
}
ee_log_info1() {
declare desc="log info1 formatter"
echo "-----> $*"
}
ee_log_info2() {
declare desc="log info2 formatter"
echo "=====> $*"
}
ee_log_info1_quiet() {
declare desc="log info1 formatter (with quiet option)"
if [[ -z "$EE_QUIET_OUTPUT" ]]; then
echo "-----> $*"
else
return 0
fi
}
ee_log_info2_quiet() {
declare desc="log info2 formatter (with quiet option)"
if [[ -z "$EE_QUIET_OUTPUT" ]]; then
echo "=====> $*"
else
return 0
fi
}
ee_col_log_info1() {
declare desc="columnar log info1 formatter"
printf "%-6s %-18s %-25s %-25s %-25s\n" "----->" "$@"
}
ee_col_log_info1_quiet() {
declare desc="columnar log info1 formatter (with quiet option)"
if [[ -z "$EE_QUIET_OUTPUT" ]]; then
printf "%-6s %-18s %-25s %-25s %-25s\n" "----->" "$@"
else
return 0
fi
}
ee_col_log_info2() {
declare desc="columnar log info2 formatter"
printf "%-6s %-18s %-25s %-25s %-25s\n" "=====>" "$@"
}
ee_col_log_info2_quiet() {
declare desc="columnar log info2 formatter (with quiet option)"
if [[ -z "$EE_QUIET_OUTPUT" ]]; then
printf "%-6s %-18s %-25s %-25s %-25s\n" "=====>" "$@"
else
return 0
fi
}
ee_col_log_msg() {
declare desc="columnar log formatter"
printf "%-25s %-25s %-25s %-25s\n" "$@"
}
ee_col_log_msg_quiet() {
declare desc="columnar log formatter (with quiet option)"
if [[ -z "$EE_QUIET_OUTPUT" ]]; then
printf "%-25s %-25s %-25s %-25s\n" "$@"
else
return 0
fi
}
ee_log_verbose_quiet() {
declare desc="log verbose formatter (with quiet option)"
if [[ -z "$EE_QUIET_OUTPUT" ]]; then
echo " $*"
else
return 0
fi
}
ee_log_verbose() {
declare desc="log verbose formatter"
echo " $*"
}
ee_log_warn() {
declare desc="log warning formatter"
echo " ! $*" 1>&2
}
ee_log_fail() {
declare desc="log fail formatter"
echo "$@" 1>&2
exit 1
}
parse_args() {
declare desc="top-level cli arg parser"
local next_index=1
local skip=false
local args=("$@")
for arg in "$@"; do
if [[ "$skip" == "true" ]]; then
next_index=$((next_index + 1))
skip=false
continue
fi
case "$arg" in
--quiet)
export EE_QUIET_OUTPUT=1
;;
--trace)
export EE_TRACE=1
;;
--dry-run)
export EE_DRY_RUN=1
;;
--all)
export EE_SITE_ALL=1
;;
--remote-host)
export REMOTE_HOST=${args[$next_index]}
skip=true
;;
esac
next_index=$((next_index + 1))
done
return 0
}
function check_ssh() {
ee_log_info1 "Checking connection to remote server."
ssh -q -i $SSH_KEY "root@$REMOTE_HOST" exit >/dev/null 2>&1 # No need to show this output
if [ $? -eq 0 ]; then
true
else
if [ ! -f "$SSH_KEY" ]; then
ssh-keygen -t rsa -b 4096 -N '' -C 'ee3_to_ee4_key' -f $SSH_KEY >/dev/null 2>&1 # No need to show this output
else
ee_log_info2 "If you have not done so already, you need to add the following"
cat "${SSH_KEY}.pub"
ee_log_info2 "to \`/root/.ssh/authorized_keys\` on the remote server"
ee_log_fail "Unable to connect to remote server. Please check if \`ssh root@$REMOTE_HOST\` is working."
false
fi
ee_log_info2 "Add the following"
cat "${SSH_KEY}.pub"
ee_log_info2 "to \`/root/.ssh/authorized_keys\` on the remote server"
false
fi
}
function run_remote_command() {
declare desc="run_remote_command COMMAND [HOST:$REMOTE_HOST] [DIR:/root] [USER:root]"
COMMAND="$1"
HOST="${2:-$REMOTE_HOST}"
DIR="${3:-/root}"
USER="${4:-root}"
ssh -i $SSH_KEY $USER@$HOST "source ${REMOTE_TMP_WORK_DIR}install-script; source ${REMOTE_TMP_WORK_DIR}helper-functions; $COMMAND"
}
function setup_docker() {
ee_log_info1 "Installing Docker"
# Check if docker exists. If not start docker installation.
if ! command -v docker >/dev/null 2>&1; then
# Download into TMP_WORK_DIR so setup.sh's EXIT trap cleans it up on any
# exit path, instead of leaving docker-setup.sh behind in the CWD.
wget --quiet get.docker.com -O "$TMP_WORK_DIR/docker-setup"
sh "$TMP_WORK_DIR/docker-setup"
fi
# Check if docker-compose exists. If not start docker-compose installation.
if ! command -v docker-compose >/dev/null 2>&1; then
ee_log_info1 "Installing Docker-Compose"
curl -L https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
fi
}
# Host PHP version control. EE_PHP_VERSION pins an exact <major.minor> (fails
# loudly if it can't be installed cleanly). When unset, EE_PHP_VERSION_CHOICES
# is tried version-first: each version from native repos then the ondrej/sury
# repo, before the next.
EE_PHP_VERSION="${EE_PHP_VERSION:-}"
EE_PHP_VERSION_CHOICES="${EE_PHP_VERSION_CHOICES:-8.4 8.3 8.5 8.2}"
EE_INSTALLED_PHP_VERSION="${EE_INSTALLED_PHP_VERSION:-}"
EE_PHP_THIRDPARTY_ADDED="${EE_PHP_THIRDPARTY_ADDED:-}"
# HTTP status of the ondrej/php PPA Release file for an Ubuntu codename (200/404).
get_ondrej_php_ppa_release_status() {
local ubuntu_codename="$1"
curl --location --silent --output /dev/null --write-out "%{http_code}" \
--connect-timeout 5 --max-time 10 \
"https://ppa.launchpadcontent.net/ondrej/php/ubuntu/dists/${ubuntu_codename}/Release" || true
}
# 0 if php<ver>-cli installs cleanly from current sources. Dry-run (-s) so
# unsatisfiable deps (e.g. a PPA build needing a libxml2 the OS lacks) are caught
# before touching the system.
ee_php_cli_installable() {
# -s (simulate) takes no dpkg lock, so a lock-wait option here would be a no-op
apt-get install -s "php${1}-cli" >/dev/null 2>&1
}
# Add the third-party PHP repo (ondrej/php on Ubuntu, sury on Debian), pinned to
# a codename the repo actually publishes for. Idempotent.
ee_php_add_thirdparty_repo() {
[ "$EE_PHP_THIRDPARTY_ADDED" == "1" ] && return 0
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then
apt-get $_EE_APT_LOCK_INSTALL install -y software-properties-common curl ca-certificates
add-apt-repository -ny ppa:ondrej/php || true
local want use="" c f
want="$(lsb_release -sc)"
if [ "$(get_ondrej_php_ppa_release_status "$want")" == "200" ]; then
use="$want"
else
for c in oracular noble jammy focal; do
if [ "$(get_ondrej_php_ppa_release_status "$c")" == "200" ]; then
use="$c"; break
fi
done
[ -n "$use" ] && ee_log_info2 "ondrej/php has no build for '${want}'; pinning PPA to '${use}'"
for f in /etc/apt/sources.list.d/ondrej-ubuntu-php-*.sources; do
[ -f "$f" ] && sed -i "s/^Suites: .*/Suites: ${use}/" "$f"
done
fi
# No serveable codename → drop the source so it can't 404 later, and fail.
if [ -z "$use" ]; then
rm -f /etc/apt/sources.list.d/ondrej-ubuntu-php*
return 1
fi
elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then
apt-get $_EE_APT_LOCK_INSTALL install -y apt-transport-https lsb-release ca-certificates curl locales locales-all
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
curl -fsSL https://packages.sury.org/php/apt.gpg -o /etc/apt/trusted.gpg.d/php.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
fi
ee_apt_update
EE_PHP_THIRDPARTY_ADDED=1
return 0
}
# Remove the ondrej/php PPA we added and refresh apt.
ee_php_drop_thirdparty_repo() {
[ "$EE_PHP_THIRDPARTY_ADDED" == "1" ] || return 0
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then
rm -f /etc/apt/sources.list.d/ondrej-ubuntu-php* /etc/apt/preferences.d/ee-ondrej-php
ee_apt_update
EE_PHP_THIRDPARTY_ADDED=""
fi
}
# Install the first candidate that installs cleanly, version-first. Native
# installability is snapshotted BEFORE adding the PPA: once ondrej is present its
# newer build of a natively-available version (e.g. php8.5 on 26.04) shadows the
# native one and fails to install, so native versions are taken with the PPA
# dropped. Sets EE_INSTALLED_PHP_VERSION; returns 0 on success.
ee_select_and_install_php() {
local v native_ok=" "
for v in "$@"; do
if ee_php_cli_installable "$v"; then
native_ok="${native_ok}${v} "
fi
done
for v in "$@"; do
if [[ "$native_ok" == *" ${v} "* ]]; then
# Native: drop any probe PPA so it isn't shadowed.
ee_php_drop_thirdparty_repo
ee_log_info2 "Installing PHP ${v} (native)"
apt-get $_EE_APT_LOCK_INSTALL install -y "php${v}-cli"
EE_INSTALLED_PHP_VERSION="$v"
return 0
fi
if ee_php_add_thirdparty_repo && ee_php_cli_installable "$v"; then
ee_log_info2 "Installing PHP ${v} (third-party repo)"
apt-get $_EE_APT_LOCK_INSTALL install -y "php${v}-cli"
EE_INSTALLED_PHP_VERSION="$v"
return 0
fi
ee_log_info2 "PHP ${v} not cleanly installable (native or third-party); trying next"
done
return 1
}
function setup_php() {
ee_log_info1 "Installing PHP"
# Only Ubuntu and Debian are supported for host-PHP install.
if [ "$EE_LINUX_DISTRO" != "Ubuntu" ] && [ "$EE_LINUX_DISTRO" != "Debian" ]; then
return 0
fi
local candidates
if [ -n "$EE_PHP_VERSION" ]; then
candidates="$EE_PHP_VERSION"
ee_log_info2 "PHP version pinned via EE_PHP_VERSION=${EE_PHP_VERSION}"
elif command -v php >/dev/null 2>&1; then
# Keep an existing php unless a version was pinned.
EE_INSTALLED_PHP_VERSION="$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;' 2>/dev/null)"
ee_log_info2 "Existing PHP ${EE_INSTALLED_PHP_VERSION} detected; keeping it (set EE_PHP_VERSION to override)"
return 0
else
candidates="$EE_PHP_VERSION_CHOICES"
ee_log_info2 "No PHP pinned; trying in order (version-first): ${candidates}"
fi
ee_apt_update
ee_select_and_install_php $candidates || true
# Unpinned fallback: distro default php-cli, so an unknown OS still gets a php.
if [ -z "$EE_INSTALLED_PHP_VERSION" ] && [ -z "$EE_PHP_VERSION" ]; then
if apt-get $_EE_APT_LOCK_INSTALL install -y php-cli && command -v php >/dev/null 2>&1; then
EE_INSTALLED_PHP_VERSION="$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;' 2>/dev/null)"
[ -n "$EE_INSTALLED_PHP_VERSION" ] && ee_log_info2 "Fell back to distro default php-cli (${EE_INSTALLED_PHP_VERSION})"
fi
fi
if [ -z "$EE_INSTALLED_PHP_VERSION" ]; then
# Don't leave a probe PPA behind on the loud-failure path.
ee_php_drop_thirdparty_repo
echo "ERROR: Could not install a usable PHP CLI (tried: ${candidates}) on $(lsb_release -ds 2>/dev/null || echo "$EE_LINUX_DISTRO")." >&2
echo " Set EE_PHP_VERSION=<major.minor> to a version your OS provides (e.g. EE_PHP_VERSION=8.5) and re-run." >&2
exit 1
fi
ee_log_info1 "Selected host PHP version: ${EE_INSTALLED_PHP_VERSION}"
# Make the chosen version the default `php`.
if command -v update-alternatives >/dev/null 2>&1 && [ -x "/usr/bin/php${EE_INSTALLED_PHP_VERSION}" ]; then
update-alternatives --set php "/usr/bin/php${EE_INSTALLED_PHP_VERSION}" >/dev/null 2>&1 || true
fi
}
function setup_php_extensions() {
ee_log_info1 "Installing PHP extensions"
# Setting up the three required php extensions for EasyEngine.
if command -v php >/dev/null 2>&1; then
php_extensions=(curl sqlite3 zip)
if ! command -v gawk >/dev/null 2>&1; then
apt-get $_EE_APT_LOCK_LIGHT_INSTALL install gawk -y
fi
# Use the version setup_php installed; else detect from the `php` symlink.
default_php_version="${EE_INSTALLED_PHP_VERSION:-}"
if [ -z "$default_php_version" ]; then
default_php_version="$(readlink -f /usr/bin/php | gawk -F "php" '{ print $2}')"
fi
ee_log_info1 "Installed PHP : $default_php_version"
ee_log_info1 "Checking if required PHP modules are installed..."
packages=""
for module in "${php_extensions[@]}"; do
if ! php -m | grep $module >/dev/null 2>&1; then
ee_log_info1 "$module not installed. Installing..."
packages+="php$default_php_version-$module "
else
ee_log_info1 "$module is already installed"
fi
done
if [ -n "$packages" ]; then
apt-get $_EE_APT_LOCK_INSTALL install -y $packages
fi
fi
}
function create_swap() {
ee_log_info2 "Enabling 1GiB swap"
EE_SWAP_FILE="/ee-swapfile"
fallocate -l 1G $EE_SWAP_FILE && \
chmod 600 $EE_SWAP_FILE && \
chown root:root $EE_SWAP_FILE && \
mkswap $EE_SWAP_FILE && \
swapon $EE_SWAP_FILE
}
function check_swap() {
ee_log_info1 "Checking swap"
if free | awk '/^Swap:/ {exit !$2}'; then
:
else
ee_log_info1 "No swap detected"
create_swap
fi
}
function setup_host_dependencies() {
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ] || [ "$EE_LINUX_DISTRO" == "Debian" ]; then
if ! command -v ip >> $LOG_FILE 2>&1; then
ee_log_info2 "Installing iproute2"
apt-get $_EE_APT_LOCK_LIGHT_INSTALL install iproute2 -y
fi
fi
}
function check_dependencies() {
ee_log_info1 "Checking dependencies"
# Self-heal (adapted from the candidate script): a previous failed run may
# have left an ondrej/php source pinned to a codename this release no longer
# serves, which would 404 every apt-get update below. Drop it first.
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ] && compgen -G "/etc/apt/sources.list.d/ondrej-ubuntu-php*" >/dev/null 2>&1; then
local host_codename
host_codename="$(lsb_release -sc 2>/dev/null || true)"
if [ "$(get_ondrej_php_ppa_release_status "$host_codename")" == "404" ]; then
ee_log_warn "Removing stale ondrej/php source (no release for '${host_codename:-unknown}')"
rm -f /etc/apt/sources.list.d/ondrej-ubuntu-php*
fi
fi
# Run apt update once upfront so that all subsequent apt install calls
# can find their packages. On a freshly booted machine the apt cache
# is typically empty and installs would fail without this.
ee_log_info2 "Updating apt cache"
ee_apt_update
if ! command -v sqlite3 >/dev/null 2>&1; then
ee_log_info2 "Installing sqlite3"
apt-get $_EE_APT_LOCK_LIGHT_INSTALL install sqlite3 -y
fi
setup_host_dependencies
setup_docker
setup_php
setup_php_extensions
check_swap
}
function download_and_install_easyengine() {
ee_log_info1 "Downloading EasyEngine phar"
local phar_url="https://raw.githubusercontent.com/EasyEngine/easyengine-builds/master/phar/easyengine.phar"
local checksum_url="${phar_url}.sha512"
local tmp_phar=""
tmp_phar="$(mktemp /tmp/easyengine.phar.XXXXXX)"
local tmp_checksum=""
tmp_checksum="$(mktemp /tmp/easyengine.phar.sha512.XXXXXX)"
# Cleanup helper — removes temp files.
# Explicit calls are used before every ee_log_fail (which calls "exit 1",
# bypassing RETURN traps). The trap RETURN below is a belt-and-suspenders
# catch for any unexpected early exits caused by set -e.
_ee_download_cleanup() {
rm -f "${tmp_phar:-}" "${tmp_checksum:-}"
# Unregister this trap so it doesn't fire again when a later function
# returns (bash does not scope nested function definitions, so
# _ee_download_cleanup remains in the environment after this function
# exits and the RETURN trap would otherwise re-fire with tmp_phar and
# tmp_checksum out of scope, causing "unbound variable" under set -u).
trap - RETURN
}
trap '_ee_download_cleanup' RETURN
# Download the phar to a temp file.
# --fail: exit non-zero on HTTP 4xx/5xx (prevents saving an error page as the binary).
# --location: follow redirects.
if ! curl --fail --location --silent --show-error --output "$tmp_phar" "$phar_url"; then
_ee_download_cleanup
ee_log_fail "ERROR: Failed to download EasyEngine phar from $phar_url. Check your network connection or try again later."
fi
# Verify the file is not empty (second guard against silent download failures).
if [ ! -s "$tmp_phar" ]; then
_ee_download_cleanup
ee_log_fail "ERROR: Downloaded EasyEngine phar is empty. Aborting installation."
fi
# Download the SHA-512 checksum file.
if ! curl --fail --location --silent --show-error --output "$tmp_checksum" "$checksum_url"; then
_ee_download_cleanup
ee_log_fail "ERROR: Failed to download EasyEngine checksum from $checksum_url. Aborting installation."
fi
ee_log_info1 "Verifying EasyEngine phar checksum"
# Use awk to extract the first field so this works with both a plain hex hash
# and the standard sha512sum output format ('<hash> <filename>').
local expected_hash
expected_hash="$(awk '{print $1}' "$tmp_checksum")"
if [ -z "$expected_hash" ]; then
_ee_download_cleanup
ee_log_fail "ERROR: Checksum file is empty or invalid. Aborting installation."
fi
local actual_hash
actual_hash="$(sha512sum "$tmp_phar" | awk '{print $1}')"
if [ "$expected_hash" != "$actual_hash" ]; then
_ee_download_cleanup
ee_log_fail "ERROR: EasyEngine phar checksum mismatch! The downloaded file may be corrupt or tampered with. Aborting installation."
fi
ee_log_info1 "Checksum verified. Installing EasyEngine"
# Move verified phar into place and make it executable.
mv "$tmp_phar" "$EE4_BINARY"
chmod +x "$EE4_BINARY"
# _ee_download_cleanup called by trap RETURN on normal exit
}
function pull_easyengine_images() {
# Running EE migrations and pulling of images by first `ee` invocation.
ee_log_info1 "Pulling EasyEngine docker images"
"$EE4_BINARY" cli info
}
function add_ssl_renew_cron() {
# noglob is required to ensure that '*' is not expanded to list all files in current directory while printing SSL_RENEW_CRON
set -o noglob
[[ ":$PATH:" != *":/usr/local/bin:"* ]] && PATH="/usr/local/bin:${PATH}"
SSL_RENEW_CRON="PATH=$PATH\n\n0 0 * * * /usr/local/bin/ee site ssl-renew --all >> /opt/easyengine/logs/cron.log 2>&1"
# Check if cron is installed in the system.
if which cron > /dev/null 2>&1 && which crontab > /dev/null 2>&1; then
ee_log_info1 "Adding ssl-renew cron"
# crontab -l exits 1 when no crontab exists; suppress that so set -e
# does not abort the script on a fresh machine.
crontab -l 2>/dev/null > ee_cron || true
echo -e $SSL_RENEW_CRON >> ee_cron
crontab ee_cron
rm ee_cron
fi
set +o noglob
}