source: client/shared/etc/preinit/otherservices.py @ f160ff2

test-python-scriptsticket-693
Last change on this file since f160ff2 was 5b1449d, checked in by Antonio Emmanuel Guerrero Silva <aguerrero@…>, 8 months ago

refs #700 shared files convert to Python3

  • Property mode set to 100644
File size: 1.5 KB
Line 
1#!/usr/bin/env python3
2
3import os
4import subprocess
5
6"""
7@file    otherservices.py
8@brief   Script de inicio para cargar otros servicios complementarios.
9"""
10
11# Lanzar servicios complementarios del cliente.
12print(os.getenv('MSG_OTHERSERVICES', '.'))
13
14# Iniciar rsyslog, si es necesario.
15if not os.path.exists('/dev/log'):
16    subprocess.run(['service', 'rsyslog', 'start'])
17
18# Adpatar la clave de "root" para acceso SSH.
19with open('/scripts/ogfunctions', 'r') as file:
20    for line in file:
21        if 'OPTIONS=' in line:
22            pass_option = line.split('pass=')[1].split()[0]
23            break
24    else:
25        pass_option = 'og'
26
27passwd = pass_option or 'og'
28subprocess.run(['passwd', 'root'], input=f'{passwd}\n{passwd}\n', text=True)
29
30# Cargar el entorno OpenGnsys en conexión SSH.
31subprocess.run(['cp', '-a', f'{os.getenv("OPENGNSYS")}/etc/preinit/loadenviron.sh', '/etc/profile.d/'])
32
33# Arrancar SSH.
34subprocess.run(['/etc/init.d/ssh', 'start'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
35
36# Desactivado apagado de monitor.
37# subprocess.run(['setterm', '-blank', '0', '-powersave', 'off', '-powerdown', '0'], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
38
39# Activado WOL en la interfaz usada en arranque PXE.
40subprocess.run(['ethtool', '-s', os.getenv('DEVICE'), 'wol', 'g'], stderr=subprocess.DEVNULL)
41
42# TODO Localizar correctamente el script de arranque.
43if os.path.isfile('/opt/opengnsys/scripts/runhttplog.sh'):
44    subprocess.run(['/opt/opengnsys/scripts/runhttplog.sh'], stderr=subprocess.DEVNULL)
Note: See TracBrowser for help on using the repository browser.