-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
62 lines (44 loc) · 1.31 KB
/
install.py
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
# Script to install arpmon
from os import getuid, system
from os.path import exists
service_name = "arpmon"
service_defs = '''[Unit]
Description=ArpMon network monitoring tool
[Service]
WorkingDirectory=$wd
Type=simple
ExecStart=$es $iface $gip
RestartSec=5
Restart=always
SuccessExitStatus=0
[Install]
WantedBy=multi_user.target
'''
if getuid() != 0:
print("[!] Need root permissions")
exit(5)
service_file_path = f'/etc/systemd/system/{service_name}.service'
print(f"[*] Installing service to {service_file_path}")
if exists(service_file_path):
print(f"[!] Service already installed.")
exit(0)
ip = input("Install path: ")
if exists(ip):
print("[!] Directory already exists")
gip = input("Gateway ip: ")
iface = input("Interface name: ")
# Copy all files to install path
service_defs = service_defs.replace("$wd", ip)
service_defs = service_defs.replace("$es", f"{ip}/{service_name}")
service_defs = service_defs.replace("$iface", iface)
service_defs = service_defs.replace("$gip", gip)
system(f"mkdir -p {ip}")
system(f"cp {service_name} {ip} -r -vv")
# Create service
# Write service settings to disk
with open(service_file_path, "w") as file:
file.write(service_defs)
# Enable autorun
system(f"systemctl enable {service_name}")
# Execute service
system(f"systemctl start {service_name}")