-
Notifications
You must be signed in to change notification settings - Fork 0
/
services.sh
executable file
·43 lines (38 loc) · 1.9 KB
/
services.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
#/usr/bin/bash
set -euo pipefail
container_runtime=$(yq -r '.container_runtime' setup.conf.yaml)
if ! command -v ${container_runtime} >/dev/null 2>&1; then
echo "${container_runtime} not installed!"
exit 1
fi
echo start haproxy service
[ -f haproxy/haproxy.cfg ] || { echo "haproxy/haproxy.cfg not found!"; exit 1; }
${container_runtime} stop ocp-haproxy || true
${container_runtime} rm ocp-haproxy || true
count=$(sudo ${container_runtime} ps --filter name=ocp-haproxy --format {{.Names}} | wc -l)
if [[ $count -eq 0 ]]; then
sudo ${container_runtime} run -d --name ocp-haproxy --cap-add=NET_ADMIN --net=host -v "$PWD/haproxy":/usr/local/etc/haproxy:ro haproxy:1.7
else
# let haproxy reload haproxy.cfg
sudo ${container_runtime} kill -s HUP ocp-haproxy
fi
echo start httpd service
[ -d www ] || { echo "directory www not found!"; exit 1; }
${container_runtime} stop ocp-httpd || true
${container_runtime} rm ocp-httpd || true
count=$(sudo ${container_runtime} ps --filter name=ocp-httpd --format {{.Names}} | wc -l)
if [[ $count -eq 0 ]]; then
sudo ${container_runtime} run -dit --name ocp-httpd -p 81:80 -v "$PWD/www":/usr/local/apache2/htdocs/ httpd:2.4
else
sudo ${container_runtime} kill -s HUP ocp-httpd
fi
echo "start dnsmasq service"
[ -f dnsmasq/dnsmasq.conf ] || { echo "dnsmasq/dnsmasq.conf not found!"; exit 1; }
${container_runtime} stop ocp-dnsmasq || true
${container_runtime} rm ocp-dnsmasq || true
count=$(sudo ${container_runtime} ps --filter name=ocp-dnsmasq --format {{.Names}} | wc -l)
if [[ $count -eq 0 ]]; then
sudo ${container_runtime} run -dit --name ocp-dnsmasq -v $PWD/dnsmasq:/etc/dnsmasq.d -v $PWD/pxelinux.cfg:/var/lib/tftpboot/pxelinux.cfg --cap-add=NET_ADMIN --net=host quay.io/jianzzha/dnsmasq -d -q --conf-file=/etc/dnsmasq.d/dnsmasq.conf --enable-tftp --tftp-root=/var/lib/tftpboot --log-queries --log-dhcp
else
sudo ${container_runtime} kill -s HUP ocp-dnsmasq
fi