-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-offline-deployment.sh
executable file
·59 lines (42 loc) · 1.57 KB
/
setup-offline-deployment.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
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
set -euo pipefail
compose=$(cat docker-compose.sample.yml)
secret_key=$(openssl rand -base64 36)
pg_password=$(openssl rand -hex 24)
pw=$(openssl rand -hex 12)
read -p "Web interface username [synchronist]: " username
username=${username:-synchronist}
read -p "Web interface password: " password
password=${password:-$pw}
read -p "Port for web interface [80]: " port
port=${port:-80}
read -p "Docker volumes (comma-separated, e.g. /host:/container,/data:/data): " volumes_in
IFS=', ' read -r -a volumes_arr <<< "$volumes_in"
volumes_yml=()
for element in ${volumes_arr[@]}
do
volumes_yml+=(" - $element")
done
volumes=$(IFS=$'\n'; echo "${volumes_yml[*]}")
compose=${compose//"<secret_key>"/"$secret_key"}
compose=${compose//"<pg_password>"/"$pg_password"}
compose=${compose//"<username>"/"$username"}
compose=${compose//"<password>"/"$password"}
compose=${compose//"<port>"/"$port"}
compose=${compose//"<volumes>"/"$volumes"}
cat <<< "$compose" > "./docker-compose.yml"
if [ -d "/usr/lib/systemd/system" ]; then
echo "Installing service file..."
service=$(cat synchronist.service)
read -p "Systemd service user [root]: " service_user
service_user=${service_user:-root}
service=${service//"<service_user>"/"$service_user"}
service=${service//"<working_directory>"/"$PWD"}
sudo cat <<< "$service" > "/usr/lib/systemd/system/synchronist.service"
else
echo "No systemd found, use: docker compose up -d"
fi
echo "Loading all docker containers into local docker registry.. "
for tarfile in *.tar; do
docker load -i "$tarfile"
done