Commit Graph

506 Commits (master)
 

Author SHA1 Message Date
OpenGnSys Support Team cf9577a40e fs: call wipefs partition before formatting partition
call wipefs before formatting partition, to remove any labels and stale data.

call wipefs if formatting fails, to leave partition in consistent state.

moreover, remove unnecessary exception handling on get_partition_device().
2025-02-14 15:48:53 +01:00
OpenGnSys Support Team 6503d0ffe7 live: call wipefs if partition or format fails
wipe disk if partition or format fails to leave the disk in consistent state.
2025-02-14 15:48:13 +01:00
Alejandro Sirgo Rica 0ca16bc46c live: remove unused variable in cache_delete()
Remove unused variable delted_images in the function cache_delete()
2025-02-14 13:15:27 +01:00
Alejandro Sirgo Rica bd190f8d44 live: send refresh payload in image restore
Send the refresh payload after a completed image restore operation.

The fields sent to ogServer are not enough to update the status of
the client and the OS installed in a partition does not appear in
the database.
2025-02-13 12:40:53 +01:00
Alejandro Sirgo Rica e0ba9cc98c uefi: log efibootmgr errors as warnings
Log as warning when efibootmgr fails to update the NVRAM.

Raise an exception when the command is not available or when
there are not enough permissions to execute. Provide contextual
information in the error message.
2025-02-13 09:06:38 +01:00
Alejandro Sirgo Rica ccdcb7bfc7 uefi: add missing f-string prefix in _find_bootentry() error
Add missing f-string prefix for proper string interpolation in
the error message of _find_bootentry()
2025-02-13 09:06:25 +01:00
Alejandro Sirgo Rica 72406a7d89 live: configure OS on first disk only
Call configure_os only for first disk, any other disks are only
supported to restore data images by now.

Call os_probe only for disk 1 in refresh.
2025-02-11 11:06:29 +01:00
Alejandro Sirgo Rica 0f519ecfeb grub: move disabled boot entries at the end of boot order
The GRUB entry is always set as the second boot option, assuming
PXE is first. This is not always true, as disabled entries before
PXE IPv4 can make it the first valid but not the first defined
entry in the boot order.

Move every disabled boot entry at the end of boot order.
2025-02-05 09:42:38 +01:00
Alejandro Sirgo Rica c260534534 live: remove unneeded string formatting in image_create
Replace f-string wf'{image_path}' with the variable image_path.
2025-02-03 11:27:18 +01:00
Alejandro Sirgo Rica f67f3c598a rest: register image/update as a valid request
Accept both image/create and image/update requests from ogServer.
2025-01-31 14:31:17 +01:00
OpenGnSys Support Team 574822907d grub: skip OS guess if partition cannot be mounted
otherwise, _get_os_entries() fails when it finds a swap partition:

  (2025-01-23 17:44:30) ogClient: [ERROR] - Error generating /mnt/nvme0n1p4/EFI/grub/Boot/grub.cfg: Unable to mount /dev/nvme0n1p3 into /mnt/nvme0n1p3
2025-01-24 15:15:57 +01:00
Alejandro Sirgo Rica 30e0e1dca3 src: run session check thread if the event socket is available
Disable session check thread if the event socket is not in an
initialized state.
2025-01-24 15:15:57 +01:00
OpenGnSys Support Team 59d642f6b5 ogclient: rename event handler
no functional changes intended.
2025-01-15 11:41:41 +01:00
Alejandro Sirgo Rica 24568356bc winreg: move disk id functions into disk.py
Move uuid_to_bytes, get_disk_id_bytes and get_part_id_bytes from
winreg.py to the more fitting location disk.py
2025-01-07 15:56:55 +01:00
Alejandro Sirgo Rica 40e4545bb7 live: fix image restore backtrace
import the missing function is_hibernation_enabled() into
ogOperations.py to prevent a backtrace in each restore operation.
2025-01-07 15:02:10 +01:00
Alejandro Sirgo Rica d29b601f17 uefi: remove dependency with probe.py
Reduce interdependency between imports by checking the correct OS for
copy_windows_efi_bootloader() from the code invoking the operation.

Break circular dependency where:
probe.py imports from winreg.py
winreg.py imports from uefi.py
uefi.py imports from probe.py
2025-01-07 15:02:04 +01:00
Alejandro Sirgo Rica 476d82e6a9 ogclient-systray: add new systray program for ogclient
Add make.bat for an easier building process in Windows. This
script generates ogclient.exe and ogclient-systray binaries in
a ./dist directory.

Add ogclient-systray program. This python program polls the
existence of the ogclient process and shows a systray if the
ogclient service is active.

Update utils/create_version_file.py to generate information for
the systray binary.
2024-12-16 16:01:06 +01:00
Alejandro Sirgo Rica e91f6c5e2c windows: remove dead systray code
Remove dead systray code and unused imports in ogclient for
Windows.
2024-12-16 15:08:22 +01:00
Alejandro Sirgo Rica 4465c6a25a ogclient: remove session event cmd commands
Remove commands to send session events as the session report
logic is now implemented in the ogOperations.py file of each
platform.
2024-12-12 13:14:48 +01:00
Alejandro Sirgo Rica 203f3e5533 live: add additional error checks for shell run
Add checks for invalid arguments and permission errors.
2024-12-12 11:20:23 +01:00
Alejandro Sirgo Rica bf15491435 hw_inventory: fix json parsing
Add support for both lshw -json return formats.
The json structure may follow one of the following.

output:list flag enabled:
[{content}]

output:list flag disabled:
{content}

The output:list flag was defined in the commit 2b1c730 of
https://ezix.org/src/pkg/lshw
2024-12-11 15:17:02 +01:00
Alejandro Sirgo Rica 855768e144 src: refactor windows hive code
Remove usage of hivexget as a subprocess and use Python hivex to
inspect the Windows Registry.

Use registry path constants defined in src.utils.winreg

Remove windows_is64bit() funcion as the code to identify the
architecture relies on a broken Registry query. Fixing the query
proved to be a challenge and the only implication is the removal
of the string "64 bits" at the end of the listed Windows OS
installed in each partition.

Use utility function in src.utils.winreg to make the software
inventory code more compact.

Rewrite onliner in _fill_package_set function and parse the
registry with a for loop.
2024-12-11 15:16:34 +01:00
Alejandro Sirgo Rica aa570e66e6 log: use INFO as default logging mode for Windows 2024-11-28 16:58:41 +01:00
Alejandro Sirgo Rica ffaf2aac05 install: add script to generate the windows metadata information file
Add create_version_file.py, running this script creates a file
version_info.txt with the data required for the Windows ogClient
binary metadata.
2024-11-28 16:58:41 +01:00
OpenGnSys Support Team 62b52ff364 src: update license header 2024-11-28 16:45:56 +01:00
Alejandro Sirgo Rica e4be5c34eb src: add support for direct command execution
Update live shell run mode for the new REST API interface.
Evaluate the "inline" field to diferentiate between execution of
script in /opt/opengnsys/shell/ and a cmd execution.

Remove usage of echo argument of the API REST.

Update Windows and Linux mode for direct command execution.
Set OutputEncoding environment variable to 'utf-8' in Windows to
unify the encoding of stdout for the invoked programs.

Decode stdout to utf-8-sig to remove potential BOM.

While at this, remove strange legacy ;|\n\r terminator.
2024-11-27 13:53:19 +01:00
Alejandro Sirgo Rica a36c4daa23 src: add user session detection implementation
Detect user login and logout for Linux and Windows.

Report an active interactive session through the /refresh response
so a new ogserver instance can update the session status.

Poll the session change in 5 second intervals in a thread. Use the
same event socket previously used by the old session detection
mechanism to notify a session change.

Use the method check_interactive_session_change in each
ogOperations.py to report the session status.
Return values:
	None: no session changes are found
	True: login
	False: logout

Windows
Verify if psutil.users() has any value.

Linux
Verify all the psutil.users() asociated to a terminal.
2024-11-26 13:02:45 +01:00
Alejandro Sirgo Rica a1bd0c36f3 linux: remove leftover prove() method 2024-11-26 13:02:45 +01:00
Alejandro Sirgo Rica c8674a4e93 windows: bind the systray process lifetime to ogClient
Add daemon=True to the systray process in order to make it close
when the ogClient process closes.
2024-11-26 13:02:45 +01:00
Alejandro Sirgo Rica 179d17cae8 windows: make the systray reference local to OgWindowsOperations 2024-11-26 13:02:45 +01:00
Alejandro Sirgo Rica bc7fe848ac windows: use a better systray default icon
Draw a blue circle as default icon in the systray. Use the same
blue color as the one shown in ogCP for an ogClient Windows instance.
2024-11-26 13:02:45 +01:00
Alejandro Sirgo Rica 525958ae85 src: update functions for every ogClient mode
Add missing ogClient mode functions and show an error in every
unimplemented function.
2024-11-26 13:02:17 +01:00
Alejandro Sirgo Rica d7658f03ab utils: disable fcntl in ogClient for Windows
Add conditional import for fcntl as it is only supported for
Linux and causes ogClient for Windows fail to start.
2024-11-15 10:47:05 +01:00
OpenGnSys Support Team 90a9ba9543 live: bogus error in logs when connecting to ogserver
This error is bogus:

 (2024-11-14 09:05:37) ogClient: [ERROR] - Partition query error for /dev/sdb: No medium found

skip if device cannot be opened instead.
2024-11-14 18:12:56 +01:00
Alejandro Sirgo Rica f5f8771b6f grub: fix failed grub configuration when a device is not found
Fix "No medium found" error aborting the grub configuration
process. Just log it and continue.
2024-11-14 18:12:56 +01:00
OpenGnSys Support Team 3b5152cdc1 tiptorrent: use absolute path to tiptorrent-client
instead of using PATH to find it
2024-11-07 19:22:47 +01:00
Alejandro Sirgo Rica a440b9da47 live: fix error report in partition and format
Fix error codepath and properly mark the operation as failed.
2024-11-05 11:20:59 +01:00
Alejandro Sirgo Rica 64f1f5403e disk: use different log message in get_disk_data and get_partition_data
Use a more specific message to differentiate the source of the error.

Add the target device to the log message.
2024-10-25 09:47:49 +02:00
OpenGnSys Support Team 7874323d46 live: use reboot --force --force to make a hard reboot in new live
this is a workaround for the new live system to make a hardware reboot
that allows UEFI to pick up, otherwise it performs a kernel reboot instead.
2024-10-24 17:46:37 +02:00
Alejandro Sirgo Rica 07b4bc1fcd postinstall: remove call to ogFixBootSector script
Remove call to ogFixBootSector function as it is possibly only
required by Windows XP and FAT filesystem.
2024-10-24 10:52:33 +02:00
Alejandro Sirgo Rica 569caa733f cache: add code to cache the oglive boot files
Add update_live_cache() implementing the legacy script
updateBootCache()

Copy the ogvmlinuz and oginitrd.img files into cache after
a partition and format command with an available cache partition.
2024-10-24 10:52:33 +02:00
OpenGnSys Support Team fc21cd988f live: always enable wol when launching ogclient
no need to wait for reboot/poweroff to enable wake-on-lan.
2024-10-24 10:46:44 +02:00
Alejandro Sirgo Rica fb707cef0b grub: move get_grub_boot_params() into grub.py
Move get_grub_boot_params() into the file related to all the grub
configuration.
2024-10-22 16:47:44 +02:00
Alejandro Sirgo Rica 373c1b2a72 grub: replace legacy grub install scripts
Translate old legacy grub scripts into grub.py
Implement ogGrubInstallMbr as install_main_grub() and
ogGrubInstallPartition as install_linux_grub().

Add grub configuration file generator through the classes
GrubConfig and MenuEntry.

Ensure EFI tree structure compatibility with legacy code.
The structure of the created folders in the ESP is non-standard,
efi binaries are usually located in the folder below the EFI/
directory.

Structure used by ogClient:

EFI/
├── grub/
│   └── Boot/
│       ├── BOOTX64.CSV
│       ├── grub.cfg
│       ├── mmx64.efi
│       ├── shimx64.efi
│       ├── BOOTX64.EFI
│       ├── grubx64.efi
│       └── ogloader.efi
...

The function _mangle_efi_folder handles the folder structure after
grub-install to comply with the location expected by ogLive.

install_linux_grub() installs a grub local to each Linux install
to enable chainloading, each grub is located in EFI/Part-xx-yy/ in
UEFI. The local linux BIOS grub in legacy scripts is unreliable,
grub-install reports a failure during the install process.

install_main_grub() installs a global grub in EFI/grub/ to show a
grub menu when the pxe boot fails. The global grub contains entries
to every installed os. No global grub is installed for BIOS
systems, a Boot partition would be required to store the grub
configuration.
2024-10-22 16:47:38 +02:00
Alejandro Sirgo Rica 2fcdf89606 disk: use cxt.label.name to dtect disk type in get_efi_partition
Use cxt.label.name instead of cxt.label to identify if the disk is
GPT or MBR. This way is more used in other parts of the codebase.
2024-10-21 16:56:05 +02:00
Alejandro Sirgo Rica b3659a30fc bios: fix use of undefined initrd_dir variable in get_vmlinuz_path
Use the intended linuz_dir instead of initrd_dir in the function
get_vmlinuz_path.
2024-10-21 12:04:23 +02:00
Alejandro Sirgo Rica 7be953dbe7 uefi: fix error message when no EFI loader
Fix log error message when _find_efi_loader does not find any
EFI loader in the ESP.
2024-10-11 12:06:37 +02:00
Alejandro Sirgo Rica 039bee2a05 bios.py: fix typo in GRUB_CMDLINE_LINUX_DEFAULT string
Check against GRUB_CMDLINE_LINUX_DEFAULT instead of
GRUB_CMDLINE_LINUE_DEFAULT.
2024-10-09 16:25:14 +02:00
Alejandro Sirgo Rica e8ddbbd075 src: isolate libfdisk operations to enable mount operations
python-libfdisk does not close file descriptor until the cxt
object goes out of scope.

Define get_partition_data and get_disk_data functions to isolate
the python-libfdisk logic and return the data as an object.

Improve error handling of libfdisk operaions in refresh.
2024-10-08 10:07:45 +02:00
Alejandro Sirgo Rica 97c836e0e4 live: improve part not found log in image_create
Report the partition number of the missing partition.
2024-10-08 10:07:45 +02:00