diff --git a/python/restart.py b/python/restart.py index 6793a8a..b454afa 100755 --- a/python/restart.py +++ b/python/restart.py @@ -7,11 +7,11 @@ import time import traceback import os import datetime -import sys import glob import string whitelist = set(string.ascii_letters + string.digits + "/" + "@" + "." + "-" + "_") +developmentMachine = os.getenv("WEBSITE_DEVELOPER", "false") == "true" def sanitize( @@ -40,7 +40,7 @@ def writeFile( ): # Will write info in json format to a file with open(location, "w") as f: json.dump(info, f) - if permission: + if permission and not developmentMachine: os.system("chown -R www-data:www-data " + location) @@ -54,14 +54,13 @@ try: # Looks at the configuration at understands the config try: configFilePath = __file__[: __file__.rindex("/") + 1] - # Makes sure the python file area is owned by root and not accessable by www-data for security reasons - os.system("chmod 750 -R " + configFilePath) - os.system("chown -R root:root " + configFilePath) configFilePath = configFilePath + "config.json" + if not developmentMachine: + # Makes sure the python file area is owned by root and not accessable by www-data for security reasons + os.system("chmod 750 -R " + configFilePath) + os.system("chown -R root:root " + configFilePath) # Will find the location where the config should be located. location = __file__[: __file__.rindex("/python/restart.py") + 1] + "html/" - # Creates config with the enviromental variables - developmentMachine = os.getenv("WEBSITE_DEVELOPER", "false") == "true" # This stores a list for the default config envConfiguration = [ [["passwordOptions", "cost"], int(os.getenv("PASSWORD_ROUNDS", "10"))], @@ -126,9 +125,10 @@ try: developmentMachine = configuration["developer"] backupLocation = configuration["database"]["backupLocation"] # Makes sure that the permissions are not wrong - os.system("chown -R www-data:www-data " + location) - os.system(f"chmod 644 -R {backupLocation}") - os.system("chmod 750 -R " + location) + if not developmentMachine: + os.system("chown -R www-data:www-data " + location) + os.system(f"chmod 644 -R {backupLocation}") + os.system("chmod 750 -R " + location) f = open(location + "/maintenance-mode", "w") f.close() while ( @@ -437,8 +437,9 @@ except Exception as e: f.write(error(e)) f = open(location + "maintenance-mode", "w") f.close() - os.system("chmod 750 -R " + location) - os.system("chown -R www-data:www-data " + location) + if not developmentMachine: + os.system("chmod 750 -R " + location) + os.system("chown -R www-data:www-data " + location) except Exception: print("crash") while True: