parent
655dfbb049
commit
bcf376ab82
|
@ -291,28 +291,7 @@ class OpengnsysGitLibrary:
|
|||
f.write("\n".join(self.default_ignore_list))
|
||||
f.write("\n")
|
||||
|
||||
def _parse_kernel_cmdline(self):
|
||||
"""Parse the kernel arguments to obtain configuration parameters in Oglive
|
||||
|
||||
OpenGnsys passes data in the kernel arguments, for example:
|
||||
[...] group=Aula_virtual ogrepo=192.168.2.1 oglive=192.168.2.1 [...]
|
||||
|
||||
Returns:
|
||||
dict: Dict of configuration parameters and their values.
|
||||
"""
|
||||
params = {}
|
||||
self.logger.debug("Parsing kernel parameters")
|
||||
|
||||
with open("/proc/cmdline", encoding='utf-8') as cmdline:
|
||||
line = cmdline.readline()
|
||||
parts = line.split()
|
||||
for part in parts:
|
||||
if "=" in part:
|
||||
key, value = part.split("=")
|
||||
params[key] = value
|
||||
|
||||
self.logger.debug("%i parameters found", len(params))
|
||||
return params
|
||||
|
||||
|
||||
|
||||
|
@ -1544,6 +1523,9 @@ if __name__ == '__main__':
|
|||
# esto arregla las tildes y las eñes
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
kernel_args = parse_kernel_cmdline()
|
||||
|
||||
|
||||
opengnsys_log_dir = "/opt/opengnsys/log"
|
||||
|
||||
logger = logging.getLogger(__package__)
|
||||
|
@ -1555,7 +1537,13 @@ if __name__ == '__main__':
|
|||
if not os.path.exists(opengnsys_log_dir):
|
||||
os.mkdir(opengnsys_log_dir)
|
||||
|
||||
logFilePath = f"{opengnsys_log_dir}/gitlib.log"
|
||||
ip_address = "unknown"
|
||||
if "ip" in kernel_args:
|
||||
ip_address = kernel_args["ip"].split(":")[0]
|
||||
|
||||
|
||||
logFilePath = f"{opengnsys_log_dir}/{ip_address}.gitlib.log"
|
||||
|
||||
fileLog = logging.FileHandler(logFilePath)
|
||||
fileLog.setLevel(logging.DEBUG)
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
|
||||
def parse_kernel_cmdline():
|
||||
"""Parse the kernel arguments to obtain configuration parameters in Oglive
|
||||
|
||||
OpenGnsys passes data in the kernel arguments, for example:
|
||||
[...] group=Aula_virtual ogrepo=192.168.2.1 oglive=192.168.2.1 [...]
|
||||
|
||||
Returns:
|
||||
dict: Dict of configuration parameters and their values.
|
||||
"""
|
||||
params = {}
|
||||
|
||||
with open("/proc/cmdline", encoding='utf-8') as cmdline:
|
||||
line = cmdline.readline()
|
||||
parts = line.split()
|
||||
for part in parts:
|
||||
if "=" in part:
|
||||
key, value = part.split("=")
|
||||
params[key] = value
|
||||
|
||||
return params
|
Loading…
Reference in New Issue