forked from dokku/dokku-graphite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·49 lines (41 loc) · 1.87 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
#!/usr/bin/env bash
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
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}"
pull-docker-image "busybox:1.31.0-uclibc"
pull-docker-image "dokku/ambassador:0.3.1"
pull-docker-image "dokku/s3backup:0.10.1"
pull-docker-image "dokku/wait:0.4.1"
mkdir -p "$PLUGIN_DATA_ROOT" || echo "Failed to create $PLUGIN_SERVICE data directory"
chown dokku:dokku "$PLUGIN_DATA_ROOT"
mkdir -p "$PLUGIN_CONFIG_ROOT" || echo "Failed to create $PLUGIN_SERVICE config directory"
chown dokku:dokku "$PLUGIN_CONFIG_ROOT"
rm -f "/etc/sudoers.d/dokku-${PLUGIN_COMMAND_PREFIX}*"
_SUDOERS_FILE="/etc/sudoers.d/dokku-${PLUGIN_COMMAND_PREFIX}"
touch "$_SUDOERS_FILE"
cat >"$_SUDOERS_FILE" <<EOL
%dokku ALL=(ALL) NOPASSWD:/bin/rm -f /etc/cron.d/dokku-${PLUGIN_COMMAND_PREFIX}-*
%dokku ALL=(ALL) NOPASSWD:/bin/chown root\:root /etc/cron.d/dokku-${PLUGIN_COMMAND_PREFIX}-*
%dokku ALL=(ALL) NOPASSWD:/bin/chmod 644 /etc/cron.d/dokku-${PLUGIN_COMMAND_PREFIX}-*
%dokku ALL=(ALL) NOPASSWD:/bin/mv ${PLUGIN_DATA_ROOT}/.TMP_CRON_FILE /etc/cron.d/dokku-${PLUGIN_COMMAND_PREFIX}-*
%dokku ALL=(ALL) NOPASSWD:/bin/chown 8983 $PLUGIN_DATA_ROOT/*
%dokku ALL=(ALL) NOPASSWD:/bin/chgrp 8983 $PLUGIN_DATA_ROOT/*
%dokku ALL=(ALL) NOPASSWD:/usr/bin/tee /etc/nginx/conf.d/grafana-*.conf
%dokku ALL=(ALL) NOPASSWD:/bin/rm /etc/nginx/conf.d/grafana-*.conf
EOL
chmod 0440 "$_SUDOERS_FILE"
}
plugin-install "$@"