-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-run.sh
executable file
·68 lines (61 loc) · 1.66 KB
/
create-run.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
#!/bin/bash
if [[ ! $(whoami) = "root" ]]
then
echo "Usage: Must be root"
exit 1
fi
while getopts ":d:n:" opt; do
case $opt in
d) DOMAIN=${OPTARG} ;;
n) K8S_N=${OPTARG} ;;
\?)
echo "Invalid option: -$OPTARG"
exit 1
;;
:)
echo "Option -$OPTARG requires an argument."
exit 1
;;
esac
done
if [[ -z $DOMAIN ]]
then
echo 'Flag -d is required'
exit 1
fi
if [[ -z $K8S_N ]]
then
echo 'Flag -n is required'
exit 1
fi
if [ -d run ]
then
chmod u=rwx cleanup.sh
./cleanup.sh
fi
mkdir run
cp -r dns run/dns
cp -r nfs run/nfs
cp -r vpn run/vpn
cp -r main run/main
for (( i=1; i<=$K8S_N; i++ ))
do
cp -r worker run/worker$i
done
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/dns/initscripts/ansible-dns.yaml
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/dns/initscripts/test-dns.sh
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/dns/initscripts/script-dns.sh
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/nfs/initscripts/ansible-nfs.yaml
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/nfs/initscripts/test-nfs.sh
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/nfs/initscripts/script-nfs.sh
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/main/initscripts/mainkubeinstall.sh
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/main/jenkins/jenkins-ingress.yaml
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/main/jenkins/jenkins-pv.yaml
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/main/tls/myapp-ingress-tls.yaml
for (( i=1; i<=$K8S_N; i++ ))
do
sed -i "s/\[\[DOMAIN\]\]/$DOMAIN/g" run/worker$i/initscripts/workerkubeinstall.sh
sed -i "s/\[\[WORKER_N\]\]/$i/g" run/worker$i/Vagrantfile
ip=$(( $i + 10 ))
sed -i "s/\[\[WORKER_IP\]\]/$ip/g" run/worker$i/Vagrantfile
done