From 80be991d939b6a8b6925dfb41a227875f1609b8d Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Mon, 13 May 2019 12:38:15 +0900 Subject: [PATCH] chg: [installer] Added systemd unit file for workers. --- docs/INSTALL.ubuntu1804.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/docs/INSTALL.ubuntu1804.md b/docs/INSTALL.ubuntu1804.md index 712cf7869..51f1967fa 100644 --- a/docs/INSTALL.ubuntu1804.md +++ b/docs/INSTALL.ubuntu1804.md @@ -299,6 +299,12 @@ apacheConfig () { debug "Generating Apache config" sudo cp ${PATH_TO_MISP}/INSTALL/apache.24.misp.ssl /etc/apache2/sites-available/misp-ssl.conf + if [[ ! -z ${MISP_BASEURL} ]] && [[ "$(echo $MISP_BASEURL|cut -f 1 -d :)" == "http" || "$(echo $MISP_BASEURL|cut -f 1 -d :)" == "https" ]]; then + + echo "Potentially replacing misp.local with $MISP_BASEURL in misp-ssl.conf" + + fi + # If a valid SSL certificate is not already created for the server, # create a self-signed certificate: sudo openssl req -newkey rsa:4096 -days 365 -nodes -x509 \ @@ -438,6 +444,7 @@ backgroundWorkers () { debug "Setting up background workers" # To make the background workers start on boot sudo chmod +x $PATH_TO_MISP/app/Console/worker/start.sh + if [ ! -e /etc/rc.local ] then echo '#!/bin/sh -e' | sudo tee -a /etc/rc.local @@ -445,14 +452,28 @@ backgroundWorkers () { sudo chmod u+x /etc/rc.local fi - # Start the workers - $SUDO_WWW bash $PATH_TO_MISP/app/Console/worker/start.sh + echo "[Unit] +Description=MISP background workers +After=network.target + +[Service] +Type=forking +User=${WWW_USER} +Group=${WWW_USER} +ExecStart=${PATH_TO_MISP}/app/Console/worker/start.sh +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target" | sudo tee /etc/systemd/system/misp-workers.service + + sudo systemctl daemon-reload + sudo systemctl enable --now misp-workers # Add the following lines before the last line (exit 0). Make sure that you replace www-data with your apache user: sudo sed -i -e '$i \echo never > /sys/kernel/mm/transparent_hugepage/enabled\n' /etc/rc.local sudo sed -i -e '$i \echo 1024 > /proc/sys/net/core/somaxconn\n' /etc/rc.local sudo sed -i -e '$i \sysctl vm.overcommit_memory=1\n' /etc/rc.local - sudo sed -i -e '$i \sudo -u www-data bash ${PATH_TO_MISP}/app/Console/worker/start.sh > /tmp/worker_start_rc.local.log\n' /etc/rc.local } # ```