diff --git a/change_manager.py b/change_manager.py index 96ade8f..c7041f6 100644 --- a/change_manager.py +++ b/change_manager.py @@ -41,13 +41,13 @@ def set_root_password(new_pass): print(f"Issue unlocking root account") print(unlock_result) return False + else: + result = run(["passwd", "-s", "root"],capture_output = True, text = True, input=new_pass) + if result.returncode != 0: + print(f"Issue setting password for root account") + print(result) + return False else: - result = run(["passwd", "-s", "root"],capture_output = True, text = True, input=new_pass) - if result.returncode != 0: - print(f"Issue setting password for root account") - print(result) - return False - print(f"Root account password set successfully.") return True @@ -99,41 +99,6 @@ def change_service_status(setting, service): else: return(disable_service(service)) -def change_keanu_weblite_config(new_hostname): - regex = re.compile('aut ?= ?"([^"]*)"') - target_file = "/var/www/html/chat/assets/index-xXHv_nhZ.js" - match_changed = False - with open(target_file, "r") as f: - lines = f.readlines() - match_exists = False - try: - for i,line in enumerate(lines): - match = regex.search(line) - if match: - match_exists = True - old_hostname = match.group(1) - print(f"Old hostname {old_hostname}, new is {new_hostname}") - if old_hostname != new_hostname: - lines[i] = re.sub(old_hostname, new_hostname, lines[i]) - match_changed = True - break - else: - print(f"Old hostname same as new, not changing Keanu config") - if not match_exists: - print("Keanu weblite match not found!") - return False - except Exception as e: - print(e) - print(line) - if match_changed and lines: - new_lines = "".join(lines) - with open(target_file, "w") as f: - print(f"Writing changed file {target_file}.") - f.write(new_lines) - return True - return False - - def change_line_in_file(target_file: str, regex: str, replacement: str): regex = re.compile(regex) if not os.path.isfile(target_file): @@ -194,17 +159,7 @@ def check_settings(raspap_installed: bool): if s == "enable_deltachat": needs_restart = change_service_status("enable_deltachat", "madmail") or needs_restart if s == "butterbox_hostname": - # change in keanu-weblite compiled assets - new_hostname=f"{load_setting('butterbox_hostname')}.local" -# result_keanu = change_keanu_weblite_config(new_hostname) -# print(f"Changing keanu weblite assets {result_keanu}") -# # change in butterbox-dendrite.conf -# regex_matrix_server = " server_name:.*?.local\n" -# result_matrix = change_line_in_file("../dendrite/butterbox-dendrite.conf", regex_matrix_server, -# f" server_name: {load_setting("butterbox_hostname")}.local\n") -# print(f"Changing dendrite config: {result_matrix}") - # change in /etc/hostname - + # change in /etc/hostname print("Writing new hostname to /etc/hostname") with open("/etc/hostname", 'w') as f: f.write(load_setting('butterbox_hostname'))