mirror of https://github.com/MISP/MISP
chg: [tools] misp-workers.service need to be able to be installed on a stick MISP install (Ubuntu) other flavours want to be marked as such. (and in a seperate directory, ideally, etc/systemd/system)
chg: [tools] Backup script todo added chg: [tools] worker start script todo and fix me addedpull/4229/head
parent
ceacaf56d1
commit
640c7f9ac9
|
@ -1,14 +1,14 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=misp-workers
|
Description=misp-workers
|
||||||
After=network.target apache2.service
|
After=network.target remote-fs.target nss-lookup.target httpd.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
KillMode=none
|
KillMode=none
|
||||||
User=www-data
|
User=www-data
|
||||||
Group=misp-server
|
Group=www-data
|
||||||
ExecStart=/bin/bash -c "/opt/misp-server/misp/app/Console/worker/start.sh"
|
ExecStart=/bin/bash -c "/var/www/MISP/app/Console/worker/start.sh"
|
||||||
ExecStop=/bin/bash -c "/opt/misp-server/misp/app/Console/cake CakeResque.CakeResque stop --all"
|
ExecStop=/bin/bash -c "/var/www/MISP/app/Console/cake CakeResque.CakeResque stop --all"
|
||||||
WorkingDirectory=%h
|
WorkingDirectory=%h
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,29 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# TODO: Improve script to bring workers up that are not.
|
||||||
|
|
||||||
|
# Extract base directory where this script is and cd into it
|
||||||
|
cd "${0%/*}"
|
||||||
|
|
||||||
# Check if run as root
|
# Check if run as root
|
||||||
if [ "$EUID" -eq 0 ]; then
|
if [ "$EUID" -eq 0 ]; then
|
||||||
echo "Please DO NOT run the worker script as root"
|
echo "Please DO NOT run the worker script as root"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract base directory where this script is and cd into it
|
##[[ $(../cake CakeResque.CakeResque stop --all |grep "not permitted" ; echo $?) != 1 ]] && echo "Either you have no permissions or CakeResque is not installed/configured" && exit 1
|
||||||
cd "${0%/*}"
|
|
||||||
|
## FIXME: PIDs seem off by 1
|
||||||
|
# Check which workers are currently running
|
||||||
|
WORKERS_PID=$(ps a |grep CakeResque |grep -v grep |cut -f 1 -d\ )
|
||||||
|
|
||||||
|
if [[ ! -z $WORKERS_PID ]]; then
|
||||||
|
for p in $WORKERS_PID; do
|
||||||
|
WORKER_RUNNING=$(ps $p |grep CakeRes|grep -v grep |grep -o -e "QUEUE=.[a-z]*" |cut -f2 -d\')
|
||||||
|
#echo "Worker $WORKER_RUNNING with PID $p"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
../cake CakeResque.CakeResque stop --all
|
../cake CakeResque.CakeResque stop --all
|
||||||
../cake CakeResque.CakeResque start --interval 5 --queue default
|
../cake CakeResque.CakeResque start --interval 5 --queue default
|
||||||
../cake CakeResque.CakeResque start --interval 5 --queue prio
|
../cake CakeResque.CakeResque start --interval 5 --queue prio
|
||||||
|
|
|
@ -2,13 +2,16 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
## $Id: misp-backup.sh 07.04.2016 $
|
## $Id: misp-backup.sh 07.04.2016 $
|
||||||
##
|
##
|
||||||
## script to backup MISP on debian/ubuntu 14.04.1
|
## script to backup MISP on debian/ubuntu 18.04.1
|
||||||
##
|
##
|
||||||
## Authored by daverstephens@gmail.com
|
## Authored by daverstephens@gmail.com
|
||||||
## https://github.com/daverstephens/The-SOC-Shop
|
## https://github.com/daverstephens/The-SOC-Shop
|
||||||
##
|
##
|
||||||
## added some more studd by @alexanderjaeger
|
## added some more studd by @alexanderjaeger
|
||||||
## https://github.com/deralexxx/misp-backup
|
## https://github.com/deralexxx/misp-backup
|
||||||
|
##
|
||||||
|
## more amendments by @SteveClement
|
||||||
|
##
|
||||||
|
|
||||||
##
|
##
|
||||||
## This script can be used to backup a complete MISP
|
## This script can be used to backup a complete MISP
|
||||||
|
@ -16,7 +19,7 @@
|
||||||
## built system. This is not intended as an upgrade script
|
## built system. This is not intended as an upgrade script
|
||||||
## to move between MISP versions - But it might work ;).
|
## to move between MISP versions - But it might work ;).
|
||||||
##
|
##
|
||||||
## Tested against MISP 2.4.96
|
## Tested against MISP 2.4.101
|
||||||
##
|
##
|
||||||
## Run the script as the standard user with the command below
|
## Run the script as the standard user with the command below
|
||||||
##
|
##
|
||||||
|
@ -24,9 +27,37 @@
|
||||||
## vi misp-backup.conf # adjust values
|
## vi misp-backup.conf # adjust values
|
||||||
## sudo sh -x misp-backup.sh 2>&1 | tee misp-backup.log
|
## sudo sh -x misp-backup.sh 2>&1 | tee misp-backup.log
|
||||||
##
|
##
|
||||||
## Time to set some variables
|
## TODO: Target directory, rudimentary free space check: stat -f --format="%a" OutputDirName
|
||||||
|
## TODO: Make sure no directories are blank
|
||||||
##
|
##
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
# Dynamic horizontal spacer
|
||||||
|
space () {
|
||||||
|
if [[ "$NO_PROGRESS" == "1" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# Check terminal width
|
||||||
|
num=`tput cols`
|
||||||
|
for i in `seq 1 $num`; do
|
||||||
|
echo -n "-"
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make sure the target has enough free space
|
||||||
|
checkDiskFree () {
|
||||||
|
threshhold=90
|
||||||
|
free=$(df -l --sync --output=pcent $1 |tail -1|cut -f 1 -d% | tr -d \ )
|
||||||
|
if [ $free > $threshhold ]; then
|
||||||
|
echo "Your destination folder is $threshhold% full."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
## Time to set some variables
|
||||||
|
##
|
||||||
|
|
||||||
FILE=./misp-backup.conf
|
FILE=./misp-backup.conf
|
||||||
|
|
||||||
|
@ -74,6 +105,10 @@ AdminEmail=$(grep -o -P "(?<='contact' => ').*(?=')" $MISPPath/app/Config/config
|
||||||
GnuPGEmail=$(sed -n -e '/GnuPG/,$p' $MISPPath/app/Config/config.php|grep -o -P "(?<='email' => ').*(?=')")
|
GnuPGEmail=$(sed -n -e '/GnuPG/,$p' $MISPPath/app/Config/config.php|grep -o -P "(?<='email' => ').*(?=')")
|
||||||
GnuPGHomeDir=$(grep -o -P "(?<='homedir' => ').*(?=')" $MISPPath/app/Config/config.php)
|
GnuPGHomeDir=$(grep -o -P "(?<='homedir' => ').*(?=')" $MISPPath/app/Config/config.php)
|
||||||
GnuPGPass=$(grep -o -P "(?<='password' => ').*(?=')" $MISPPath/app/Config/config.php)
|
GnuPGPass=$(grep -o -P "(?<='password' => ').*(?=')" $MISPPath/app/Config/config.php)
|
||||||
|
|
||||||
|
## Folders to be checked for useable space: OutputDirName
|
||||||
|
## To be checked for emptiness: all?
|
||||||
|
|
||||||
# Create backup files
|
# Create backup files
|
||||||
TmpDir="$(mktemp --tmpdir=$OutputDirName -d)"
|
TmpDir="$(mktemp --tmpdir=$OutputDirName -d)"
|
||||||
cp -r $GnuPGHomeDir/* $TmpDir/
|
cp -r $GnuPGHomeDir/* $TmpDir/
|
||||||
|
@ -81,6 +116,7 @@ echo "copy of org images and other custom images"
|
||||||
cp -r $MISPPath/app/webroot/img/orgs $TmpDir/
|
cp -r $MISPPath/app/webroot/img/orgs $TmpDir/
|
||||||
cp -r $MISPPath/app/webroot/img/custom $TmpDir/
|
cp -r $MISPPath/app/webroot/img/custom $TmpDir/
|
||||||
cp -r $MISPPath/app/files $TmpDir
|
cp -r $MISPPath/app/files $TmpDir
|
||||||
|
|
||||||
# MISP Config files
|
# MISP Config files
|
||||||
mkdir -p $TmpDir/Config
|
mkdir -p $TmpDir/Config
|
||||||
cp $MISPPath/app/Config/bootstrap.php $TmpDir/Config
|
cp $MISPPath/app/Config/bootstrap.php $TmpDir/Config
|
||||||
|
|
Loading…
Reference in New Issue