-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
40 lines (32 loc) · 992 Bytes
/
server.py
File metadata and controls
40 lines (32 loc) · 992 Bytes
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
import subprocess as sp
import socket
import os
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
ip = "192.168.43.227"
port = 1234
s.bind((ip,port))
s.listen()
c_ses, c_add = s.accept()
while True:
data = c_ses.recv(1000)
cmmnd = data.decode()
if "install" in cmmnd and "Hadoop" in cmmnd:
os.system("ansible-playbook /root/Desktop/reps/conf_hadoop.yml")
output = "hadoop installed"
elif "stop" in cmmnd and "firewall" in cmmnd:
os.system("firewalloff")
output = "firewall flushed"
elif "install" in cmmnd and "docker" in cmmnd:
os.system("ansible-playbook /root/Desktop/reps/ansible_docker.yml")
output = "docker installed"
elif "setup" in cmmnd and "server" in cmmnd:
os.system("ansible-playbook /root/Desktop/reps/httpd.yml")
output = "server has been setup"
elif "click" in cmmnd:
os.system(cmmnd)
output = "http://192.168.43.227:/pic.png"
else:
output = sp.getoutput(cmmnd)
output = output.encode()
c_ses.send(output)