-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
69 lines (53 loc) · 2.28 KB
/
setup.py
File metadata and controls
69 lines (53 loc) · 2.28 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
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
import subprocess
import os
def install(cmd):
FNULL = open(os.devnull, 'w')
try:
out = subprocess.check_call(cmd,stdout=FNULL,shell=True)
return [0,out]
except subprocess.CalledProcessError as excp:
return [excp.returncode,excp.output]
response = install("sudo apt-get update")
if(response[0] != 0):
print("Could not install software")
response=install("sudo apt-get install -y python3")
if(response[0] != 0):
print("could not install python3")
response=install("sudo apt-get install -y python3-pip")
if(response[0] != 0):
print("could not install python3-pip")
response = install("sudo apt-get install -y nmap")
if(response[0] != 0):
print("Could not install nmap")
response = install("sudo apt-add-repository -y ppa:ansible/ansible")
if(response[0] != 0):
print("Could not install software-installer")
response = install("sudo apt-get update")
if(response[0] != 0):
print("Could not install software")
response = install("sudo apt-get -y install ansible")
if(response[0] != 0):
print("Could not install software-installer")
response = install("sudo pip3 install virtualenv")
if(response[0] != 0):
print("Could not install virtualenv")
response = install("sudo apt-get install sshpass")
if(response[0] != 0):
print("Could not install sshpass")
reponse = install("sudo virtualenv -p /usr/bin/python3 env")
if(response[0] != 0):
print("could not create a virtual env")
response = install("./env/bin/pip3 install -r requirements.txt")
if(response[0] != 0):
print("could not install requirements file")
response = install("sudo sed -i 's/# StrictHostKeyChecking ask/StrictHostKeyChecking no/g' /etc/ssh/ssh_config")
if(response[0] != 0):
print("could not edit ssh_config")
response = install('sudo rm -f /root/.ssh/id_rsa.pub')
response = install('sudo rm -f /root/.ssh/id_rsa')
response = install('sudo ssh-keygen -t rsa -f /root/.ssh/id_rsa -q -P ""')
if(response[0] != 0):
print("WARNING: Could not generate Key")
response = install("./env/bin/python3 app.py")
if(response[0] != 0):
print("could not run project")