-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmaster.py
116 lines (67 loc) · 2.32 KB
/
master.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/python
import os
import subprocess
def hello():
print('Hi NTI300')
print('This is Grants Python Install Script!')
hello()
def tree_install():
print('Installing tree')
os.system('yum -y install tree')
tree_install()
def apache_install():
print('Installing Apache Web Server')
os.system('yum -y install httpd')
print('Starting http service')
os.system('systemctl enable httpd.service')
print('Starting apache server')
os.system('systemctl start httpd.service')
print('IMPORTANT! Create an inbound security rule to open port 80 on the server')
apache_install()
def clone_repo():
print('installing git')
os.system('yum -y install git')
print('cloning Grants github repo')
os.system('git clone https://github.com/grantypantyyy/NTI-300-GG.git')
clone_repo()
def publish_site():
print('Publishing Website')
os.system('sudo cp NTI-300-GG/webgrant.html /var/www/html')
print('adjusting permisions')
os.system('sudo chmod 644 /var/www/html/webgrant.html')
os.system('sudo setenforce 0')
os.system('sudo service httpd restart')
publish_site()
def django_install():
print('Installing Django Web Framework.')
os.chdir('NTI-300-GG')
os.system('chmod +x django_install manage.py')
subprocess.call(['./django_install'])
os.system('python /opt/django/project1/manage.py runserver 0.0.0.0:8000&')
django_install()
def mailx():
print('Installing mailx')
os.system('yum -y install mailx')
mailx()
def crontab():
print('Creating crontab entry for Server Alert emails every 30 minutes.')
os.system('sudo chmod +x /home/ec2-user/NTI-300-GG/cron2.sh')
os.system('(crontab -l 2>/dev/null; echo "0,30 * * * * /home/ec2-user/NTI-300-GG/cron2.sh | mail -s \"Server Alert\" [email protected]") | crontab - ')
os.system('crontab -l')
crontab()
def update_kernel():
print('Updating kernal')
os.system('yum clean all && yum update kernel -y')
print('Done!')
print('Verifying dirty cow patch')
os.system('rpm -q --changelog kernel | grep CVE-2016-5195')
update_kernel()
def awscli():
print('Installing the AWS CLI')
os.system('pip install -y awscli')
awscli()
def boto3():
print('Installing Boto3')
os.system('pip install -y boto3')
print('Install Script Complete! AWS RHEL Server ready to use.')
boto3()