-
Notifications
You must be signed in to change notification settings - Fork 0
/
initialize
executable file
·126 lines (117 loc) · 3.07 KB
/
initialize
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
120
121
122
123
124
125
126
#!/bin/bash
#init deploy
if [ -f "install_docker.sh" ];then
echo "Initialization completed,quit..."
exit 1
else
echo "Start executing initialization..."
fi
case "$1" in
-h|--help|?)
echo "Usage: 1st arg:config name, for example:hosts"
echo "Usage: $0 hosts"
exit 0
;;
esac
if [ ! -n "$1" ]; then
echo "pls input 1st arg"
echo "Usage: $0 -h|--help|?"
exit
fi
grep "SELINUX=enforcing" /etc/selinux/config
if [ "$?" -eq "0" ]
then
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
/usr/sbin/setenforce 0
else
echo SELINUX=disabled >> /etc/selinux/config
fi
cd `dirname $0`
which docker >/dev/nul 2>&1
if [ "$?" != "0" ]
then
export PATH=$PATH:/opt/docker_bin/
docker_bip=`grep docker_bip $1 |awk -F'=' '{print $2}'`
docker_graph=/opt/docker_bin/var/docker
registry_mirrors=`grep registry_mirrors $1 |awk -F'=' '{print $2}'`
default_address_pools=`grep default_address_pools $1 |awk -F'=' '{print $2}'`
harbor_hostname=`grep image_registryDomain $1 |awk -F'=' '{print $2}'`
harbor_port=`grep image_registryPort $1 |awk -F'=' '{print $2}'`
cat > docker_common/daemon.json << EOF
{
"bip": "${docker_bip}",
"default-address-pools":
[
{"base":"${default_address_pools}","size":24}
],
"bridge": "",
"debug": false,
"default-runtime": "runc",
"iptables": false,
"ip-forward": true,
"ip-masq": false,
"iptables": false,
"ipv6": false,
"labels": [],
"live-restore": true,
"log-driver": "json-file",
"log-level": "warn",
"log-opts": {
"tag": "{{.ImageName}}|{{.Name}}",
"max-file": "10",
"max-size": "200m"
},
"registry-mirrors": [
"${registry_mirrors}"
],
"insecure-registries": [
"${image_registryDomain:-bmnw.com}:${image_registryPort:-5000}"
],
"runtimes": {},
"selinux-enabled": false,
"hosts":[
"unix:///opt/docker_bin/run/docker.sock"
],
"data-root": "${docker_graph}",
"pidfile": "/opt/docker_bin/docker.pid",
"exec-root":"/opt/docker_bin/run",
"exec-opts": [
"native.cgroupdriver=systemd"
],
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
EOF
which /opt/docker_bin/docker >/dev/nul 2>&1
if [ "$?" != "0" ]
then
echo "install docker binaries"
bash docker_common/install_docker.sh
sleep 1
else
abaa=`ps -ef |grep /opt/docker_bin/run/containerd/containerd.toml |grep -v grep |wc -l`
if [ "$abaa" -eq 1 ]
then
echo "opt docker already install"
else
bash docker_common/install_docker.sh
fi
fi
/opt/docker_bin/docker -H unix:///opt/docker_bin/run/docker.sock image ls |grep ansible >/dev/nul 2>&1
if [ "$?" != "0" ]
then
echo "load ansible docker"
/opt/docker_bin/docker -H unix:///opt/docker_bin/run/docker.sock load -i pkg/ansible.tar.xz
fi
cp -r shell/no_docker/*.sh ./
else
docker image ls |grep ansible >/dev/nul 2>&1
if [ "$?" != "0" ]
then
echo "load ansible docker"
docker load -i pkg/ansible.tar.xz
fi
cp shell/Installed_docker/*.sh ./
fi