move requirements from Dockerfile to txt file. #67

import sqlite_web as package
change tz through python
conditionnal import for sqlite_web
This commit is contained in:
edgd1er 2022-04-22 23:41:55 +02:00
parent c216e50dad
commit 90b4af2627
No known key found for this signature in database
GPG key ID: F7B8E0D6C867CCAE
6 changed files with 39 additions and 34 deletions

View file

@ -9,6 +9,7 @@ import pwd
import subprocess
import sys
import signal
import time
PYTHON3 = '/usr/bin/python3'
dbPath = os.path.join(os.sep, 'home', 'py-kms', 'db') # Do not include the database file name, as we must correct the folder permissions (the db file is recursively reachable)
@ -26,6 +27,9 @@ loggersrv.addHandler(streamhandler)
def change_uid_grp():
if os.geteuid() != 0:
loggersrv.info(f'not root user, cannot change uid/gid.')
return None
user_db_entries = pwd.getpwnam("py-kms")
user_grp_db_entries = grp.getgrnam("power_users")
uid = int(user_db_entries.pw_uid)
@ -64,11 +68,7 @@ def change_tz():
# TZ is not symlinked and defined TZ exists
if tz not in os.readlink('/etc/localtime') and os.path.isfile('/usr/share/zoneinfo/' + tz):
loggersrv.info("Setting timzeone to %s" % tz )
os.remove('/etc/localtime')
os.symlink(os.path.join('/usr/share/zoneinfo/', tz), '/etc/localtime')
f = open("/etc/timezone", "w")
f.write(tz)
f.close()
time.tzset()
# Main
if (__name__ == "__main__"):