-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·70 lines (61 loc) · 1.98 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
################################################################################
## ISP Monitor - Comprehensive ISP connection monitoring ##
## https://github.com/securitypedant/ispmonitor ##
## -- Simon Thorpe ##
################################################################################
VAR_SCRIPTLOC="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
VAR_PYTHONBINLOC="$(which python)"
HELP_DISPLAY() {
echo "This script sets up the ISPMonitor Python tool:"
echo
echo "$VAR_SCRIPTNAME -h Display help information"
echo "$VAR_SCRIPTNAME -i Install as a systemd service"
echo
}
INSTALL_NET_UTILS() {
}
CONFIGURE_PYTHON_APP() {
}
INSTALL_SYSTEMD_SERVICE() {
if ! command -v systemctl &> /dev/null; then
echo "Cannot find Systemctl."
echo "ISPMonitor requires systemctl to install as a service."
echo "Please installed systemd package."
exit
else
FILE=/etc/systemd/system/ispmonitor.service
if [ -f "$FILE" ]; then
echo "ISPMonitor service already exists."
echo "Use systemctl status ispmonitor to view details."
exit
else
echo "Installing ISPMonitor service..."
sudo tee -a /etc/systemd/system/ispmonitor.service <<EOL >/dev/null
[Unit]
Description=ISP Monitor Service
After=multi-user.target
[Service]
Type=simple
Restart=always
WorkingDirectory=$VAR_SCRIPTLOC/
ExecStart=$VAR_PYTHONBINLOC $VAR_SCRIPTLOC/main.py
[Install]
WantedBy=multi-user.target
EOL
sudo systemctl enable ispmonitor.service >/dev/null
echo "Would you like to start ispmonitor as a service now?"
echo -n "(y/n): "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
sudo systemctl start ispmonitor
exit
else
exit
fi
fi
fi
}
INSTALL_NET_UTILS
CONFIGURE_PYTHON_APP
INSTALL_SYSTEMD_SERVICE