diff --git a/docker/entrypoint.py b/docker/entrypoint.py index ea30ede..399d091 100755 --- a/docker/entrypoint.py +++ b/docker/entrypoint.py @@ -19,17 +19,19 @@ argumentVariableMapping = { } # Build the command to execute -command = ['/usr/bin/python3', 'pykms_Server.py', os.environ.get('IP'), os.environ.get('PORT')] +listenIP = os.environ.get('IP', '0.0.0.0') +listenPort = os.environ.get('PORT', '1688') +command = ['/usr/bin/python3', 'pykms_Server.py', listenIP, listenPort] for (arg, env) in argumentVariableMapping.items(): if env in os.environ and os.environ.get(env) != '': command.append(arg) command.append(os.environ.get(env)) -enableSQLITE = os.environ.get('SQLITE') != None and os.environ.get('SQLITE').lower() == 'true' -os.makedirs('db', exist_ok=True) -dbPath = os.path.join('db', 'pykms_database.db') +enableSQLITE = os.environ.get('SQLITE', 'false').lower() == 'true' if enableSQLITE: print('Storing database file to ' + dbPath) + dbPath = os.path.join('db', 'pykms_database.db') + os.makedirs('db', exist_ok=True) command.append('-s') command.append(dbPath) @@ -40,8 +42,8 @@ if enableSQLITE: time.sleep(5) # The server may take a while to start if not os.path.isfile(dbPath): # Start a dummy activation to ensure the database file is created - subprocess.run(['/usr/bin/python3', 'pykms_Client.py', os.environ.get('IP'), os.environ.get('PORT'), '-m', 'Windows10', '-n', 'DummyClient', '-c', 'ae3a27d1-b73a-4734-9878-70c949815218']) - sqliteProcess = subprocess.Popen(['/usr/bin/python3', '/home/sqlite_web/sqlite_web.py', '-H', os.environ.get('IP'), '--read-only', '-x', dbPath, '-p', os.environ.get('SQLITE_PORT')]) + subprocess.run(['/usr/bin/python3', 'pykms_Client.py', listenIP, listenPort, '-m', 'Windows10', '-n', 'DummyClient', '-c', 'ae3a27d1-b73a-4734-9878-70c949815218']) + sqliteProcess = subprocess.Popen(['/usr/bin/python3', '/home/sqlite_web/sqlite_web.py', '-H', listenIP, '--read-only', '-x', dbPath, '-p', os.environ.get('SQLITE_PORT', 8080)]) try: pykmsProcess.wait()