This commit is contained in:
43
docker/ssh-server/app/init.py
Normal file
43
docker/ssh-server/app/init.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import os
|
||||
import subprocess
|
||||
import globals
|
||||
import sys
|
||||
|
||||
def main():
|
||||
|
||||
if globals.is_debugging():
|
||||
import debugpy
|
||||
debugpy.listen(("0.0.0.0", 5678))
|
||||
print("INFO: Waiting for debugger to attach...")
|
||||
debugpy.wait_for_client()
|
||||
print("INFO: Debugger attached")
|
||||
else:
|
||||
print("👉 starting setup")
|
||||
|
||||
|
||||
globals.load_config()
|
||||
setup_container()
|
||||
|
||||
if globals.is_debugging():
|
||||
debug_file = os.getenv("DEBUG_FILE", "")
|
||||
if debug_file and os.path.isfile(debug_file):
|
||||
print(f"🔍 Running debug file: {debug_file}")
|
||||
subprocess.run(["python3", debug_file], check=True, stdout=sys.stdout, stderr=sys.stderr)
|
||||
|
||||
return False
|
||||
elif debug_file:
|
||||
print(f"⚠️ DEBUG_FILE set but file not found: {debug_file}")
|
||||
return True
|
||||
|
||||
def setup_container():
|
||||
marker_file = "/var/run/container_initialized"
|
||||
if not os.path.exists(marker_file):
|
||||
print("INFO: First-time setup running...")
|
||||
# 👉 Your one-time setup logic here
|
||||
|
||||
# Create the marker file
|
||||
with open(marker_file, "w") as f:
|
||||
f.write("initialized\n")
|
||||
else:
|
||||
print("TRACE: Already initialized. Skipping setup.")
|
||||
|
||||
Reference in New Issue
Block a user