emalderson/ThePhish

Startup script and systemd service [Ubuntu]

majo053 opened this issue · 1 comments

Hello, thank you for this project!

I would like to add startup script and Systemd service:

ThePhish_service.sh

#!/bin/bash
#
#

case "$1" in
  start)
    cd /opt/ThePhish/app/ && /opt/ThePhish/app/venv/bin/python3 thephish_app.py
    ps aux | grep thephish_app.py | grep -v grep | awk -F' ' '{print $2}'
    echo "[  OK  ] ThePhish was successfuly started as PID $PID."
    ;;
  stop)
    PID=$(ps aux | grep thephish_app.py | grep -v grep | awk -F' ' '{print $2}')
    kill -9 $PID
    echo "[  OK  ] ThePhish was successfully stopped."
    ;;
  restart)
    stop
    start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}" >&2
    exit 1
    ;;
esac

Create file /lib/systemd/system/thephish.service

[Unit]
Description=ThePhish
Documentation= https://github.com/emalderson/ThePhish#install-it-using-docker-and-docker-compose
Wants=network-online.target davmail.service
After=network.target network-online.target davmail.service

[Service]
Type=simple
RemainAfterExit=yes
User=root
Group=root
TimeoutStartSec=0
Restart=on-failure
RestartSec=30s
#ExecStartPre=
ExecStart=/opt/ThePhish/ThePhish_service.sh start
ExecStop=/opt/ThePhish/ThePhish_service.sh stop


[Install]
WantedBy=multi-user.target

Thanks, I'll test it!