1 | import os |
---|
2 | import shutil |
---|
3 | import stat |
---|
4 | |
---|
5 | # Si está configurado OpenGnsys ... |
---|
6 | if os.getenv("OPENGNSYS"): |
---|
7 | print(os.getenv("MSG_MAKELINKS", ".")) |
---|
8 | |
---|
9 | # Shell BASH por defecto (para usar "runtest") |
---|
10 | try: |
---|
11 | os.symlink('/bin/bash', '/bin/sh') |
---|
12 | except FileExistsError: |
---|
13 | pass |
---|
14 | |
---|
15 | # Crear directorio de bloqueos |
---|
16 | os.makedirs('/var/lock', exist_ok=True) |
---|
17 | if not os.path.exists('/var/lock'): |
---|
18 | os.makedirs('/run/lock', exist_ok=True) |
---|
19 | |
---|
20 | # Crear ficheros temporales. |
---|
21 | oglogcommand = os.getenv("OGLOGCOMMAND") |
---|
22 | oglogsession = os.getenv("OGLOGSESSION") |
---|
23 | temp_files = [oglogcommand, f"{oglogcommand}.tmp", oglogsession, "/tmp/menu.tmp"] |
---|
24 | for temp_file in temp_files: |
---|
25 | with open(temp_file, 'a'): |
---|
26 | os.utime(temp_file, None) |
---|
27 | os.chmod(temp_file, 0o777) |
---|
28 | |
---|
29 | # Enlaces para Qt Embeded. |
---|
30 | qtdir = "/usr/local" |
---|
31 | os.makedirs(os.path.join(qtdir, 'etc'), exist_ok=True) |
---|
32 | os.makedirs(os.path.join(qtdir, 'lib'), exist_ok=True) |
---|
33 | os.makedirs(os.path.join(qtdir, 'plugins'), exist_ok=True) |
---|
34 | |
---|
35 | oglib = os.getenv("OGLIB") |
---|
36 | for i in os.listdir(os.path.join(oglib, 'qtlib')) + [os.path.join(oglib, 'fonts')]: |
---|
37 | src = os.path.join(oglib, 'qtlib', i) |
---|
38 | dst = os.path.join(qtdir, 'lib', i) |
---|
39 | if not os.path.exists(dst): |
---|
40 | try: |
---|
41 | os.symlink(src, dst) |
---|
42 | except FileExistsError: |
---|
43 | pass |
---|
44 | |
---|
45 | for i in os.listdir(os.path.join(oglib, 'qtplugins')): |
---|
46 | src = os.path.join(oglib, 'qtplugins', i) |
---|
47 | dst = os.path.join(qtdir, 'plugins', i) |
---|
48 | if not os.path.exists(dst): |
---|
49 | try: |
---|
50 | os.symlink(src, dst) |
---|
51 | except FileExistsError: |
---|
52 | pass |
---|
53 | |
---|
54 | ogetc = os.getenv("OGETC") |
---|
55 | for i in os.listdir(ogetc): |
---|
56 | if i.endswith('.qmap'): |
---|
57 | src = os.path.join(ogetc, i) |
---|
58 | dst = os.path.join(qtdir, 'etc', i) |
---|
59 | if not os.path.exists(dst): |
---|
60 | try: |
---|
61 | os.symlink(src, dst) |
---|
62 | except FileExistsError: |
---|
63 | pass |
---|
64 | |
---|
65 | # Autenticación con clave pública para SSH |
---|
66 | if os.path.isfile('/scripts/ssl/authorized_keys'): |
---|
67 | for file in os.listdir('/scripts/ssl'): |
---|
68 | shutil.copy(os.path.join('/scripts/ssl', file), '/root/.ssh') |
---|
69 | |
---|
70 | else: |
---|
71 | # FIXME Error: entorno de OpenGnsys no configurado. |
---|
72 | print("Error: OpenGnsys environment is not configured.") # FIXME: definir mensaje. |
---|
73 | exit(1) |
---|