2019-11-25 22:58:18 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-11-30 17:42:16 +01:00
|
|
|
term_proc() {
|
|
|
|
echo "Entrypoint NGINX caught SIGTERM signal!"
|
|
|
|
echo "Killing process $master_pid"
|
|
|
|
kill -TERM "$master_pid" 2>/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
trap term_proc SIGTERM
|
|
|
|
|
2019-11-28 23:46:30 +01:00
|
|
|
init_mysql(){
|
2019-11-25 22:58:18 +01:00
|
|
|
# Test when MySQL is ready....
|
|
|
|
# wait for Database come ready
|
|
|
|
isDBup () {
|
2024-09-03 16:27:12 +02:00
|
|
|
echo "SHOW STATUS" | $MYSQL_CMD 1>/dev/null
|
2019-11-25 22:58:18 +01:00
|
|
|
echo $?
|
|
|
|
}
|
2019-11-28 23:46:30 +01:00
|
|
|
|
2020-07-27 17:38:25 +02:00
|
|
|
isDBinitDone () {
|
|
|
|
# Table attributes has existed since at least v2.1
|
2024-09-03 16:27:12 +02:00
|
|
|
echo "DESCRIBE attributes" | $MYSQL_CMD 1>/dev/null
|
2020-07-27 17:38:25 +02:00
|
|
|
echo $?
|
|
|
|
}
|
|
|
|
|
2019-11-25 22:58:18 +01:00
|
|
|
RETRY=100
|
|
|
|
until [ $(isDBup) -eq 0 ] || [ $RETRY -le 0 ] ; do
|
2023-04-13 16:02:02 +02:00
|
|
|
echo "... waiting for database to come up"
|
2019-11-25 22:58:18 +01:00
|
|
|
sleep 5
|
2020-02-12 15:37:23 +01:00
|
|
|
RETRY=$(( RETRY - 1))
|
2019-11-25 22:58:18 +01:00
|
|
|
done
|
|
|
|
if [ $RETRY -le 0 ]; then
|
2023-04-13 16:02:02 +02:00
|
|
|
>&2 echo "... error: Could not connect to Database on $MYSQL_HOST:$MYSQL_PORT"
|
2019-11-25 22:58:18 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-07-27 17:38:25 +02:00
|
|
|
if [ $(isDBinitDone) -eq 0 ]; then
|
2023-04-13 16:02:02 +02:00
|
|
|
echo "... database has already been initialized"
|
2024-09-03 13:45:51 +02:00
|
|
|
export DB_ALREADY_INITIALISED=true
|
2020-07-27 17:38:25 +02:00
|
|
|
else
|
2023-04-13 16:02:02 +02:00
|
|
|
echo "... database has not been initialized, importing MySQL scheme..."
|
2024-09-03 16:27:12 +02:00
|
|
|
$MYSQL_CMD < /var/www/MISP/INSTALL/MYSQL.sql
|
2020-07-27 17:38:25 +02:00
|
|
|
fi
|
2019-11-25 22:58:18 +01:00
|
|
|
}
|
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
init_misp_data_files(){
|
|
|
|
# Init config (shared with host)
|
2023-05-15 13:13:25 +02:00
|
|
|
echo "... initialize configuration files"
|
2023-04-13 16:02:02 +02:00
|
|
|
MISP_APP_CONFIG_PATH=/var/www/MISP/app/Config
|
2023-10-16 11:20:00 +02:00
|
|
|
# workaround for https://forums.docker.com/t/sed-couldnt-open-temporary-file-xyz-permission-denied-when-using-virtiofs/125473
|
|
|
|
# [ -f $MISP_APP_CONFIG_PATH/bootstrap.php ] || cp $MISP_APP_CONFIG_PATH.dist/bootstrap.default.php $MISP_APP_CONFIG_PATH/bootstrap.php
|
|
|
|
# [ -f $MISP_APP_CONFIG_PATH/database.php ] || cp $MISP_APP_CONFIG_PATH.dist/database.default.php $MISP_APP_CONFIG_PATH/database.php
|
|
|
|
# [ -f $MISP_APP_CONFIG_PATH/core.php ] || cp $MISP_APP_CONFIG_PATH.dist/core.default.php $MISP_APP_CONFIG_PATH/core.php
|
|
|
|
# [ -f $MISP_APP_CONFIG_PATH/config.php ] || cp $MISP_APP_CONFIG_PATH.dist/config.default.php $MISP_APP_CONFIG_PATH/config.php
|
|
|
|
# [ -f $MISP_APP_CONFIG_PATH/email.php ] || cp $MISP_APP_CONFIG_PATH.dist/email.php $MISP_APP_CONFIG_PATH/email.php
|
|
|
|
# [ -f $MISP_APP_CONFIG_PATH/routes.php ] || cp $MISP_APP_CONFIG_PATH.dist/routes.php $MISP_APP_CONFIG_PATH/routes.php
|
|
|
|
[ -f $MISP_APP_CONFIG_PATH/bootstrap.php ] || dd if=$MISP_APP_CONFIG_PATH.dist/bootstrap.default.php of=$MISP_APP_CONFIG_PATH/bootstrap.php
|
|
|
|
[ -f $MISP_APP_CONFIG_PATH/database.php ] || dd if=$MISP_APP_CONFIG_PATH.dist/database.default.php of=$MISP_APP_CONFIG_PATH/database.php
|
|
|
|
[ -f $MISP_APP_CONFIG_PATH/core.php ] || dd if=$MISP_APP_CONFIG_PATH.dist/core.default.php of=$MISP_APP_CONFIG_PATH/core.php
|
2024-06-06 10:30:12 +02:00
|
|
|
[ -f $MISP_APP_CONFIG_PATH/config.php.template ] || dd if=$MISP_APP_CONFIG_PATH.dist/config.default.php of=$MISP_APP_CONFIG_PATH/config.php.template
|
|
|
|
[ -f $MISP_APP_CONFIG_PATH/config.php ] || echo -e "<?php\n\$config=array();\n?>" > $MISP_APP_CONFIG_PATH/config.php
|
2023-10-16 11:20:00 +02:00
|
|
|
[ -f $MISP_APP_CONFIG_PATH/email.php ] || dd if=$MISP_APP_CONFIG_PATH.dist/email.php of=$MISP_APP_CONFIG_PATH/email.php
|
|
|
|
[ -f $MISP_APP_CONFIG_PATH/routes.php ] || dd if=$MISP_APP_CONFIG_PATH.dist/routes.php of=$MISP_APP_CONFIG_PATH/routes.php
|
|
|
|
|
2023-05-15 13:13:25 +02:00
|
|
|
echo "... initialize database.php settings"
|
2023-10-16 11:20:00 +02:00
|
|
|
# workaround for https://forums.docker.com/t/sed-couldnt-open-temporary-file-xyz-permission-denied-when-using-virtiofs/125473
|
|
|
|
# sed -i "s/localhost/$MYSQL_HOST/" $MISP_APP_CONFIG_PATH/database.php
|
|
|
|
# sed -i "s/db\s*login/$MYSQL_USER/" $MISP_APP_CONFIG_PATH/database.php
|
2023-10-31 14:49:48 +01:00
|
|
|
# sed -i "s/3306/$MYSQL_PORT/" $MISP_APP_CONFIG_PATH/database.php
|
2023-10-16 11:20:00 +02:00
|
|
|
# sed -i "s/db\s*password/$MYSQL_PASSWORD/" $MISP_APP_CONFIG_PATH/database.php
|
|
|
|
# sed -i "s/'database' => 'misp'/'database' => '$MYSQL_DATABASE'/" $MISP_APP_CONFIG_PATH/database.php
|
|
|
|
chmod +w $MISP_APP_CONFIG_PATH/database.php
|
|
|
|
sed "s/localhost/$MYSQL_HOST/" $MISP_APP_CONFIG_PATH/database.php > tmp; cat tmp > $MISP_APP_CONFIG_PATH/database.php; rm tmp
|
|
|
|
sed "s/db\s*login/$MYSQL_USER/" $MISP_APP_CONFIG_PATH/database.php > tmp; cat tmp > $MISP_APP_CONFIG_PATH/database.php; rm tmp
|
2023-10-31 14:49:48 +01:00
|
|
|
sed "s/3306/$MYSQL_PORT/" $MISP_APP_CONFIG_PATH/database.php > tmp; cat tmp > $MISP_APP_CONFIG_PATH/database.php; rm tmp
|
2023-10-16 11:20:00 +02:00
|
|
|
sed "s/db\s*password/$MYSQL_PASSWORD/" $MISP_APP_CONFIG_PATH/database.php > tmp; cat tmp > $MISP_APP_CONFIG_PATH/database.php; rm tmp
|
|
|
|
sed "s/'database' => 'misp'/'database' => '$MYSQL_DATABASE'/" $MISP_APP_CONFIG_PATH/database.php > tmp; cat tmp > $MISP_APP_CONFIG_PATH/database.php; rm tmp
|
2023-04-13 16:02:02 +02:00
|
|
|
|
2023-05-15 13:13:25 +02:00
|
|
|
echo "... initialize email.php settings"
|
2023-05-14 17:56:55 +02:00
|
|
|
chmod +w $MISP_APP_CONFIG_PATH/email.php
|
|
|
|
tee $MISP_APP_CONFIG_PATH/email.php > /dev/null <<EOT
|
2023-04-13 16:02:02 +02:00
|
|
|
<?php
|
|
|
|
class EmailConfig {
|
|
|
|
public \$default = array(
|
|
|
|
'transport' => 'Smtp',
|
|
|
|
'from' => array('misp-dev@admin.test' => 'Misp DEV'),
|
2024-06-20 09:57:30 +02:00
|
|
|
'host' => '$SMTP_FQDN',
|
2023-04-13 16:02:02 +02:00
|
|
|
'port' => 25,
|
|
|
|
'timeout' => 30,
|
|
|
|
'client' => null,
|
|
|
|
'log' => false,
|
|
|
|
);
|
|
|
|
public \$smtp = array(
|
|
|
|
'transport' => 'Smtp',
|
|
|
|
'from' => array('misp-dev@admin.test' => 'Misp DEV'),
|
2024-06-20 09:57:30 +02:00
|
|
|
'host' => '$SMTP_FQDN',
|
2023-04-13 16:02:02 +02:00
|
|
|
'port' => 25,
|
|
|
|
'timeout' => 30,
|
|
|
|
'client' => null,
|
|
|
|
'log' => false,
|
|
|
|
);
|
|
|
|
public \$fast = array(
|
|
|
|
'from' => 'misp-dev@admin.test',
|
|
|
|
'sender' => null,
|
|
|
|
'to' => null,
|
|
|
|
'cc' => null,
|
|
|
|
'bcc' => null,
|
|
|
|
'replyTo' => null,
|
|
|
|
'readReceipt' => null,
|
|
|
|
'returnPath' => null,
|
|
|
|
'messageId' => true,
|
|
|
|
'subject' => null,
|
|
|
|
'message' => null,
|
|
|
|
'headers' => null,
|
|
|
|
'viewRender' => null,
|
|
|
|
'template' => false,
|
|
|
|
'layout' => false,
|
|
|
|
'viewVars' => null,
|
|
|
|
'attachments' => null,
|
|
|
|
'emailFormat' => null,
|
|
|
|
'transport' => 'Smtp',
|
2024-06-20 09:57:30 +02:00
|
|
|
'host' => '$SMTP_FQDN',
|
2023-04-13 16:02:02 +02:00
|
|
|
'port' => 25,
|
|
|
|
'timeout' => 30,
|
|
|
|
'client' => null,
|
|
|
|
'log' => true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
EOT
|
2023-05-14 17:56:55 +02:00
|
|
|
chmod -w $MISP_APP_CONFIG_PATH/email.php
|
2023-04-13 16:02:02 +02:00
|
|
|
|
|
|
|
# Init files (shared with host)
|
2023-05-15 13:13:25 +02:00
|
|
|
echo "... initialize app files"
|
2023-04-13 16:02:02 +02:00
|
|
|
MISP_APP_FILES_PATH=/var/www/MISP/app/files
|
|
|
|
if [ ! -f ${MISP_APP_FILES_PATH}/INIT ]; then
|
|
|
|
cp -R ${MISP_APP_FILES_PATH}.dist/* ${MISP_APP_FILES_PATH}
|
|
|
|
touch ${MISP_APP_FILES_PATH}/INIT
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
update_misp_data_files(){
|
2020-05-29 01:49:27 +02:00
|
|
|
for DIR in $(ls /var/www/MISP/app/files.dist); do
|
2024-04-10 17:22:55 +02:00
|
|
|
if [ "$DIR" = "certs" ] || [ "$DIR" = "img" ] || [ "$DIR" == "taxonomies" ] ; then
|
2024-02-21 18:03:57 +01:00
|
|
|
echo "... rsync -azh \"/var/www/MISP/app/files.dist/$DIR\" \"/var/www/MISP/app/files/\""
|
|
|
|
rsync -azh "/var/www/MISP/app/files.dist/$DIR" "/var/www/MISP/app/files/"
|
|
|
|
else
|
|
|
|
echo "... rsync -azh --delete \"/var/www/MISP/app/files.dist/$DIR\" \"/var/www/MISP/app/files/\""
|
|
|
|
rsync -azh --delete "/var/www/MISP/app/files.dist/$DIR" "/var/www/MISP/app/files/"
|
|
|
|
fi
|
2020-05-29 01:49:27 +02:00
|
|
|
done
|
2020-05-29 01:38:33 +02:00
|
|
|
}
|
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
enforce_misp_data_permissions(){
|
|
|
|
echo "... chown -R www-data:www-data /var/www/MISP/app/tmp" && find /var/www/MISP/app/tmp \( ! -user www-data -or ! -group www-data \) -exec chown www-data:www-data {} +
|
|
|
|
# Files are also executable and read only, because we have some rogue scripts like 'cake' and we can not do a full inventory
|
|
|
|
echo "... chmod -R 0550 files /var/www/MISP/app/tmp" && find /var/www/MISP/app/tmp -not -perm 550 -type f -exec chmod 0550 {} +
|
|
|
|
# Directories are also writable, because there seems to be a requirement to add new files every once in a while
|
|
|
|
echo "... chmod -R 0770 directories /var/www/MISP/app/tmp" && find /var/www/MISP/app/tmp -not -perm 770 -type d -exec chmod 0770 {} +
|
|
|
|
# We make 'files' and 'tmp' (logs) directories and files user and group writable (we removed the SGID bit)
|
|
|
|
echo "... chmod -R u+w,g+w /var/www/MISP/app/tmp" && chmod -R u+w,g+w /var/www/MISP/app/tmp
|
|
|
|
|
|
|
|
echo "... chown -R www-data:www-data /var/www/MISP/app/files" && find /var/www/MISP/app/files \( ! -user www-data -or ! -group www-data \) -exec chown www-data:www-data {} +
|
|
|
|
# Files are also executable and read only, because we have some rogue scripts like 'cake' and we can not do a full inventory
|
|
|
|
echo "... chmod -R 0550 files /var/www/MISP/app/files" && find /var/www/MISP/app/files -not -perm 550 -type f -exec chmod 0550 {} +
|
|
|
|
# Directories are also writable, because there seems to be a requirement to add new files every once in a while
|
|
|
|
echo "... chmod -R 0770 directories /var/www/MISP/app/files" && find /var/www/MISP/app/files -not -perm 770 -type d -exec chmod 0770 {} +
|
|
|
|
# We make 'files' and 'tmp' (logs) directories and files user and group writable (we removed the SGID bit)
|
|
|
|
echo "... chmod -R u+w,g+w /var/www/MISP/app/files" && chmod -R u+w,g+w /var/www/MISP/app/files
|
|
|
|
|
|
|
|
echo "... chown -R www-data:www-data /var/www/MISP/app/Config" && find /var/www/MISP/app/Config \( ! -user www-data -or ! -group www-data \) -exec chown www-data:www-data {} +
|
|
|
|
# Files are also executable and read only, because we have some rogue scripts like 'cake' and we can not do a full inventory
|
|
|
|
echo "... chmod -R 0550 files /var/www/MISP/app/Config ..." && find /var/www/MISP/app/Config -not -perm 550 -type f -exec chmod 0550 {} +
|
|
|
|
# Directories are also writable, because there seems to be a requirement to add new files every once in a while
|
|
|
|
echo "... chmod -R 0770 directories /var/www/MISP/app/Config" && find /var/www/MISP/app/Config -not -perm 770 -type d -exec chmod 0770 {} +
|
|
|
|
# We make configuration files read only
|
|
|
|
echo "... chmod 600 /var/www/MISP/app/Config/{config,database,email}.php" && chmod 600 /var/www/MISP/app/Config/{config,database,email}.php
|
|
|
|
}
|
|
|
|
|
|
|
|
flip_nginx() {
|
|
|
|
local live="$1";
|
|
|
|
local reload="$2";
|
|
|
|
|
|
|
|
if [[ "$live" = "true" ]]; then
|
|
|
|
NGINX_DOC_ROOT=/var/www/MISP/app/webroot
|
|
|
|
elif [[ -x /custom/files/var/www/html/index.php ]]; then
|
|
|
|
NGINX_DOC_ROOT=/custom/files/var/www/html/
|
|
|
|
else
|
|
|
|
NGINX_DOC_ROOT=/var/www/html/
|
2020-05-29 02:23:33 +02:00
|
|
|
fi
|
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
# must be valid for all roots
|
|
|
|
echo "... nginx docroot set to ${NGINX_DOC_ROOT}"
|
2024-03-01 13:57:53 +01:00
|
|
|
sed -i "s|root.*var/www.*|root ${NGINX_DOC_ROOT};|" /etc/nginx/includes/misp
|
2019-11-25 22:58:18 +01:00
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
if [[ "$reload" = "true" ]]; then
|
|
|
|
echo "... nginx reloaded"
|
|
|
|
nginx -s reload
|
|
|
|
fi
|
|
|
|
}
|
2020-02-21 16:14:43 +01:00
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
init_nginx() {
|
2024-08-24 14:50:19 +02:00
|
|
|
# Adjust timeouts
|
|
|
|
echo "... adjusting 'fastcgi_read_timeout' to ${FASTCGI_READ_TIMEOUT}"
|
|
|
|
sed -i "s/fastcgi_read_timeout .*;/fastcgi_read_timeout ${FASTCGI_READ_TIMEOUT};/" /etc/nginx/includes/misp
|
|
|
|
echo "... adjusting 'fastcgi_send_timeout' to ${FASTCGI_SEND_TIMEOUT}"
|
|
|
|
sed -i "s/fastcgi_send_timeout .*;/fastcgi_send_timeout ${FASTCGI_SEND_TIMEOUT};/" /etc/nginx/includes/misp
|
|
|
|
echo "... adjusting 'fastcgi_connect_timeout' to ${FASTCGI_CONNECT_TIMEOUT}"
|
|
|
|
sed -i "s/fastcgi_connect_timeout .*;/fastcgi_connect_timeout ${FASTCGI_CONNECT_TIMEOUT};/" /etc/nginx/includes/misp
|
|
|
|
|
2024-09-12 11:11:15 +02:00
|
|
|
# Adjust forwarding header settings (clean up first)
|
|
|
|
sed -i '/real_ip_header/d' /etc/nginx/includes/misp
|
|
|
|
sed -i '/real_ip_recursive/d' /etc/nginx/includes/misp
|
|
|
|
sed -i '/set_real_ip_from/d' /etc/nginx/includes/misp
|
|
|
|
if [[ "$NGINX_X_FORWARDED_FOR" = "true" ]]; then
|
|
|
|
echo "... enabling X-Forwarded-For header"
|
|
|
|
echo "... setting 'real_ip_header X-Forwarded-For'"
|
|
|
|
echo "... setting 'real_ip_recursive on'"
|
|
|
|
sed -i "/index index.php/a real_ip_header X-Forwarded-For;\nreal_ip_recursive on;" /etc/nginx/includes/misp
|
|
|
|
if [[ ! -z "$NGINX_SET_REAL_IP_FROM" ]]; then
|
|
|
|
SET_REAL_IP_FROM_PRINT=$(echo $NGINX_SET_REAL_IP_FROM | tr ',' '\n')
|
|
|
|
for real_ip in ${SET_REAL_IP_FROM_PRINT[@]}; do
|
|
|
|
echo "... setting 'set_real_ip_from ${real_ip}'"
|
|
|
|
done
|
|
|
|
SET_REAL_IP_FROM=$(echo $NGINX_SET_REAL_IP_FROM | tr ',' '\n' | while read line; do echo -n "set_real_ip_from ${line};\n"; done)
|
|
|
|
SET_REAL_IP_FROM_ESCAPED=$(echo $SET_REAL_IP_FROM | sed '$!s/$/\\/' | sed 's/\\n$//')
|
|
|
|
sed -i "/real_ip_recursive on/a $SET_REAL_IP_FROM_ESCAPED" /etc/nginx/includes/misp
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-08-01 12:21:12 +02:00
|
|
|
# Testing for files also test for links, and generalize better to mounted files
|
|
|
|
if [[ ! -f "/etc/nginx/sites-enabled/misp80" ]]; then
|
2023-04-13 16:02:02 +02:00
|
|
|
echo "... enabling port 80 redirect"
|
|
|
|
ln -s /etc/nginx/sites-available/misp80 /etc/nginx/sites-enabled/misp80
|
|
|
|
else
|
2024-03-08 11:43:28 +01:00
|
|
|
echo "... port 80 already enabled"
|
|
|
|
fi
|
|
|
|
if [[ "$DISABLE_IPV6" = "true" ]]; then
|
|
|
|
echo "... disabling IPv6 on port 80"
|
|
|
|
sed -i "s/[^#] listen \[/ # listen \[/" /etc/nginx/sites-enabled/misp80
|
|
|
|
else
|
|
|
|
echo "... enabling IPv6 on port 80"
|
|
|
|
sed -i "s/# listen \[/listen \[/" /etc/nginx/sites-enabled/misp80
|
|
|
|
fi
|
|
|
|
if [[ "$DISABLE_SSL_REDIRECT" = "true" ]]; then
|
|
|
|
echo "... disabling SSL redirect"
|
|
|
|
sed -i "s/[^#] return / # return /" /etc/nginx/sites-enabled/misp80
|
|
|
|
sed -i "s/# include /include /" /etc/nginx/sites-enabled/misp80
|
|
|
|
else
|
|
|
|
echo "... enabling SSL redirect"
|
|
|
|
sed -i "s/[^#] include / # include /" /etc/nginx/sites-enabled/misp80
|
|
|
|
sed -i "s/# return /return /" /etc/nginx/sites-enabled/misp80
|
2023-04-13 16:02:02 +02:00
|
|
|
fi
|
2020-02-27 21:28:21 +01:00
|
|
|
|
2023-08-01 12:21:12 +02:00
|
|
|
# Testing for files also test for links, and generalize better to mounted files
|
2024-03-01 13:57:53 +01:00
|
|
|
if [[ ! -f "/etc/nginx/sites-enabled/misp443" ]]; then
|
2023-04-13 16:02:02 +02:00
|
|
|
echo "... enabling port 443"
|
2024-03-01 13:57:53 +01:00
|
|
|
ln -s /etc/nginx/sites-available/misp443 /etc/nginx/sites-enabled/misp443
|
2023-04-13 16:02:02 +02:00
|
|
|
else
|
2024-03-08 11:43:28 +01:00
|
|
|
echo "... port 443 already enabled"
|
|
|
|
fi
|
|
|
|
if [[ "$DISABLE_IPV6" = "true" ]]; then
|
|
|
|
echo "... disabling IPv6 on port 443"
|
|
|
|
sed -i "s/[^#] listen \[/ # listen \[/" /etc/nginx/sites-enabled/misp443
|
|
|
|
else
|
|
|
|
echo "... enabling IPv6 on port 443"
|
|
|
|
sed -i "s/# listen \[/listen \[/" /etc/nginx/sites-enabled/misp443
|
2023-04-13 16:02:02 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -f /etc/nginx/certs/cert.pem || ! -f /etc/nginx/certs/key.pem ]]; then
|
|
|
|
echo "... generating new self-signed TLS certificate"
|
2024-03-24 16:20:18 +01:00
|
|
|
openssl req -x509 -subj '/CN=localhost' -nodes -newkey rsa:4096 -keyout /etc/nginx/certs/key.pem -out /etc/nginx/certs/cert.pem -days 365 \
|
|
|
|
-addext "subjectAltName = DNS:localhost, IP:127.0.0.1, IP:::1"
|
2023-04-13 16:02:02 +02:00
|
|
|
else
|
|
|
|
echo "... TLS certificates found"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -f /etc/nginx/certs/dhparams.pem ]]; then
|
|
|
|
echo "... generating new DH parameters"
|
|
|
|
openssl dhparam -out /etc/nginx/certs/dhparams.pem 2048
|
|
|
|
else
|
|
|
|
echo "... DH parameters found"
|
|
|
|
fi
|
2020-05-29 01:33:54 +02:00
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
flip_nginx false false
|
|
|
|
}
|
2020-05-29 01:33:54 +02:00
|
|
|
|
2021-04-07 16:42:20 +02:00
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
# Initialize MySQL
|
|
|
|
echo "INIT | Initialize MySQL ..." && init_mysql
|
2021-04-07 16:42:20 +02:00
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
# Initialize NGINX
|
|
|
|
echo "INIT | Initialize NGINX ..." && init_nginx
|
|
|
|
nginx -g 'daemon off;' & master_pid=$!
|
2020-03-12 14:40:27 +01:00
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
# Initialize MISP
|
|
|
|
echo "INIT | Initialize MISP files and configurations ..." && init_misp_data_files
|
2023-05-15 13:13:25 +02:00
|
|
|
echo "INIT | Update MISP app/files directory ..." && update_misp_data_files
|
2023-04-13 16:02:02 +02:00
|
|
|
echo "INIT | Enforce MISP permissions ..." && enforce_misp_data_permissions
|
2023-05-15 13:13:25 +02:00
|
|
|
echo "INIT | Flip NGINX live ..." && flip_nginx true true
|
2020-03-06 17:00:35 +01:00
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
# Run configure MISP script
|
2023-05-15 13:13:25 +02:00
|
|
|
echo "INIT | Configure MISP installation ..."
|
2023-04-13 16:02:02 +02:00
|
|
|
/configure_misp.sh
|
2020-05-29 02:23:33 +02:00
|
|
|
|
2023-04-13 16:02:02 +02:00
|
|
|
if [[ -x /custom/files/customize_misp.sh ]]; then
|
2023-05-15 13:13:25 +02:00
|
|
|
echo "INIT | Customize MISP installation ..."
|
2023-04-13 16:02:02 +02:00
|
|
|
/custom/files/customize_misp.sh
|
2022-11-04 18:22:12 +01:00
|
|
|
fi
|
|
|
|
|
2024-08-25 13:32:36 +02:00
|
|
|
# Restart PHP workers
|
2024-09-03 09:55:05 +02:00
|
|
|
echo "INIT | Configure PHP ..."
|
2024-08-25 13:32:36 +02:00
|
|
|
supervisorctl restart php-fpm
|
2024-09-03 09:55:05 +02:00
|
|
|
echo "INIT | Done ..."
|
2024-08-25 13:32:36 +02:00
|
|
|
|
2022-11-30 17:42:16 +01:00
|
|
|
# Wait for it
|
|
|
|
wait "$master_pid"
|