-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
48 lines (38 loc) · 1.05 KB
/
install.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
48
#!/bin/bash
function isSwarmNode() {
if [[ "$(docker info 2>/dev/null | grep Swarm | sed 's/Swarm: //g' | xargs echo -n)" == "active" ]]; then
echo true;
else
echo false;
fi
}
function isDockerInstalled() {
which docker &> /dev/null
local result="$?"
if [[ "${result}" -eq 0 ]]; then
echo true;
else
echo false;
fi
}
function readServerVersion() {
echo $(cat ./server.version)
}
if [[ "$(isDockerInstalled)" == "false" ]]; then
echo "Docker is not installed."
exit 1
fi
if [[ "$(isSwarmNode)" == "false" ]]; then
echo "Docker is not in Swarm mode. Use 'docker swarm init' command."
exit 2
fi
echo "Docker is installed with Swarm mode enabled. Proceeding with Habit installation."
VERSION=$(readServerVersion)
[ -z "$SERVER_IMAGE" ] && export SERVER_IMAGE="ghcr.io/wttech/habit/habit-server:${VERSION}"
export HABIT_HTTP_PORT=7080
docker stack deploy -c ./docker-compose.yml habit
dockerResult=$?
if [[ "${dockerResult}" -ne 0 ]]; then
echo "Installation failed."
exit 3
fi