Merge pull request #224 from Gormogon/master
GDM Auto-Login Bug Fix and PEP Cleanup
This commit is contained in:
commit
8b9688a590
@ -40,10 +40,12 @@ def get_uuid():
|
|||||||
print("Root mount point: \"{!s}\"".format(root_mount_point))
|
print("Root mount point: \"{!s}\"".format(root_mount_point))
|
||||||
partitions = libcalamares.globalstorage.value("partitions")
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
print("Partitions: \"{!s}\"".format(partitions))
|
print("Partitions: \"{!s}\"".format(partitions))
|
||||||
|
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
if partition["mountPoint"] == "/":
|
if partition["mountPoint"] == "/":
|
||||||
print("Root partition uuid: \"{!s}\"".format(partition["uuid"]))
|
print("Root partition uuid: \"{!s}\"".format(partition["uuid"]))
|
||||||
return partition["uuid"]
|
return partition["uuid"]
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +91,7 @@ def create_systemd_boot_conf(uuid, conf_path, kernel_line):
|
|||||||
img = libcalamares.job.configuration["img"]
|
img = libcalamares.job.configuration["img"]
|
||||||
partitions = libcalamares.globalstorage.value("partitions")
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
swap = ""
|
swap = ""
|
||||||
|
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
if partition["fs"] == "linuxswap":
|
if partition["fs"] == "linuxswap":
|
||||||
swap = partition["uuid"]
|
swap = partition["uuid"]
|
||||||
@ -97,7 +100,7 @@ def create_systemd_boot_conf(uuid, conf_path, kernel_line):
|
|||||||
'## This is just an example config file.\n',
|
'## This is just an example config file.\n',
|
||||||
'## Please edit the paths and kernel parameters according to your system.\n',
|
'## Please edit the paths and kernel parameters according to your system.\n',
|
||||||
'\n',
|
'\n',
|
||||||
"title {!s}{!s}\n".format(distribution,kernel_line),
|
"title {!s}{!s}\n".format(distribution, kernel_line),
|
||||||
"linux {!s}\n".format(kernel),
|
"linux {!s}\n".format(kernel),
|
||||||
"initrd {!s}\n".format(img),
|
"initrd {!s}\n".format(img),
|
||||||
"options root=UUID={!s} quiet resume=UUID={!s} rw\n".format(uuid, swap),
|
"options root=UUID={!s} quiet resume=UUID={!s} rw\n".format(uuid, swap),
|
||||||
@ -140,14 +143,11 @@ def install_systemd_boot(efi_directory):
|
|||||||
distribution = get_bootloader_entry_name()
|
distribution = get_bootloader_entry_name()
|
||||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
file_name_sanitizer = str.maketrans(" /", "_-")
|
||||||
distribution_translated = distribution.translate(file_name_sanitizer)
|
distribution_translated = distribution.translate(file_name_sanitizer)
|
||||||
conf_path = os.path.join(
|
conf_path = os.path.join(install_efi_directory, "loader", "entries",
|
||||||
install_efi_directory, "loader", "entries",
|
"{!s}.conf".format(distribution_translated))
|
||||||
"{!s}.conf".format(distribution_translated))
|
fallback_path = os.path.join(install_efi_directory, "loader", "entries",
|
||||||
fallback_path = os.path.join(
|
"{!s}-fallback.conf".format(distribution_translated))
|
||||||
install_efi_directory, "loader", "entries",
|
loader_path = os.path.join(install_efi_directory, "loader", "loader.conf")
|
||||||
"{!s}-fallback.conf".format(distribution_translated))
|
|
||||||
loader_path = os.path.join(
|
|
||||||
install_efi_directory, "loader", "loader.conf")
|
|
||||||
subprocess.call(["bootctl", "--path={!s}".format(install_efi_directory), "install"])
|
subprocess.call(["bootctl", "--path={!s}".format(install_efi_directory), "install"])
|
||||||
kernel_line = get_kernel_line("default")
|
kernel_line = get_kernel_line("default")
|
||||||
print("Configure: \"{!s}\"".format(kernel_line))
|
print("Configure: \"{!s}\"".format(kernel_line))
|
||||||
@ -168,6 +168,7 @@ def install_grub(efi_directory, fw_type):
|
|||||||
print("Bootloader: grub (efi)")
|
print("Bootloader: grub (efi)")
|
||||||
efi_directory_firmware = efi_directory + "/EFI"
|
efi_directory_firmware = efi_directory + "/EFI"
|
||||||
check_chroot_call(["mkdir", "-p", "{!s}".format(efi_directory)])
|
check_chroot_call(["mkdir", "-p", "{!s}".format(efi_directory)])
|
||||||
|
|
||||||
if "efiBootloaderId" in libcalamares.job.configuration:
|
if "efiBootloaderId" in libcalamares.job.configuration:
|
||||||
efi_bootloader_id = libcalamares.job.configuration["efiBootloaderId"]
|
efi_bootloader_id = libcalamares.job.configuration["efiBootloaderId"]
|
||||||
else:
|
else:
|
||||||
@ -175,22 +176,19 @@ def install_grub(efi_directory, fw_type):
|
|||||||
distribution = branding["bootloaderEntryName"]
|
distribution = branding["bootloaderEntryName"]
|
||||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
file_name_sanitizer = str.maketrans(" /", "_-")
|
||||||
efi_bootloader_id = distribution.translate(file_name_sanitizer)
|
efi_bootloader_id = distribution.translate(file_name_sanitizer)
|
||||||
check_chroot_call(
|
check_chroot_call([libcalamares.job.configuration["grubInstall"], "--target=x86_64-efi",
|
||||||
[libcalamares.job.configuration["grubInstall"], "--target=x86_64-efi",
|
"--efi-directory={!s}".format(efi_directory),
|
||||||
"--efi-directory={!s}".format(efi_directory),
|
"--bootloader-id={!s}".format(efi_bootloader_id),
|
||||||
"--bootloader-id={!s}".format(efi_bootloader_id),
|
"--force"])
|
||||||
"--force"])
|
|
||||||
# Workaround for some UEFI firmwares
|
# Workaround for some UEFI firmwares
|
||||||
check_chroot_call(["mkdir", "-p", "{!s}/boot".format(efi_directory_firmware)])
|
check_chroot_call(["mkdir", "-p", "{!s}/boot".format(efi_directory_firmware)])
|
||||||
check_chroot_call(["cp", "{!s}/{!s}/grubx64.efi".format(efi_directory_firmware,
|
check_chroot_call(["cp", "{!s}/{!s}/grubx64.efi".format(efi_directory_firmware, efi_bootloader_id),
|
||||||
efi_bootloader_id),
|
|
||||||
"{!s}/boot/bootx64.efi".format(efi_directory_firmware)])
|
"{!s}/boot/bootx64.efi".format(efi_directory_firmware)])
|
||||||
else:
|
else:
|
||||||
print("Bootloader: grub (bios)")
|
print("Bootloader: grub (bios)")
|
||||||
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
||||||
check_chroot_call(
|
check_chroot_call([libcalamares.job.configuration["grubInstall"], "--target=i386-pc",
|
||||||
[libcalamares.job.configuration["grubInstall"], "--target=i386-pc",
|
"--recheck", "--force", boot_loader["installPath"]])
|
||||||
"--recheck", "--force", boot_loader["installPath"]])
|
|
||||||
|
|
||||||
check_chroot_call([libcalamares.job.configuration["grubMkconfig"], "-o",
|
check_chroot_call([libcalamares.job.configuration["grubMkconfig"], "-o",
|
||||||
libcalamares.job.configuration["grubCfg"]])
|
libcalamares.job.configuration["grubCfg"]])
|
||||||
@ -205,26 +203,30 @@ def prepare_bootloader(fw_type):
|
|||||||
"""
|
"""
|
||||||
efi_boot_loader = libcalamares.job.configuration["efiBootLoader"]
|
efi_boot_loader = libcalamares.job.configuration["efiBootLoader"]
|
||||||
efi_directory = libcalamares.globalstorage.value("efiSystemPartition")
|
efi_directory = libcalamares.globalstorage.value("efiSystemPartition")
|
||||||
|
|
||||||
if fw_type == "efi":
|
if fw_type == "efi":
|
||||||
partitions = libcalamares.globalstorage.value("partitions")
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
boot_p = ""
|
boot_p = ""
|
||||||
device = ""
|
device = ""
|
||||||
|
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
if partition["mountPoint"] == efi_directory:
|
if partition["mountPoint"] == efi_directory:
|
||||||
boot_device = partition["device"]
|
boot_device = partition["device"]
|
||||||
boot_p = boot_device[-1:]
|
boot_p = boot_device[-1:]
|
||||||
device = boot_device[:-1]
|
device = boot_device[:-1]
|
||||||
|
|
||||||
if (not boot_p or not device):
|
if (not boot_p or not device):
|
||||||
return ("EFI directory \"{!s}\" not found!",
|
return ("EFI directory \"{!s}\" not found!",
|
||||||
"Boot partition: \"{!s}\"",
|
"Boot partition: \"{!s}\"",
|
||||||
"Boot device: \"{!s}\"".format(efi_directory,boot_p,device))
|
"Boot device: \"{!s}\"".format(efi_directory, boot_p, device))
|
||||||
else:
|
else:
|
||||||
print("EFI directory: \"{!s}\"".format(efi_directory))
|
print("EFI directory: \"{!s}\"".format(efi_directory))
|
||||||
print("Boot partition: \"{!s}\"".format(boot_p))
|
print("Boot partition: \"{!s}\"".format(boot_p))
|
||||||
print("Boot device: \"{!s}\"".format(device))
|
print("Boot device: \"{!s}\"".format(device))
|
||||||
print("Set 'EF00' flag")
|
print("Set 'EF00' flag")
|
||||||
subprocess.call(["sgdisk", "--typecode={!s}:EF00".format(boot_p), "{!s}".format(device)])
|
subprocess.call(["sgdisk", "--typecode={!s}:EF00".format(boot_p), "{!s}".format(device)])
|
||||||
if (efi_boot_loader == "systemd-boot" and fw_type == "efi"):
|
|
||||||
|
if efi_boot_loader == "systemd-boot" and fw_type == "efi":
|
||||||
install_systemd_boot(efi_directory)
|
install_systemd_boot(efi_directory)
|
||||||
else:
|
else:
|
||||||
install_grub(efi_directory, fw_type)
|
install_grub(efi_directory, fw_type)
|
||||||
@ -237,4 +239,5 @@ def run():
|
|||||||
"""
|
"""
|
||||||
fw_type = libcalamares.globalstorage.value("firmwareType")
|
fw_type = libcalamares.globalstorage.value("firmwareType")
|
||||||
prepare_bootloader(fw_type)
|
prepare_bootloader(fw_type)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
@ -55,10 +55,11 @@ def find_desktop_environment(root_mount_point):
|
|||||||
"""
|
"""
|
||||||
for desktop_environment in desktop_environments:
|
for desktop_environment in desktop_environments:
|
||||||
if os.path.exists(
|
if os.path.exists(
|
||||||
"{!s}{!s}".format(root_mount_point, desktop_environment.executable)) \
|
"{!s}{!s}".format(root_mount_point, desktop_environment.executable)) \
|
||||||
and os.path.exists("{!s}/usr/share/xsessions/{!s}.desktop".format(root_mount_point,
|
and os.path.exists("{!s}/usr/share/xsessions/{!s}.desktop".format(root_mount_point,
|
||||||
desktop_environment.desktop_file)):
|
desktop_environment.desktop_file)):
|
||||||
return desktop_environment
|
return desktop_environment
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@ -74,8 +75,7 @@ def have_dm(dm_name, root_mount_point):
|
|||||||
"{!s}/usr/sbin/{!s}".format(root_mount_point, dm_name))
|
"{!s}/usr/sbin/{!s}".format(root_mount_point, dm_name))
|
||||||
|
|
||||||
|
|
||||||
def set_autologin(username, displaymanagers, default_desktop_environment,
|
def set_autologin(username, displaymanagers, default_desktop_environment, root_mount_point):
|
||||||
root_mount_point):
|
|
||||||
""" Enables automatic login for the installed desktop managers.
|
""" Enables automatic login for the installed desktop managers.
|
||||||
|
|
||||||
:param username:
|
:param username:
|
||||||
@ -83,17 +83,19 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
:param default_desktop_environment:
|
:param default_desktop_environment:
|
||||||
:param root_mount_point:
|
:param root_mount_point:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
do_autologin = True
|
do_autologin = True
|
||||||
|
|
||||||
if username is None:
|
if username is None:
|
||||||
do_autologin = False
|
do_autologin = False
|
||||||
|
|
||||||
if "mdm" in displaymanagers:
|
if "mdm" in displaymanagers:
|
||||||
# Systems with MDM as Desktop Manager
|
# Systems with MDM as Desktop Manager
|
||||||
mdm_conf_path = os.path.join(root_mount_point, "etc/mdm/custom.conf")
|
mdm_conf_path = os.path.join(root_mount_point, "etc/mdm/custom.conf")
|
||||||
|
|
||||||
if os.path.exists(mdm_conf_path):
|
if os.path.exists(mdm_conf_path):
|
||||||
with open(mdm_conf_path, 'r') as mdm_conf:
|
with open(mdm_conf_path, 'r') as mdm_conf:
|
||||||
text = mdm_conf.readlines()
|
text = mdm_conf.readlines()
|
||||||
|
|
||||||
with open(mdm_conf_path, 'w') as mdm_conf:
|
with open(mdm_conf_path, 'w') as mdm_conf:
|
||||||
for line in text:
|
for line in text:
|
||||||
if '[daemon]' in line:
|
if '[daemon]' in line:
|
||||||
@ -101,12 +103,13 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
line = "[daemon]\nAutomaticLogin={!s}\nAutomaticLoginEnable=True\n".format(username)
|
line = "[daemon]\nAutomaticLogin={!s}\nAutomaticLoginEnable=True\n".format(username)
|
||||||
else:
|
else:
|
||||||
line = "[daemon]\nAutomaticLoginEnable=False\n"
|
line = "[daemon]\nAutomaticLoginEnable=False\n"
|
||||||
|
|
||||||
mdm_conf.write(line)
|
mdm_conf.write(line)
|
||||||
else:
|
else:
|
||||||
with open(mdm_conf_path, 'w') as mdm_conf:
|
with open(mdm_conf_path, 'w') as mdm_conf:
|
||||||
mdm_conf.write(
|
mdm_conf.write('# Calamares - Configure automatic login for user\n')
|
||||||
'# Calamares - Configure automatic login for user\n')
|
|
||||||
mdm_conf.write('[daemon]\n')
|
mdm_conf.write('[daemon]\n')
|
||||||
|
|
||||||
if do_autologin:
|
if do_autologin:
|
||||||
mdm_conf.write("AutomaticLogin={!s}\n".format(username))
|
mdm_conf.write("AutomaticLogin={!s}\n".format(username))
|
||||||
mdm_conf.write('AutomaticLoginEnable=True\n')
|
mdm_conf.write('AutomaticLoginEnable=True\n')
|
||||||
@ -116,9 +119,11 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
if "gdm" in displaymanagers:
|
if "gdm" in displaymanagers:
|
||||||
# Systems with GDM as Desktop Manager
|
# Systems with GDM as Desktop Manager
|
||||||
gdm_conf_path = os.path.join(root_mount_point, "etc/gdm/custom.conf")
|
gdm_conf_path = os.path.join(root_mount_point, "etc/gdm/custom.conf")
|
||||||
|
|
||||||
if os.path.exists(gdm_conf_path):
|
if os.path.exists(gdm_conf_path):
|
||||||
with open(gdm_conf_path, 'r') as gdm_conf:
|
with open(gdm_conf_path, 'r') as gdm_conf:
|
||||||
text = gdm_conf.readlines()
|
text = gdm_conf.readlines()
|
||||||
|
|
||||||
with open(gdm_conf_path, 'w') as gdm_conf:
|
with open(gdm_conf_path, 'w') as gdm_conf:
|
||||||
for line in text:
|
for line in text:
|
||||||
if '[daemon]' in line:
|
if '[daemon]' in line:
|
||||||
@ -126,37 +131,38 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
line = "[daemon]\nAutomaticLogin={!s}\nAutomaticLoginEnable=True\n".format(username)
|
line = "[daemon]\nAutomaticLogin={!s}\nAutomaticLoginEnable=True\n".format(username)
|
||||||
else:
|
else:
|
||||||
line = "[daemon]\nAutomaticLoginEnable=False\n"
|
line = "[daemon]\nAutomaticLoginEnable=False\n"
|
||||||
|
|
||||||
gdm_conf.write(line)
|
gdm_conf.write(line)
|
||||||
else:
|
else:
|
||||||
with open(gdm_conf_path, 'w') as gdm_conf:
|
with open(gdm_conf_path, 'w') as gdm_conf:
|
||||||
gdm_conf.write(
|
gdm_conf.write('# Calamares - Enable automatic login for user\n')
|
||||||
'# Calamares - Enable automatic login for user\n')
|
|
||||||
gdm_conf.write('[daemon]\n')
|
gdm_conf.write('[daemon]\n')
|
||||||
|
|
||||||
if do_autologin:
|
if do_autologin:
|
||||||
gdm_conf.write("AutomaticLogin={!s}\n".format(username))
|
gdm_conf.write("AutomaticLogin={!s}\n".format(username))
|
||||||
mdm_conf.write('AutomaticLoginEnable=True\n')
|
gdm_conf.write('AutomaticLoginEnable=True\n')
|
||||||
else:
|
else:
|
||||||
mdm_conf.write('AutomaticLoginEnable=False\n')
|
gdm_conf.write('AutomaticLoginEnable=False\n')
|
||||||
|
|
||||||
if do_autologin and os.path.exists("{!s}/var/lib/AccountsService/users".format(root_mount_point)):
|
if do_autologin and os.path.exists("{!s}/var/lib/AccountsService/users".format(root_mount_point)):
|
||||||
os.system(
|
os.system("echo \"[User]\" > {!s}/var/lib/AccountsService/users/{!s}".format(root_mount_point, username))
|
||||||
"echo \"[User]\" > {!s}/var/lib/AccountsService/users/{!s}".format(
|
|
||||||
root_mount_point, username))
|
|
||||||
if default_desktop_environment is not None:
|
if default_desktop_environment is not None:
|
||||||
os.system(
|
os.system("echo \"XSession={!s}\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
||||||
"echo \"XSession={!s}\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
default_desktop_environment.desktop_file, root_mount_point, username))
|
||||||
default_desktop_environment.desktop_file, root_mount_point, username))
|
|
||||||
os.system(
|
os.system("echo \"Icon=\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
||||||
"echo \"Icon=\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
root_mount_point, username))
|
||||||
root_mount_point, username))
|
|
||||||
|
|
||||||
if "kdm" in displaymanagers:
|
if "kdm" in displaymanagers:
|
||||||
# Systems with KDM as Desktop Manager
|
# Systems with KDM as Desktop Manager
|
||||||
kdm_conf_path = os.path.join(
|
kdm_conf_path = os.path.join(root_mount_point, "usr/share/config/kdm/kdmrc")
|
||||||
root_mount_point, "usr/share/config/kdm/kdmrc")
|
|
||||||
text = []
|
text = []
|
||||||
|
|
||||||
if os.path.exists(kdm_conf_path):
|
if os.path.exists(kdm_conf_path):
|
||||||
with open(kdm_conf_path, 'r') as kdm_conf:
|
with open(kdm_conf_path, 'r') as kdm_conf:
|
||||||
text = kdm_conf.readlines()
|
text = kdm_conf.readlines()
|
||||||
|
|
||||||
with open(kdm_conf_path, 'w') as kdm_conf:
|
with open(kdm_conf_path, 'w') as kdm_conf:
|
||||||
for line in text:
|
for line in text:
|
||||||
if 'AutoLoginEnable=' in line:
|
if 'AutoLoginEnable=' in line:
|
||||||
@ -164,8 +170,10 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
line = 'AutoLoginEnable=true\n'
|
line = 'AutoLoginEnable=true\n'
|
||||||
else:
|
else:
|
||||||
line = 'AutoLoginEnable=false\n'
|
line = 'AutoLoginEnable=false\n'
|
||||||
|
|
||||||
if do_autologin and 'AutoLoginUser=' in line:
|
if do_autologin and 'AutoLoginUser=' in line:
|
||||||
line = "AutoLoginUser={!s}\n".format(username)
|
line = "AutoLoginUser={!s}\n".format(username)
|
||||||
|
|
||||||
kdm_conf.write(line)
|
kdm_conf.write(line)
|
||||||
else:
|
else:
|
||||||
return "Cannot write KDM configuration file", "KDM config file {!s} does not exist".format(kdm_conf_path)
|
return "Cannot write KDM configuration file", "KDM config file {!s} does not exist".format(kdm_conf_path)
|
||||||
@ -174,9 +182,11 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
# Systems with LXDM as Desktop Manager
|
# Systems with LXDM as Desktop Manager
|
||||||
lxdm_conf_path = os.path.join(root_mount_point, "etc/lxdm/lxdm.conf")
|
lxdm_conf_path = os.path.join(root_mount_point, "etc/lxdm/lxdm.conf")
|
||||||
text = []
|
text = []
|
||||||
|
|
||||||
if os.path.exists(lxdm_conf_path):
|
if os.path.exists(lxdm_conf_path):
|
||||||
with open(lxdm_conf_path, 'r') as lxdm_conf:
|
with open(lxdm_conf_path, 'r') as lxdm_conf:
|
||||||
text = lxdm_conf.readlines()
|
text = lxdm_conf.readlines()
|
||||||
|
|
||||||
with open(lxdm_conf_path, 'w') as lxdm_conf:
|
with open(lxdm_conf_path, 'w') as lxdm_conf:
|
||||||
for line in text:
|
for line in text:
|
||||||
if 'autologin=' in line:
|
if 'autologin=' in line:
|
||||||
@ -184,6 +194,7 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
line = "autologin={!s}\n".format(username)
|
line = "autologin={!s}\n".format(username)
|
||||||
else:
|
else:
|
||||||
line = "# autologin=\n"
|
line = "# autologin=\n"
|
||||||
|
|
||||||
lxdm_conf.write(line)
|
lxdm_conf.write(line)
|
||||||
else:
|
else:
|
||||||
return "Cannot write LXDM configuration file", "LXDM config file {!s} does not exist".format(lxdm_conf_path)
|
return "Cannot write LXDM configuration file", "LXDM config file {!s} does not exist".format(lxdm_conf_path)
|
||||||
@ -193,12 +204,13 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
# Ideally, we should use configparser for the ini conf file,
|
# Ideally, we should use configparser for the ini conf file,
|
||||||
# but we just do a simple text replacement for now, as it
|
# but we just do a simple text replacement for now, as it
|
||||||
# worksforme(tm)
|
# worksforme(tm)
|
||||||
lightdm_conf_path = os.path.join(
|
lightdm_conf_path = os.path.join(root_mount_point, "etc/lightdm/lightdm.conf")
|
||||||
root_mount_point, "etc/lightdm/lightdm.conf")
|
|
||||||
text = []
|
text = []
|
||||||
|
|
||||||
if os.path.exists(lightdm_conf_path):
|
if os.path.exists(lightdm_conf_path):
|
||||||
with open(lightdm_conf_path, 'r') as lightdm_conf:
|
with open(lightdm_conf_path, 'r') as lightdm_conf:
|
||||||
text = lightdm_conf.readlines()
|
text = lightdm_conf.readlines()
|
||||||
|
|
||||||
with open(lightdm_conf_path, 'w') as lightdm_conf:
|
with open(lightdm_conf_path, 'w') as lightdm_conf:
|
||||||
for line in text:
|
for line in text:
|
||||||
if 'autologin-user=' in line:
|
if 'autologin-user=' in line:
|
||||||
@ -206,6 +218,7 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
line = "autologin-user={!s}\n".format(username)
|
line = "autologin-user={!s}\n".format(username)
|
||||||
else:
|
else:
|
||||||
line = "#autologin-user=\n"
|
line = "#autologin-user=\n"
|
||||||
|
|
||||||
lightdm_conf.write(line)
|
lightdm_conf.write(line)
|
||||||
else:
|
else:
|
||||||
return "Cannot write LightDM configuration file", "LightDM config file {!s} does not exist".format(lightdm_conf_path)
|
return "Cannot write LightDM configuration file", "LightDM config file {!s} does not exist".format(lightdm_conf_path)
|
||||||
@ -214,9 +227,11 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
# Systems with Slim as Desktop Manager
|
# Systems with Slim as Desktop Manager
|
||||||
slim_conf_path = os.path.join(root_mount_point, "etc/slim.conf")
|
slim_conf_path = os.path.join(root_mount_point, "etc/slim.conf")
|
||||||
text = []
|
text = []
|
||||||
|
|
||||||
if os.path.exists(slim_conf_path):
|
if os.path.exists(slim_conf_path):
|
||||||
with open(slim_conf_path, 'r') as slim_conf:
|
with open(slim_conf_path, 'r') as slim_conf:
|
||||||
text = slim_conf.readlines()
|
text = slim_conf.readlines()
|
||||||
|
|
||||||
with open(slim_conf_path, 'w') as slim_conf:
|
with open(slim_conf_path, 'w') as slim_conf:
|
||||||
for line in text:
|
for line in text:
|
||||||
if 'auto_login' in line:
|
if 'auto_login' in line:
|
||||||
@ -224,8 +239,10 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
line = 'auto_login yes\n'
|
line = 'auto_login yes\n'
|
||||||
else:
|
else:
|
||||||
line = 'auto_login no\n'
|
line = 'auto_login no\n'
|
||||||
|
|
||||||
if do_autologin and 'default_user' in line:
|
if do_autologin and 'default_user' in line:
|
||||||
line = "default_user {!s}\n".format(username)
|
line = "default_user {!s}\n".format(username)
|
||||||
|
|
||||||
slim_conf.write(line)
|
slim_conf.write(line)
|
||||||
else:
|
else:
|
||||||
return "Cannot write SLIM configuration file", "SLIM config file {!s} does not exist".format(slim_conf_path)
|
return "Cannot write SLIM configuration file", "SLIM config file {!s} does not exist".format(slim_conf_path)
|
||||||
@ -233,13 +250,17 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
if "sddm" in displaymanagers:
|
if "sddm" in displaymanagers:
|
||||||
# Systems with Sddm as Desktop Manager
|
# Systems with Sddm as Desktop Manager
|
||||||
sddm_conf_path = os.path.join(root_mount_point, "etc/sddm.conf")
|
sddm_conf_path = os.path.join(root_mount_point, "etc/sddm.conf")
|
||||||
|
|
||||||
if os.path.isfile(sddm_conf_path):
|
if os.path.isfile(sddm_conf_path):
|
||||||
libcalamares.utils.debug('SDDM config file exists')
|
libcalamares.utils.debug('SDDM config file exists')
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.check_chroot_call(["sh", "-c", "sddm --example-config > /etc/sddm.conf"])
|
libcalamares.utils.check_chroot_call(["sh", "-c", "sddm --example-config > /etc/sddm.conf"])
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
|
|
||||||
with open(sddm_conf_path, 'r') as sddm_conf:
|
with open(sddm_conf_path, 'r') as sddm_conf:
|
||||||
text = sddm_conf.readlines()
|
text = sddm_conf.readlines()
|
||||||
|
|
||||||
with open(sddm_conf_path, 'w') as sddm_conf:
|
with open(sddm_conf_path, 'w') as sddm_conf:
|
||||||
for line in text:
|
for line in text:
|
||||||
# User= line, possibly commented out
|
# User= line, possibly commented out
|
||||||
@ -248,6 +269,7 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
line = 'User={}\n'.format(username)
|
line = 'User={}\n'.format(username)
|
||||||
else:
|
else:
|
||||||
line = '#User=\n'
|
line = '#User=\n'
|
||||||
|
|
||||||
# Session= line, commented out or with empty value
|
# Session= line, commented out or with empty value
|
||||||
if re.match('\\s*#\\s*Session=|\\s*Session=$', line):
|
if re.match('\\s*#\\s*Session=|\\s*Session=$', line):
|
||||||
if default_desktop_environment is not None:
|
if default_desktop_environment is not None:
|
||||||
@ -255,6 +277,7 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
line = 'Session={}.desktop\n'.format(default_desktop_environment.desktop_file)
|
line = 'Session={}.desktop\n'.format(default_desktop_environment.desktop_file)
|
||||||
else:
|
else:
|
||||||
line = '#Session={}.desktop\n'.format(default_desktop_environment.desktop_file)
|
line = '#Session={}.desktop\n'.format(default_desktop_environment.desktop_file)
|
||||||
|
|
||||||
sddm_conf.write(line)
|
sddm_conf.write(line)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@ -262,7 +285,7 @@ def set_autologin(username, displaymanagers, default_desktop_environment,
|
|||||||
|
|
||||||
def run():
|
def run():
|
||||||
""" Configure display managers.
|
""" Configure display managers.
|
||||||
|
|
||||||
We acquire a list of displaymanagers, either from config or (overridden) from globalstorage.
|
We acquire a list of displaymanagers, either from config or (overridden) from globalstorage.
|
||||||
This module will try to set up (including autologin) all the displaymanagers in the list, in that specific order.
|
This module will try to set up (including autologin) all the displaymanagers in the list, in that specific order.
|
||||||
Most distros will probably only ship one displaymanager.
|
Most distros will probably only ship one displaymanager.
|
||||||
@ -310,23 +333,22 @@ def run():
|
|||||||
if have_dm("lightdm", root_mount_point):
|
if have_dm("lightdm", root_mount_point):
|
||||||
if enable_basic_setup:
|
if enable_basic_setup:
|
||||||
libcalamares.utils.chroot_call(['mkdir', '-p', '/run/lightdm'])
|
libcalamares.utils.chroot_call(['mkdir', '-p', '/run/lightdm'])
|
||||||
|
|
||||||
if libcalamares.utils.chroot_call(['getent', 'group', 'lightdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'group', 'lightdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(['groupadd', '-g', '620', 'lightdm'])
|
||||||
['groupadd', '-g', '620', 'lightdm'])
|
|
||||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'lightdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'lightdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(['useradd', '-c', '"LightDM Display Manager"',
|
||||||
['useradd', '-c', '"LightDM Display Manager"',
|
'-u', '620', '-g', 'lightdm', '-d', '/var/run/lightdm',
|
||||||
'-u', '620', '-g', 'lightdm', '-d', '/var/run/lightdm',
|
'-s', '/usr/bin/nologin', 'lightdm'])
|
||||||
'-s', '/usr/bin/nologin', 'lightdm'])
|
|
||||||
libcalamares.utils.chroot_call(['passwd', '-l', 'lightdm'])
|
libcalamares.utils.chroot_call(['passwd', '-l', 'lightdm'])
|
||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(['chown', '-R', 'lightdm:lightdm', '/run/lightdm'])
|
||||||
['chown', '-R', 'lightdm:lightdm', '/run/lightdm'])
|
libcalamares.utils.chroot_call(['chmod', '+r' '/etc/lightdm/lightdm.conf'])
|
||||||
libcalamares.utils.chroot_call(
|
|
||||||
['chmod', '+r' '/etc/lightdm/lightdm.conf'])
|
|
||||||
if default_desktop_environment is not None:
|
if default_desktop_environment is not None:
|
||||||
os.system(
|
os.system("sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format(
|
||||||
"sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format(
|
default_desktop_environment.desktop_file, root_mount_point))
|
||||||
default_desktop_environment.desktop_file, root_mount_point))
|
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.debug("lightdm selected but not installed")
|
libcalamares.utils.debug("lightdm selected but not installed")
|
||||||
displaymanagers.remove("lightdm")
|
displaymanagers.remove("lightdm")
|
||||||
@ -337,14 +359,14 @@ def run():
|
|||||||
if enable_basic_setup:
|
if enable_basic_setup:
|
||||||
if libcalamares.utils.chroot_call(['getent', 'group', 'gdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'group', 'gdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['groupadd', '-g', '120', 'gdm'])
|
libcalamares.utils.chroot_call(['groupadd', '-g', '120', 'gdm'])
|
||||||
|
|
||||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'gdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'gdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(['useradd', '-c', '"Gnome Display Manager"',
|
||||||
['useradd', '-c', '"Gnome Display Manager"',
|
'-u', '120', '-g', 'gdm', '-d', '/var/lib/gdm',
|
||||||
'-u', '120', '-g', 'gdm', '-d', '/var/lib/gdm',
|
'-s', '/usr/bin/nologin', 'gdm'])
|
||||||
'-s', '/usr/bin/nologin', 'gdm'])
|
|
||||||
libcalamares.utils.chroot_call(['passwd', '-l', 'gdm'])
|
libcalamares.utils.chroot_call(['passwd', '-l', 'gdm'])
|
||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(['chown', '-R', 'gdm:gdm', '/var/lib/gdm'])
|
||||||
['chown', '-R', 'gdm:gdm', '/var/lib/gdm'])
|
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.debug("gdm selected but not installed")
|
libcalamares.utils.debug("gdm selected but not installed")
|
||||||
displaymanagers.remove("gdm")
|
displaymanagers.remove("gdm")
|
||||||
@ -355,19 +377,19 @@ def run():
|
|||||||
if enable_basic_setup:
|
if enable_basic_setup:
|
||||||
if libcalamares.utils.chroot_call(['getent', 'group', 'mdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'group', 'mdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['groupadd', '-g', '128', 'mdm'])
|
libcalamares.utils.chroot_call(['groupadd', '-g', '128', 'mdm'])
|
||||||
|
|
||||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'mdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'mdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(['useradd', '-c', '"Linux Mint Display Manager"',
|
||||||
['useradd', '-c', '"Linux Mint Display Manager"',
|
'-u', '128', '-g', 'mdm', '-d', '/var/lib/mdm',
|
||||||
'-u', '128', '-g', 'mdm', '-d', '/var/lib/mdm',
|
'-s', '/usr/bin/nologin', 'mdm'])
|
||||||
'-s', '/usr/bin/nologin', 'mdm'])
|
|
||||||
libcalamares.utils.chroot_call(['passwd', '-l', 'mdm'])
|
libcalamares.utils.chroot_call(['passwd', '-l', 'mdm'])
|
||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(['chown', 'root:mdm', '/var/lib/mdm'])
|
||||||
['chown', 'root:mdm', '/var/lib/mdm'])
|
|
||||||
libcalamares.utils.chroot_call(['chmod', '1770', '/var/lib/mdm'])
|
libcalamares.utils.chroot_call(['chmod', '1770', '/var/lib/mdm'])
|
||||||
|
|
||||||
if default_desktop_environment is not None:
|
if default_desktop_environment is not None:
|
||||||
os.system(
|
os.system("sed -i \"s|default.desktop|{!s}.desktop|g\" {!s}/etc/mdm/custom.conf".format(
|
||||||
"sed -i \"s|default.desktop|{!s}.desktop|g\" {!s}/etc/mdm/custom.conf".format(
|
default_desktop_environment.desktop_file, root_mount_point))
|
||||||
default_desktop_environment.desktop_file, root_mount_point))
|
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.debug("mdm selected but not installed")
|
libcalamares.utils.debug("mdm selected but not installed")
|
||||||
displaymanagers.remove("mdm")
|
displaymanagers.remove("mdm")
|
||||||
@ -378,16 +400,14 @@ def run():
|
|||||||
if enable_basic_setup:
|
if enable_basic_setup:
|
||||||
if libcalamares.utils.chroot_call(['getent', 'group', 'lxdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'group', 'lxdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['groupadd', '--system', 'lxdm'])
|
libcalamares.utils.chroot_call(['groupadd', '--system', 'lxdm'])
|
||||||
libcalamares.utils.chroot_call(
|
|
||||||
['chgrp', '-R', 'lxdm', '/var/lib/lxdm'])
|
libcalamares.utils.chroot_call(['chgrp', '-R', 'lxdm', '/var/lib/lxdm'])
|
||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(['chgrp', 'lxdm', '/etc/lxdm/lxdm.conf'])
|
||||||
['chgrp', 'lxdm', '/etc/lxdm/lxdm.conf'])
|
libcalamares.utils.chroot_call(['chmod', '+r', '/etc/lxdm/lxdm.conf'])
|
||||||
libcalamares.utils.chroot_call(
|
|
||||||
['chmod', '+r', '/etc/lxdm/lxdm.conf'])
|
|
||||||
if default_desktop_environment is not None:
|
if default_desktop_environment is not None:
|
||||||
os.system(
|
os.system("sed -i -e \"s|^.*session=.*|session={!s}|\" {!s}/etc/lxdm/lxdm.conf".format(
|
||||||
"sed -i -e \"s|^.*session=.*|session={!s}|\" {!s}/etc/lxdm/lxdm.conf".format(
|
default_desktop_environment.executable, root_mount_point))
|
||||||
default_desktop_environment.executable, root_mount_point))
|
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.debug("lxdm selected but not installed")
|
libcalamares.utils.debug("lxdm selected but not installed")
|
||||||
displaymanagers.remove("lxdm")
|
displaymanagers.remove("lxdm")
|
||||||
@ -398,19 +418,18 @@ def run():
|
|||||||
if enable_basic_setup:
|
if enable_basic_setup:
|
||||||
if libcalamares.utils.chroot_call(['getent', 'group', 'kdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'group', 'kdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['groupadd', '-g', '135', 'kdm'])
|
libcalamares.utils.chroot_call(['groupadd', '-g', '135', 'kdm'])
|
||||||
|
|
||||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'kdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'kdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(['useradd', '-u', '135', '-g', 'kdm', '-d',
|
||||||
['useradd', '-u', '135', '-g', 'kdm', '-d',
|
'/var/lib/kdm', '-s', '/bin/false', '-r', '-M', 'kdm'])
|
||||||
'/var/lib/kdm', '-s', '/bin/false', '-r', '-M', 'kdm'])
|
|
||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(['chown', '-R', '135:135', 'var/lib/kdm'])
|
||||||
['chown', '-R', '135:135', 'var/lib/kdm'])
|
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.debug("kdm selected but not installed")
|
libcalamares.utils.debug("kdm selected but not installed")
|
||||||
displaymanagers.remove("kdm")
|
displaymanagers.remove("kdm")
|
||||||
|
|
||||||
if username is not None:
|
if username is not None:
|
||||||
libcalamares.utils.debug(
|
libcalamares.utils.debug("Setting up autologin for user {!s}.".format(username))
|
||||||
"Setting up autologin for user {!s}.".format(username))
|
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.debug("Unsetting autologin.")
|
libcalamares.utils.debug("Unsetting autologin.")
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ def run():
|
|||||||
|
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
returnCode = run_dracut()
|
return_code = run_dracut()
|
||||||
if returnCode != 0:
|
|
||||||
return ("Failed to run dracut on the target", "The exit code was {}".format(returnCode))
|
if return_code != 0:
|
||||||
|
return "Failed to run dracut on the target", "The exit code was {}".format(return_code)
|
||||||
|
Loading…
Reference in New Issue
Block a user