0
0
Fork 0
mirror of https://github.com/boltgolt/howdy.git synced 2024-09-19 09:51:19 +02:00

gtk: search for config.ini in /etc/howdy

This commit is contained in:
Patrizio Bruno 2022-04-05 19:20:00 +01:00
parent c345fb1fa8
commit dee239a13c
No known key found for this signature in database
GPG key ID: 829581B9BB81D1C8
3 changed files with 19 additions and 11 deletions

View file

@ -74,16 +74,17 @@ class OnboardingWindow(gtk.Window):
else:
lib_site = None
if lib_site is None:
self.downloadoutputlabel.set_text(_("Unable to find Howdy's installation location"))
return
if lib_site:
conf_path = lib_site + "/security/howdy"
else:
conf_path = "/etc/howdy"
if os.path.exists(lib_site + "/security/howdy/dlib-data/shape_predictor_5_face_landmarks.dat"):
if os.path.exists(conf_path + "/dlib-data/shape_predictor_5_face_landmarks.dat"):
self.downloadoutputlabel.set_text(_("Datafiles have already been downloaded!\nClick Next to continue"))
self.enable_next()
return
self.proc = subprocess.Popen("./install.sh", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, cwd=lib_site + "/security/howdy/dlib-data")
self.proc = subprocess.Popen("./install.sh", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, cwd=conf_path + "/howdy/dlib-data")
self.download_lines = []
self.read_download_line()

View file

@ -102,9 +102,9 @@ if not os.path.exists("/tmp/howdy_picked_device"):
newConf.write(configfile)
# Install dlib data files if needed
if not os.path.exists("/lib/security/howdy/dlib-data/shape_predictor_5_face_landmarks.dat"):
if not os.path.exists("/lib/security/howdy/dlib-data/shape_predictor_5_face_landmarks.dat") and not os.path.exists("/etc/howdy/dlib-data/shape_predictor_5_face_landmarks.dat"):
print("Attempting installation of missing data files")
handleStatus(subprocess.call(["./install.sh"], shell=True, cwd="/lib/security/howdy/dlib-data"))
handleStatus(subprocess.call(["./install.sh"], shell=True, cwd="/etc/howdy/dlib-data"))
sys.exit(0)
@ -121,7 +121,7 @@ handleStatus(subprocess.call(["pip3", "install", "--upgrade", "numpy"]))
log("Downloading and unpacking data files")
# Run the bash script to download and unpack the .dat files needed
handleStatus(subprocess.call(["./install.sh"], shell=True, cwd="/lib/security/howdy/dlib-data"))
handleStatus(subprocess.call(["./install.sh"], shell=True, cwd="/etc/howdy/dlib-data"))
log("Downloading dlib")
@ -208,6 +208,7 @@ print("Camera ID saved")
# Secure the howdy folder
handleStatus(sc(["chmod 744 -R /lib/security/howdy/"], shell=True))
handleStatus(sc(["chmod 744 -R /etc/howdy/"], shell=True))
# Allow anyone to execute the python CLI
os.chmod("/lib/security/howdy", 0o755)

View file

@ -9,12 +9,18 @@ import sys
if "upgrade" in sys.argv:
# Try to copy the config file as a backup
try:
if os.path.exists("/lib/security/howdy/config.ini") and not os.path.exists("/etc/howdy/config.ini"):
subprocess.call(["cp /lib/security/howdy/config.ini /tmp/howdy_config_backup_v" + sys.argv[2] + ".ini"], shell=True)
else os.path.exists("/etc/howdy/config.ini"):
subprocess.call(["cp /etc/howdy/config.ini /tmp/howdy_config_backup_v" + sys.argv[2] + ".ini"], shell=True)
# Let the user know so he knows where to look on a failed install
print("Backup of Howdy config file created in /tmp/howdy_config_backup_v" + sys.argv[2] + ".ini")
except subprocess.CalledProcessError:
try:
if os.path.exists("/lib/security/howdy/config.ini") and not os.path.exists("/etc/howdy/config.ini"):
subprocess.call(["cp /lib/security/howdy/config.ini /tmp/howdy_config_backup_v" + sys.argv[2] + ".ini"], shell=True)
else os.path.exists("/etc/howdy/config.ini"):
subprocess.call(["cp /etc/howdy/config.ini /tmp/howdy_config_backup_v" + sys.argv[2] + ".ini"], shell=True)
# Let the user know so he knows where to look on a failed install