-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd_panel
56 lines (55 loc) · 1.91 KB
/
d_panel
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
#!/usr/bin/env python3
import os
def display_menu():
print("Select the operation you want to perform:")
print("1. Change DPanel admin password")
print("2. Change DPanel Port")
print("3. Start DPanel")
print("4. Stop DPanel")
print("5. Restart DPanel")
print("0. Exit")
def change_password():
os.system(f"/var/server/dpanel/venv/bin/python3 /var/server/dpanel/app/manage.py changepassword admin")
def change_port():
port = input("Enter new port: ")
service_file_path = '/etc/systemd/system/dpanel'
with open(service_file_path, 'r') as file:
service_file_content = file.readlines()
for i, line in enumerate(service_file_content):
if 'ExecStart' in line:
service_file_content[
i] = f'ExecStart=/var/server/dpanel/venv/bin/python /var/server/dpanel/app/manage.py runserver 0.0.0.0:{port}\n'
with open(service_file_path, 'w') as file:
file.writelines(service_file_content)
os.system("sudo systemctl daemon-reload")
os.system("sudo systemctl restart dpanel")
print("Port changed successfully.")
def start_dpanel():
os.system("sudo systemctl start dpanel")
print("DPanel started successfully.")
def restart_dpanel():
os.system("sudo systemctl restart dpanel")
print("DPanel restarted successfully.")
def stop_dpanel():
os.system("sudo systemctl stop dpanel")
print("DPanel stopped successfully.")
def main():
while True:
display_menu()
choice = input("Enter your choice: ")
if choice == '1':
change_password()
elif choice == '2':
change_port()
elif choice == '3':
start_dpanel()
elif choice == '4':
stop_dpanel()
elif choice == '5':
restart_dpanel()
elif choice == '0':
break
else:
print("Invalid choice, please try again.")
if __name__ == "__main__":
main()