postinstall: linux does not allow more than 64 bytes long hostnames

As per:

  $ getconf HOST_NAME_MAX
  64

truncate it to the maximum.
master
OpenGnSys Support Team 2024-08-06 17:26:25 +02:00
parent e9ee1b1c9f
commit fd64b84bcc
1 changed files with 4 additions and 0 deletions

View File

@ -69,6 +69,10 @@ def set_windows_hostname(disk, partition, name):
def set_linux_hostname(disk, partition, name):
logging.info(f'Setting Linux hostname to {name}')
if len(name) > 64:
logging.warning(f'Linux does not permit hostnames that exceed 64 characters. Truncating {name}')
name = name[0:64]
device = get_partition_device(disk, partition)
mountpoint = device.replace('dev', 'mnt')