-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmail.lan.sh
62 lines (51 loc) · 1.88 KB
/
mail.lan.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
60
61
62
#!/bin/bash
DOMAIN=`basename -- "$0" .sh`
MODULE_NAME=${DOMAIN//./-}
# Pod configurations
HOST_IPv4=`ip -4 route get 255.255.255.255 | head -1 | cut -f6 -d' '`
POD_DATAPATH="/srv/mail"
POD_LOCALTIMEPATH="/etc/localtime"
# Prepare the Mail Server data folder
echo ">> Creating /srv/mail folder..."
mkdir -p /srv/mail &>/dev/null
# Thanks to http://stackoverflow.com/a/10467453
function sedeasy {
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
}
# Wait until POD is Running
function wait_until_pod_is_running {
# Wait until the docker is up and running
echo -n ">> Waiting for '$1' to start..."
status=`kubectl get pods --all-namespaces -l $2 -o jsonpath="{.items[0].status.phase}" | grep Running`
while [ "$status" != "Running" ]
do
echo -n "."
sleep 0.5
status=`kubectl get pods --all-namespaces -l $2 -o jsonpath="{.items[0].status.phase}" | grep Running`
done
echo "started!"
}
# Install helm dependency with configuration
# $1: channel ( stable/incubator/test)
# $2: app name
function helm_install_with_config {
# Copy the template
cp -f config.tpl.yaml config.yaml
# Replace configurations
sedeasy "VPS_POD_DOMAIN" "$DOMAIN" config.yaml
sedeasy "VPS_POD_DATAPATH" "$POD_DATAPATH" config.yaml
sedeasy "VPS_POD_LOCALTIMEPATH" "$POD_LOCALTIMEPATH" config.yaml
sedeasy "HOST_IPv4" "$HOST_IPv4" config.yaml
helm install \
--name "$MODULE_NAME" \
-f "config.yaml" \
"$1/$2" &>/dev/null
}
helm_install_with_config "ukube" "posteio"
wait_until_pod_is_running "$MODULE_NAME" "app=posteio"
# Print friendly done message
echo "-----------------------------------------------------"
echo "All right! Everything seems to be installed correctly. Have a nice day!"
echo ">> Admin URL: https://${DOMAIN}/admin/login"
echo ">> User URL: https://${DOMAIN}/"
echo "-----------------------------------------------------"