-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall
executable file
·108 lines (87 loc) · 2.42 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
pushd "$DOKKU_ROOT" > /dev/null
git_status_result=$(git status &> /dev/null)$?
if (( git_status_result )); then
git init --quiet "$DOKKU_ROOT"
cat<<EOF > "$DOKKU_ROOT/.gitignore"
.DS_Store
/.bash_history
/.ssh/
/*/.build.lock
/*/branches/
/*/cache/
/*/config
/*/CONTAINER*
/*/description
/*/hooks/
/*/info/
/*/IP
/*/nginx.conf
/*/objects/
/*/packed-refs
/*/PORT
/*/refs/remotes/
/*/refs/tags/
/*/URL
/*/URLS
/GRADUATE_ENVIRONMENTS
/GRADUATE_PRE_HOOKS
/GRADUATE_POST_HOOKS
/GRADUATE_STATUS
EOF
fi
pushd "$DOKKU_ROOT" > /dev/null
CHECK_DEPLOY_DIR="$PLUGIN_AVAILABLE_PATH/zzz_graduate"
if ! [[ -d "$CHECK_DEPLOY_DIR" ]]; then
mkdir "$CHECK_DEPLOY_DIR"
fi
cat<<"EOF" > "$CHECK_DEPLOY_DIR/plugin.toml"
[plugin]
description = "Automatically installed dokku-graduate component"
version = "1.0.0"
[plugin.config]
EOF
cat<<"EOF" > "$CHECK_DEPLOY_DIR/check-deploy"
#!/usr/bin/env bash
# This hook is a component of the dokku-graduate plugin. It is installed here,
# rather than being included in the main dokku-graduate directory, to try ensure
# that this hook is called after all other hooks.
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$(dirname $0)/../common/functions"
APP="$1"
POLL_SECONDS=3
MAXIMUM_WAIT_SECONDS=7200 # 2 hours.... if your deploy is taking longer, just give up.
let "WAITED = 0" || true
GRADUATE_STATUS=""
if [[ -f "$DOKKU_ROOT/GRADUATE_STATUS" ]]; then
read -r GRADUATE_STATUS < "$DOKKU_ROOT/GRADUATE_STATUS"
fi
if [[ "$GRADUATE_STATUS" == "deploying" ]]; then
echo "Waiting on graduating peers..."
while [[ "$GRADUATE_STATUS" != $APP:* ]] && [[ "$GRADUATE_STATUS" != "cleaning" ]] && (( $WAITED < $MAXIMUM_WAIT_SECONDS )); do
if [[ -e "$DOKKU_ROOT/GRADUATE_STATUS" ]]; then
read -r GRADUATE_STATUS < "$DOKKU_ROOT/GRADUATE_STATUS"
fi
let "WAITED += $POLL_SECONDS"
sleep $POLL_SECONDS
done
case "$GRADUATE_STATUS" in
$APP:continue)
dokku_log_info2_quiet "Continuing with $APP deployment..."
;;
$APP:abort)
dokku_log_fail "$APP deployment aborted"
;;
*)
dokku_log_fail "$APP timed out waiting for peers to graduate"
;;
esac
fi
EOF
chmod 755 "$CHECK_DEPLOY_DIR/check-deploy"
cp -rf "$CHECK_DEPLOY_DIR" "$PLUGIN_ENABLED_PATH/zzz_graduate"
SSH_PRIVATE_KEY=/home/dokku/.ssh/id_rsa
if ! [[ -f "$SSH_PRIVATE_KEY" ]]; then
ssh-keygen -f "$SSH_PRIVATE_KEY" -t rsa -N '' > /dev/null
fi