-
Notifications
You must be signed in to change notification settings - Fork 144
/
deploy.sh
executable file
·47 lines (39 loc) · 1.2 KB
/
deploy.sh
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
#!/usr/bin/env bash
set -e
YE_HOME=$HOME/yearn-exporter
TAG=${1:-latest}
ENV_FILE=${2:-"$HOME/.env"}
UP_CMD=$3
BASE_URL=$4
if [[ -z "${UP_CMD}" ]]; then
echo "[!] UP_CMD not specified. Exiting..."
exit 1
fi
echo "[*] Starting deployment"
echo "[*] Sourcing environment"
if ! [ -f "$ENV_FILE" ]; then
echo "[!] $ENV_FILE file not found. Exiting..."
exit 1
fi
rm -fr $YE_HOME || true
git clone https://github.com/yearn/yearn-exporter --single-branch $YE_HOME
cd $YE_HOME
source $ENV_FILE
docker pull "ghcr.io/yearn/yearn-exporter:$TAG"
make down
make $UP_CMD with_logs=false || true
if [[ ! -z "${BASE_URL}" ]]; then
LOGIN_RESPONSE=$(curl -X POST \
-d '{"user":"admin","password":"admin"}' \
-H 'Content-Type: application/json' \
$BASE_URL/login \
-o /dev/null \
-sw '%{http_code}')
if [ "$LOGIN_RESPONSE" = "200" ]; then
echo "[*] ! SER ! Grafana admin password is not good. Please change the admin password manually with the grafana UI."
echo "[*] Stopping existing service"
make down
exit 1
fi
fi
echo "[*] Finished!"