-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvpn_register.py
More file actions
executable file
·45 lines (38 loc) · 1.18 KB
/
vpn_register.py
File metadata and controls
executable file
·45 lines (38 loc) · 1.18 KB
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
#!/bin/python3
import subprocess
etc_hosts_filename = "/etc/hosts"
etc_ansible_hosts_filename = "/etc/ansible/hosts"
etc_firehol_vpn_list_filename = "/etc/firehol/vpn_list"
vpn_list = []
while True :
a=input("Entrez l'adresse d'un vpn (touche A pour finir) \n")
if a=="A":
break
vpn_list.append(a)
file = open(etc_hosts_filename, "r")
file_content = file.readlines()
file_right_content = []
for line in file_content:
if "vpn" not in line :
file_right_content.append(line)
file.close()
file = open(etc_hosts_filename, "w")
for line in file_right_content :
file.write(line)
i = 1
for ip_vpn in vpn_list :
file.write(ip_vpn + " vpn" + str(i) + "\n")
i+=1
file.close()
file = open(etc_ansible_hosts_filename, "w")
file.write("[vpn] \n\n")
for i in range (len(vpn_list)) :
file.write("vpn" + str(i+1) + " id=" + str(i+1) + "\n")
file.close()
file = open(etc_firehol_vpn_list_filename, "w")
for i in range(len(vpn_list)) :
file.write("vpn" + str(i+1) + "=" + vpn_list[i] +"\n")
file.close()
for i in range(len(vpn_list)) :
s = "ssh-keygen -R vpn" + str(i+1)
subprocess.run(args = s, shell = True)