#!/usr/bin/env python3 import os import subprocess """ @file otherservices.py @brief Script de inicio para cargar otros servicios complementarios. """ # Lanzar servicios complementarios del cliente. print(os.getenv('MSG_OTHERSERVICES', '.')) # Iniciar rsyslog, si es necesario. if not os.path.exists('/dev/log'): subprocess.run(['service', 'rsyslog', 'start']) # Adpatar la clave de "root" para acceso SSH. with open('/scripts/ogfunctions', 'r') as file: for line in file: if 'OPTIONS=' in line: pass_option = line.split('pass=')[1].split()[0] break else: pass_option = 'og' passwd = pass_option or 'og' subprocess.run(['passwd', 'root'], input=f'{passwd}\n{passwd}\n', text=True) # Cargar el entorno OpenGnsys en conexión SSH. subprocess.run(['cp', '-a', f'{os.getenv("OPENGNSYS")}/etc/preinit/loadenviron.py', '/etc/profile.d/']) # Arrancar SSH. subprocess.run(['/etc/init.d/ssh', 'start'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # Desactivado apagado de monitor. # subprocess.run(['setterm', '-blank', '0', '-powersave', 'off', '-powerdown', '0'], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # Activado WOL en la interfaz usada en arranque PXE. subprocess.run(['ethtool', '-s', os.getenv('DEVICE'), 'wol', 'g'], stderr=subprocess.DEVNULL) # TODO Localizar correctamente el script de arranque. if os.path.isfile('/opt/opengnsys/scripts/runhttplog.sh'): subprocess.run(['/opt/opengnsys/scripts/runhttplog.sh'], stderr=subprocess.DEVNULL)