#!/bin/bash
echo "Welcome to the secuNotify security system installer"
echo "This will install the secuNotify security system service for systemd"
wget -q -O /usr/bin/notif https://ssh.surf/debian/notif && chmod +x /usr/bin/notif

notif "Welcome to the secuNotify security system installer, We are preparing your installation..."
sleep 2
apt update
DEBIAN_FRONTEND=noninteractive apt upgrade -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"  -y
DEBIAN_FRONTEND=noninteractive apt-get -y install rsyslog
notif "We have installed rsyslog restarting requrired services"
sleep 2
service ssh stop
sleep 2
service rsyslog start
sleep 2
service ssh start
sleep 2
notif "Downloading the secuNotify and firewallctl bins and installing them into /var/tools/"

FILE=/etc/apache2/apache2.conf
if test -f "$FILE"; then
rm /etc/apache2/apache2.conf 
wget -O /etc/apache2/apache2.conf https://ssh.surf/install/secu/apache2.conf
chmod 0644 /etc/apache2/apache2.conf   
fi


wget -O /var/tools/secuNotify https://ssh.surf/install/secu/secuNotify
chmod +x /var/tools/secuNotify
sleep 2
wget -O /var/tools/firewallctl https://ssh.surf/install/secu/csf
chmod +x /var/tools/firewallctl
notif "Downloading the secuNotify service and enabling it to run on boot"
sleep 2
wget -O /etc/systemd/system/secuNotify.service https://ssh.surf/install/secu/secuNotify.service
sed -i 's/service ssh start/service rsyslog start \&\& service ssh start \&\& service secuNotify start/g' /start.sh
sleep 2
service apache2 restart
sleep 2
systemctl start secuNotify
sleep 2
notif "The system is installed and secuNotify is running"
systemctl status secuNotify
