-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathupdate.py
More file actions
38 lines (30 loc) · 758 Bytes
/
update.py
File metadata and controls
38 lines (30 loc) · 758 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
import sys
import subprocess
def cmd(cmd: str):
try:
subprocess.run(
cmd,
shell=True,
check=True
)
return True
except subprocess.CalledProcessError as e:
sys.exit(1)
def shell(cmd: str) -> str:
"""
Execute a shell statement and return the output.
"""
r = subprocess.run(
cmd,
shell=True,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
return r.stdout.decode()
def main():
shell("git --git-dir=/etc/cfw/.git --work-tree=/etc/cfw pull https://github.com/Cyberbolt/cfw.git --quiet")
cmd("systemctl start cfw")
print("CFW has been updated.")
if __name__ == "__main__":
main()