summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/postinstall.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/utils/postinstall.py b/src/utils/postinstall.py
index 7fef437..374a1cd 100644
--- a/src/utils/postinstall.py
+++ b/src/utils/postinstall.py
@@ -66,6 +66,25 @@ def set_windows_hostname(disk, partition, name):
umount(mountpoint)
+def set_linux_hostname(disk, partition, name):
+ logging.info(f'Configuring hostname')
+
+ device = get_partition_device(disk, partition)
+ mountpoint = device.replace('dev', 'mnt')
+
+ if not mount_mkdir(device, mountpoint):
+ raise OgError(f'Unable to mount {device} into {mountpoint}')
+
+ try:
+ hostname_path = f'{mountpoint}/etc/hostname'
+ with open(hostname_path, 'w') as f:
+ f.write(name)
+ except OSError as e:
+ raise OgError(f'Unable to configure Linux hostname: {e}') from e
+ finally:
+ umount(mountpoint)
+
+
def configure_os_custom(disk, partition):
if not shutil.which('configureOsCustom'):
raise OgError('configureOsCustom not found')
@@ -149,6 +168,9 @@ def install_grub(disk, partition):
def configure_os_linux(disk, partition):
+ hostname = gethostname()
+ set_linux_hostname(disk, partition, hostname)
+
configure_fstab(disk, partition)
if is_uefi_supported():