-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
120 lines (96 loc) · 4.59 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
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
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
TZKD_VERSION=0.2.0
if echo "${VPNName:-tzk}" | grep -Eq ^[a-z0-9]+$; then
echo "${VPNName:-tzk} [VPNName matched]"
else
echo "${VPNName:-tzk} is invalid name, use only these characters a-z 0-9" && exit 100
fi
command_exists() {
command -v "$@" > /dev/null 2>&1
}
if command_exists docker;then
echo "Docker is installed already"
else
curl -sSL https://get.docker.com/ | sh
fi
apt-get update -y && apt-get install curl wget apt-transport-https -y
# install sigil
curl -fsSL https://github.com/gliderlabs/sigil/releases/download/v0.4.0/sigil_0.4.0_Linux_x86_64.tgz | tar -zxC /usr/local/bin
curl -o /tmp/tzk.toml https://raw.githubusercontent.com/NebTex/tzk/master/kubernetes.sh
# install tzk daemon
RUN wget https://github.com/NebTex/tzk-daemon/releases/download/v${TZKD_VERSION}/tzkd_linux_amd64 && \
mv tzkd_linux_amd64 /usr/local/bin/tzkd && \
chmod +x /usr/local/bin/tzkd && \
# install sigil
curl -fsSL https://github.com/gliderlabs/sigil/releases/download/v0.4.0/sigil_0.4.0_Linux_x86_64.tgz | tar -zxC /usr/local/bin
curl -o /tmp/tzk.toml https://raw.githubusercontent.com/NebTex/tzk/master/tzk.toml
# install tzk daemon
wget https://github.com/NebTex/tzk-daemon/releases/download/v${TZKD_VERSION}/tzkd_linux_amd64 && \
mv tzkd_linux_amd64 /usr/local/bin/tzkd && \
chmod +x /usr/local/bin/tzkd && \
mkdir -p /etc/tzk.d
if [ "${master:-false}" == "true" ];then
export ACLToken=$(uuidgen)
mkdir -p /consul
mkdir -p /caddy
chmod 755 -R /consul
chmod 755 -R /caddy
fi
sigil -p -i "$(cat /tmp/tzk.toml)" \
VPNName=${VPNName:-tzk} ACLToken=${ACLToken:?} master=${master:-false} \
Subnet=${Subnet:-10.187.0.0/16} ConsulHost=${ConsulHost:?} \
NodeIP=${NodeIP:-} \
ClusterCIDR=${ClusterCIDR:-10.32.0.0/12}\
PodSubnet=${PodSubnet:-}\
> /etc/tzk.d/tzk.toml
if [ "${master:-false}" != "true" ];then
# set docker new subnet
curl -sS https://raw.githubusercontent.com/NebTex/tzk/master/configure_docker0.sh | sudo bash -s - `tzkd get podSubnet`
fi
docker run -d \
--env ACLToken=${ACLToken:?} \
--env ConsulHost=${ConsulHost:?} \
--env master=${master:-false} \
--net=host \
--restart=always \
--device=/dev/net/tun \
--cap-add NET_ADMIN \
--volume /consul-tinc:/consul \
--volume /etc/tinc/tzk:/etc/tinc/tzk \
--volume /etc/tzk.d/:/etc/tzk.d/ \
--volume /caddy:/root/.caddy \
--volume /etc/hosts:/etc/hosts --name tzk nebtex/tzk
# print welcome
sleep 5
# create
BLUE='\e[34m'
RED='\e[31m'
MAGENTA='\e[35m'
CYAN='\e[36m'
NC='\e[39m' # No Color
echo -e "
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
$BLUE
█ █░▓█████ ██▓ ▄████▄ ▒█████ ███▄ ▄███▓▓█████
▓█░ █ ░█░▓█ ▀ ▓██▒ ▒██▀ ▀█ ▒██▒ ██▒▓██▒▀█▀ ██▒▓█ ▀
▒█░ █ ░█ ▒███ ▒██░ ▒▓█ ▄ ▒██░ ██▒▓██ ▓██░▒███
░█░ █ ░█ ▒▓█ ▄ ▒██░ ▒▓▓▄ ▄██▒▒██ ██░▒██ ▒██ ▒▓█ ▄
░░██▒██▓ ░▒████▒░██████▒▒ ▓███▀ ░░ ████▓▒░▒██▒ ░██▒░▒████▒
░ ▓░▒ ▒ ░░ ▒░ ░░ ▒░▓ ░░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒░ ░ ░░░ ▒░ ░
▒ ░ ░ ░ ░ ░░ ░ ▒ ░ ░ ▒ ░ ▒ ▒░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░
░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░
░
How can I add new node?:
========================
ConsulHost=${ConsulHost:?} ACLToken=${ACLToken:?} bash -c \"\$(curl -fsSL https://git.io/v1b4Q)\"
$NC
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
vpn = ${VPNName:-tzk}
hostname = `hostname -s`.${VPNName:-tzk}.local
ip = `tzkd get ip`
podSubnet = `tzkd get podSubnet`
master = master1.${VPNName:-tzk}.local
logs = tzkd get logs
Enjoy !!!
"