mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-06-03 02:57:17 +02:00
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:
parent
c216e50dad
commit
90b4af2627
6 changed files with 39 additions and 34 deletions
|
@ -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__"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue