-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathuninstall.py
More file actions
52 lines (44 loc) · 1.14 KB
/
Copy pathuninstall.py
File metadata and controls
52 lines (44 loc) · 1.14 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
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():
# Remove cfw
cmd("rm -rf /etc/cfw/")
# Remove cfw for systemd
cmd("systemctl stop cfw")
cmd("rm /etc/systemd/system/cfw.service")
cmd("systemctl daemon-reload")
# Delete environment variable
with open("/root/.bashrc", "r") as f:
text = f.read()
lines = text.splitlines()
text_new = ""
for line in lines:
if "alias cfw='/etc/cfw/py39/bin/python /etc/cfw/client.py'" not in line:
text_new += line + "\n"
with open("/root/.bashrc", "w") as f:
f.write(text_new)
print("CFW uninstallation complete.")
if __name__ == "__main__":
main()