summaryrefslogtreecommitdiff
path: root/start.sh
blob: 0ec7c206cb8ca77699a13d4d11691d3d8acebd00 (plain)
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
#!/bin/sh

systemctl disable firewalld.service

cd /opt
git clone [email protected]:chongming/tsg_test.git
cd /opt/tsg_test
git checkout develop
find . -type f -name "*.py" -exec chmod 777 {} \;
chmod 777 /opt/tsg_test/supervisor.conf
chmod 777 /opt/tsg_test/package/requirements.txt
chmod 777 /opt/tsg_test/package/tsg_ca.txt
chmod 777 /opt/tsg_test/package/rocky.repo
chmod 777 /opt/tsg_test/package/rocky-extras.repo
chmod 777 /etc/pki/tls/certs/ca-bundle.crt

yum install -y perl
perl /opt/tsg_test/package/update_mirror.pl /etc/yum.repos.d/centos*.repo

python3 /opt/tsg_test/package/install_docker.py

tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": [
        "https://dockerproxy.com",
        "https://registry.docker-cn.com",
        "https://hub-mirror.c.163.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://cr.console.aliyun.com/",
        "https://ccr.ccs.tencentyun.com"
  ]
}
EOF
systemctl daemon-reload
systemctl restart docker

if [[ "$(docker images -q)" == "" ]] || [[ "$(docker images --format "{{.Repository}}:{{.Tag}}" | grep 'package')" != "package:base" ]]; then
    echo "No Docker images, start to building."
    cd /opt/tsg_test/package/
    docker build -t package:base .
    echo "The Docker images have been created."
else
    echo "Exist Docker images"
fi

docker images

if [[ "$(docker ps -q)" == "" ]]; then
    echo "No Docker containers, start to building."
    cd /opt/tsg_test/
    docker build -t test:test .
    echo "The Docker containers have been created."
else
    echo "Exist Docker containers"
fi

docker ps -a

docker run -d --network=host --name automation --privileged --cap-add=ALL -v /dev:/dev -v /lib/modules:/lib/modules -p 8800:8800 test:test