Skip to content

Commit

Permalink
run sudo menu script
Browse files Browse the repository at this point in the history
  • Loading branch information
UTXOnly committed Nov 25, 2023
1 parent d225148 commit 9b0a189
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def setup_server():
subprocess.run(["python3", "setup_env.py"], check=True)
subprocess.run(["python3", "-m", "venv", "zap_venv"], check=True)
activate_cmd = ". zap_venv/bin/activate && "
commands = ["python setup_nginx.py"]
commands = ["sudo python setup_nginx.py"]
for cmd in commands:
subprocess.run(["bash", "-c", activate_cmd + cmd], check=True)
except subprocess.CalledProcessError as e:
Expand Down
25 changes: 11 additions & 14 deletions setup_nginx.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,17 @@ def setup_nginx():
}}
"""

if os.path.exists(nginx_filepath):
print_color("The default configuration file already exists.", "31")
else:
try:
with open(nginx_filepath, "w", encoding="utf-8") as f:
f.write(nginx_config)
print_color(
"The default configuration file has been written successfully.", "32"
)
except Exception as e:
print_color(
f"An error occurred while writing the default configuration file: {e}",
"31",
)
try:
with open(nginx_filepath, "w", encoding="utf-8") as f:
f.write(nginx_config)
print_color(
"The default configuration file has been written successfully.", "32"
)
except Exception as e:
print_color(
f"An error occurred while writing the default configuration file: {e}",
"31",
)

try:
subprocess.run(["sudo", "service", "nginx", "restart"], check=True)
Expand Down

0 comments on commit 9b0a189

Please sign in to comment.