forked from metal3-io/ironic-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runhttpd.sh
executable file
·42 lines (30 loc) · 1.42 KB
/
runhttpd.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
#!/usr/bin/bash
PROVISIONING_INTERFACE=${PROVISIONING_INTERFACE:-"provisioning"}
HTTP_PORT=${HTTP_PORT:-"80"}
HTTP_IP=$(ip -4 address show dev "$PROVISIONING_INTERFACE" | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n 1)
mkdir -p /shared/html
chmod 0777 /shared/html
# Copy files to shared mount
cp /tmp/inspector.ipxe /shared/html/inspector.ipxe
cp /tmp/dualboot.ipxe /shared/html/dualboot.ipxe
# Use configured values
sed -i -e s/IRONIC_IP/${HTTP_IP}/g -e s/HTTP_PORT/${HTTP_PORT}/g /shared/html/inspector.ipxe
sed -i 's/^Listen .*$/Listen '"$HTTP_PORT"'/' /etc/httpd/conf/httpd.conf
sed -i -e 's|\(^[[:space:]]*\)\(DocumentRoot\)\(.*\)|\1\2 "/shared/html"|' \
-e 's|<Directory "/var/www/html">|<Directory "/shared/html">|' \
-e 's|<Directory "/var/www">|<Directory "/shared">|' /etc/httpd/conf/httpd.conf
# Remove log files from last deployment
rm -rf /shared/log/httpd
mkdir -p /shared/log/httpd
# Make logs available in shared mount
touch /shared/log/httpd/access_log
ln -s /shared/log/httpd/access_log /var/log/httpd/access_log
touch /shared/log/httpd/error_log
ln -s /shared/log/httpd/error_log /var/log/httpd/error_log
# Allow external access
if ! iptables -C INPUT -i "$PROVISIONING_INTERFACE" -p tcp --dport "$HTTP_PORT" -j ACCEPT 2>/dev/null ; then
iptables -I INPUT -i "$PROVISIONING_INTERFACE" -p tcp --dport "$HTTP_PORT" -j ACCEPT
fi
/usr/sbin/httpd &
/bin/runhealthcheck "httpd" "$HTTP_PORT" &>/dev/null &
sleep infinity