-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-webpage
executable file
·37 lines (26 loc) · 1.01 KB
/
update-webpage
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
#!/usr/bin/env python3
import hashlib
import os
if os.path.basename(os.getcwd()) != "portfolio-webpage":
print("Wrong directory; Please cd to your nearest portfolio-webpage.")
exit(1)
def md5(file):
return hashlib.md5(open(file).read().encode()).hexdigest()
hash1 = md5("main.py")
hash2 = md5("nginx")
os.system("git fetch")
os.system("git reset --hard origin/master")
os.system("/usr/bin/env python3 work.py")
print("Running 'sudo systemctl daemon-reload'. You may be asked for your password.")
os.system("sudo systemctl daemon-reload")
hash3 = md5("main.py")
hash4 = md5("nginx")
if hash1 != hash3:
print("main.py has changed; Running 'sudo systemctl restart portfolio-webpage-*'")
os.system("sudo systemctl restart portfolio-webpage-1")
os.system("sudo systemctl restart portfolio-webpage-2")
if hash2 != hash4:
print("./nginx has changed; Running 'systemctl restart nginx'...")
os.system("sudo systemctl reload nginx")
os.system("sudo systemctl restart nginx")
print("All done.")