-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-container
More file actions
71 lines (58 loc) · 2.3 KB
/
Copy pathstart-container
File metadata and controls
71 lines (58 loc) · 2.3 KB
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
#!/usr/bin/env bash
# prepare the container
if [ ! -d /.composer ]; then
mkdir /.composer
fi
mkdir /var/log/php-fpm/
chmod -R ugo+rw /.composer
# prepare SSL on the container
chmod +x /opt/scripts/make-localhost-cert
/opt/scripts/make-localhost-cert /var/www/localhost.crt
# Prepare custom nginx files
mkdir -p /var/www/html/nginx.d/
if test -e /var/www/html/nginx.d/php-fpm.conf; then
cp /var/www/html/nginx.d/php-fpm.conf /etc/php/8.2/fpm/pool.d/www.conf
fi
if test -e /var/www/html/nginx.d/nginx.conf; then
cp /var/www/html/nginx.d/nginx.conf /etc/nginx/sites-available/default
fi
if test -e /var/www/html/nginx.d/nginx-ssl.conf; then
cp /var/www/html/nginx.d/nginx-ssl.conf /etc/nginx/sites-enabled/default-ssl
fi
if test -e /var/www/html/nginx.d/php.ini; then
cp /var/www/html/nginx.d/php.ini /etc/php/8.2/fpm/php.ini
cp /var/www/html/nginx.d/php.ini /etc/php/8.2/cli/php.ini
fi
# Moving potential supervisor files — clear stale configs first
rm -f /etc/supervisor/conf.d/*.conf 2>/dev/null
if test -d /var/www/html/supervisor.d/; then
cp -r /var/www/html/supervisor.d/* /etc/supervisor/conf.d/
fi
# Prep the cron.d directory
mkdir /var/log/html/cron.d/
chmod o+rwx /var/www/html/cron.d/*.sh
find /var/www/html/cron.d -type f ! -path '*.sh' -delete
# Process web app startup specifics
if test -e /var/www/html/docker.d/; then
chmod o+rwx /var/www/html/docker.d/*.sh
for file in /var/www/html/docker.d/*.sh
do
filename=$(basename "$file")
"$file" >> /var/log/"$filename".log 2>&1
done
fi
# Enable Wazuh agent only when WAZUH_MANAGER is configured
if [ -n "$WAZUH_MANAGER" ] && [ -f /var/ossec/etc/ossec.conf ]; then
sed -i "s|<address>.*</address>|<address>${WAZUH_MANAGER}</address>|" /var/ossec/etc/ossec.conf
if [ -n "$WAZUH_AGENT_NAME" ]; then
sed -i "s|<agent_name>.*</agent_name>|<agent_name>${WAZUH_AGENT_NAME}</agent_name>|" /var/ossec/etc/ossec.conf
fi
sed -i 's/autostart=false/autostart=true/' /etc/supervisor/supervisord.conf
fi
# start the container services
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
# Setting web application permissions
chown -R www-data:www-data /var/www/html
find /var/www/html/ -type f ! -path '*.sh' ! -path '/var/www/html/console' -exec chmod 644 {} \;
find /var/www/html/ -type d -exec chmod 755 {} \;
exit