-
-
Notifications
You must be signed in to change notification settings - Fork 92
/
install
executable file
·92 lines (79 loc) · 4.17 KB
/
install
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
#!/usr/bin/env bash
source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
fn-letsencrypt-migrate-properties() {
declare desc="migrates deprecated config variables to property counterpart"
local value
value=$(plugn trigger config-get-global "DOKKU_LETSENCRYPT_EMAIL" || true)
if [[ -n "$value" ]]; then
dokku_log_info1 "Migrating deprecated global DOKKU_LETSENCRYPT_EMAIL to letsencrypt email property."
fn-plugin-property-write "letsencrypt" "--global" "email" "$value"
DOKKU_QUIET_OUTPUT=1 config_unset --global DOKKU_LETSENCRYPT_EMAIL || true
fi
value=$(plugn trigger config-get-global "DOKKU_LETSENCRYPT_GRACEPERIOD" || true)
if [[ -n "$value" ]]; then
dokku_log_info1 "Migrating deprecated global DOKKU_LETSENCRYPT_GRACEPERIOD to letsencrypt graceperiod property."
fn-plugin-property-write "letsencrypt" "--global" "graceperiod" "$value"
DOKKU_QUIET_OUTPUT=1 config_unset --global DOKKU_LETSENCRYPT_GRACEPERIOD || true
fi
value=$(plugn trigger config-get-global "DOKKU_LETSENCRYPT_ARGS" || true)
if [[ -n "$value" ]]; then
dokku_log_info1 "Migrating deprecated global DOKKU_LETSENCRYPT_ARGS to letsencrypt lego-docker-args property."
fn-plugin-property-write "letsencrypt" "--global" "lego-docker-args" "$value"
DOKKU_QUIET_OUTPUT=1 config_unset --global DOKKU_LETSENCRYPT_ARGS || true
fi
value=$(plugn trigger config-get-global "DOKKU_LETSENCRYPT_SERVER" || true)
if [[ -n "$value" ]]; then
dokku_log_info1 "Migrating deprecated global DOKKU_LETSENCRYPT_SERVER to letsencrypt server property."
fn-plugin-property-write "letsencrypt" "--global" "server" "$value"
DOKKU_QUIET_OUTPUT=1 config_unset --global DOKKU_LETSENCRYPT_SERVER || true
fi
for app in $(dokku_apps "false"); do
value="$(plugn trigger config-get "$app" DOKKU_LETSENCRYPT_EMAIL || true)"
if [[ -n "$value" ]]; then
dokku_log_info1 "Migrating deprecated DOKKU_LETSENCRYPT_EMAIL to letsencrypt email property for $app."
fn-plugin-property-write "letsencrypt" "$app" "email" "$value"
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" "DOKKU_LETSENCRYPT_EMAIL" || true
fi
value="$(plugn trigger config-get "$app" DOKKU_LETSENCRYPT_GRACEPERIOD || true)"
if [[ -n "$value" ]]; then
dokku_log_info1 "Migrating deprecated DOKKU_LETSENCRYPT_GRACEPERIOD to letsencrypt graceperiod property for $app."
fn-plugin-property-write "letsencrypt" "$app" "graceperiod" "$value"
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" "DOKKU_LETSENCRYPT_GRACEPERIOD" || true
fi
value="$(plugn trigger config-get "$app" DOKKU_LETSENCRYPT_ARGS || true)"
if [[ -n "$value" ]]; then
dokku_log_info1 "Migrating deprecated DOKKU_LETSENCRYPT_ARGS to letsencrypt lego-docker-args property for $app."
fn-plugin-property-write "letsencrypt" "$app" "lego-docker-args" "$value"
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" "DOKKU_LETSENCRYPT_ARGS" || true
fi
value="$(plugn trigger config-get "$app" DOKKU_LETSENCRYPT_SERVER || true)"
if [[ -n "$value" ]]; then
dokku_log_info1 "Migrating deprecated DOKKU_LETSENCRYPT_SERVER to letsencrypt server property for $app."
fn-plugin-property-write "letsencrypt" "$app" "server" "$value"
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$app" "DOKKU_LETSENCRYPT_SERVER" || true
fi
done
}
plugin-install() {
pull-docker-image() {
declare IMAGE="$1"
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
echo " ! ${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
echo " ! docker pull ${IMAGE}" 1>&2
return
fi
if [[ "$(docker images -q "${IMAGE}" 2>/dev/null)" == "" ]]; then
docker pull "${IMAGE}"
fi
}
pull-docker-image "${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION}"
mkdir -p "${DOKKU_LIB_ROOT}/data/letsencrypt"
chown -R "${DOKKU_SYSTEM_USER}:${DOKKU_SYSTEM_GROUP}" "${DOKKU_LIB_ROOT}/data/letsencrypt"
fn-plugin-property-setup "letsencrypt"
fn-letsencrypt-migrate-properties
}
plugin-install "$@"