Commit 34908761 authored by Roman Alifanov's avatar Roman Alifanov

hotfix: create_config: if system config exists, copy it to home

parent 64736aa5
import sys, os, re import sys, os, shutil, re
import subprocess import subprocess
import functools import functools
...@@ -22,11 +22,16 @@ def create_config(): ...@@ -22,11 +22,16 @@ def create_config():
try: try:
if os.geteuid() == 0: if os.geteuid() == 0:
os.makedirs(SYSTEM_CONFIG_DIR, exist_ok=True) os.makedirs(SYSTEM_CONFIG_DIR, exist_ok=True)
open(SYSTEM_CONFIG_FILE, 'a').close() with open(SYSTEM_CONFIG_FILE, 'a'):
pass
return SYSTEM_CONFIG_FILE return SYSTEM_CONFIG_FILE
else: else:
os.makedirs(HOME_CONFIG_DIR, exist_ok=True) if os.path.exists(SYSTEM_CONFIG_FILE):
open(HOME_CONFIG_FILE, 'a').close() os.makedirs(HOME_CONFIG_DIR, exist_ok=True)
shutil.copyfile(SYSTEM_CONFIG_FILE, HOME_CONFIG_FILE)
else:
os.makedirs(HOME_CONFIG_DIR, exist_ok=True)
open(HOME_CONFIG_FILE, 'a').close()
return HOME_CONFIG_FILE return HOME_CONFIG_FILE
except Exception as e: except Exception as e:
print(f"Error creating config file: {e}") print(f"Error creating config file: {e}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment