|
|
@ -30,8 +30,8 @@ import subprocess
|
|
|
|
DesktopEnvironment = collections.namedtuple('DesktopEnvironment', ['executable', 'desktop_file'])
|
|
|
|
DesktopEnvironment = collections.namedtuple('DesktopEnvironment', ['executable', 'desktop_file'])
|
|
|
|
|
|
|
|
|
|
|
|
desktop_environments = [
|
|
|
|
desktop_environments = [
|
|
|
|
DesktopEnvironment('/usr/bin/startkde', 'plasma'), # KDE Plasma 5
|
|
|
|
DesktopEnvironment('/usr/bin/startkde', 'plasma'), # KDE Plasma 5
|
|
|
|
DesktopEnvironment('/usr/bin/startkde', 'kde-plasma'), # KDE Plasma 4
|
|
|
|
DesktopEnvironment('/usr/bin/startkde', 'kde-plasma'), # KDE Plasma 4
|
|
|
|
DesktopEnvironment('/usr/bin/gnome-session', 'gnome'),
|
|
|
|
DesktopEnvironment('/usr/bin/gnome-session', 'gnome'),
|
|
|
|
DesktopEnvironment('/usr/bin/startxfce4', 'xfce'),
|
|
|
|
DesktopEnvironment('/usr/bin/startxfce4', 'xfce'),
|
|
|
|
DesktopEnvironment('/usr/bin/cinnamon-session', 'cinnamon-session'),
|
|
|
|
DesktopEnvironment('/usr/bin/cinnamon-session', 'cinnamon-session'),
|
|
|
@ -43,17 +43,25 @@ desktop_environments = [
|
|
|
|
DesktopEnvironment('/usr/bin/openbox-session', 'openbox')
|
|
|
|
DesktopEnvironment('/usr/bin/openbox-session', 'openbox')
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def find_desktop_environment(root_mount_point):
|
|
|
|
def find_desktop_environment(root_mount_point):
|
|
|
|
for desktop_environment in desktop_environments:
|
|
|
|
for desktop_environment in desktop_environments:
|
|
|
|
if os.path.exists("{!s}{!s}".format(root_mount_point,desktop_environment.executable)) \
|
|
|
|
if os.path.exists(
|
|
|
|
and os.path.exists("{!s}/usr/share/xsessions/{!s}.desktop".format(root_mount_point,desktop_environment.desktop_file)):
|
|
|
|
"{!s}{!s}".format(root_mount_point, desktop_environment.executable)) \
|
|
|
|
|
|
|
|
and os.path.exists("{!s}/usr/share/xsessions/{!s}.desktop".format(root_mount_point,
|
|
|
|
|
|
|
|
desktop_environment.desktop_file)):
|
|
|
|
return desktop_environment
|
|
|
|
return desktop_environment
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def have_dm(dm_name, root_mount_point):
|
|
|
|
def have_dm(dm_name, root_mount_point):
|
|
|
|
return os.path.exists("{!s}/usr/bin/{!s}".format(root_mount_point,dm_name)) or os.path.exists("{!s}/usr/sbin/{!s}".format(root_mount_point,dm_name))
|
|
|
|
return os.path.exists(
|
|
|
|
|
|
|
|
"{!s}/usr/bin/{!s}".format(root_mount_point, dm_name)) or os.path.exists(
|
|
|
|
|
|
|
|
"{!s}/usr/sbin/{!s}".format(root_mount_point, dm_name))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_autologin(username, displaymanagers, default_desktop_environment, root_mount_point):
|
|
|
|
def set_autologin(username, displaymanagers, default_desktop_environment,
|
|
|
|
|
|
|
|
root_mount_point):
|
|
|
|
""" Enables automatic login for the installed desktop managers """
|
|
|
|
""" Enables automatic login for the installed desktop managers """
|
|
|
|
|
|
|
|
|
|
|
|
if "mdm" in displaymanagers:
|
|
|
|
if "mdm" in displaymanagers:
|
|
|
@ -95,12 +103,15 @@ def set_autologin(username, displaymanagers, default_desktop_environment, root_m
|
|
|
|
gdm_conf.write('AutomaticLoginEnable=True\n')
|
|
|
|
gdm_conf.write('AutomaticLoginEnable=True\n')
|
|
|
|
if os.path.exists("{!s}/var/lib/AccountsService/users".format(root_mount_point)):
|
|
|
|
if 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(default_desktop_environment.desktop_file,root_mount_point,username))
|
|
|
|
"echo \"XSession={!s}\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
|
|
|
|
|
|
|
default_desktop_environment.desktop_file, root_mount_point, username))
|
|
|
|
os.system(
|
|
|
|
os.system(
|
|
|
|
"echo \"Icon=\" >> {!s}/var/lib/AccountsService/users/{!s}".format(root_mount_point,username))
|
|
|
|
"echo \"Icon=\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
|
|
|
|
|
|
|
root_mount_point, username))
|
|
|
|
|
|
|
|
|
|
|
|
if "kdm" in displaymanagers:
|
|
|
|
if "kdm" in displaymanagers:
|
|
|
|
# Systems with KDM as Desktop Manager
|
|
|
|
# Systems with KDM as Desktop Manager
|
|
|
@ -191,7 +202,7 @@ def set_autologin(username, displaymanagers, default_desktop_environment, root_m
|
|
|
|
if default_desktop_environment is not None:
|
|
|
|
if default_desktop_environment is not None:
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -209,15 +220,16 @@ def run():
|
|
|
|
displaymanagers = libcalamares.globalstorage.value("displaymanagers")
|
|
|
|
displaymanagers = libcalamares.globalstorage.value("displaymanagers")
|
|
|
|
|
|
|
|
|
|
|
|
if displaymanagers is None:
|
|
|
|
if displaymanagers is None:
|
|
|
|
return "No display managers selected for the displaymanager module.",\
|
|
|
|
return "No display managers selected for the displaymanager module.", \
|
|
|
|
"The displaymanagers list is empty or undefined in both globalstorage and displaymanager.conf."
|
|
|
|
"The displaymanagers list is empty or undefined in both globalstorage and displaymanager.conf."
|
|
|
|
|
|
|
|
|
|
|
|
username = libcalamares.globalstorage.value("autologinUser")
|
|
|
|
username = libcalamares.globalstorage.value("autologinUser")
|
|
|
|
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
|
|
|
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
|
|
|
|
|
|
|
|
|
|
|
if "default_desktop_environment" in libcalamares.job.configuration:
|
|
|
|
if "default_desktop_environment" in libcalamares.job.configuration:
|
|
|
|
entry = libcalamares.job.configuration["defaultDesktopEnvironment"]
|
|
|
|
entry = libcalamares.job.configuration["defaultDesktopEnvironment"]
|
|
|
|
default_desktop_environment = DesktopEnvironment(entry["executable"], entry["desktopFile"])
|
|
|
|
default_desktop_environment = DesktopEnvironment(entry["executable"],
|
|
|
|
|
|
|
|
entry["desktopFile"])
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
default_desktop_environment = find_desktop_environment(root_mount_point)
|
|
|
|
default_desktop_environment = find_desktop_environment(root_mount_point)
|
|
|
|
|
|
|
|
|
|
|
@ -247,9 +259,10 @@ def run():
|
|
|
|
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(['useradd', '-c', '"LightDM Display Manager"',
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
'-u', '620', '-g', 'lightdm', '-d', '/var/run/lightdm',
|
|
|
|
['useradd', '-c', '"LightDM Display Manager"',
|
|
|
|
'-s', '/usr/bin/nologin', 'lightdm'])
|
|
|
|
'-u', '620', '-g', 'lightdm', '-d', '/var/run/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'])
|
|
|
@ -257,7 +270,8 @@ def run():
|
|
|
|
['chmod', '+r' '/etc/lightdm/lightdm.conf'])
|
|
|
|
['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(default_desktop_environment.desktop_file,root_mount_point))
|
|
|
|
"sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format(
|
|
|
|
|
|
|
|
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")
|
|
|
@ -269,9 +283,10 @@ def run():
|
|
|
|
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(['useradd', '-c', '"Gnome Display Manager"',
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
'-u', '120', '-g', 'gdm', '-d', '/var/lib/gdm',
|
|
|
|
['useradd', '-c', '"Gnome Display Manager"',
|
|
|
|
'-s', '/usr/bin/nologin', 'gdm'])
|
|
|
|
'-u', '120', '-g', 'gdm', '-d', '/var/lib/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'])
|
|
|
@ -286,16 +301,18 @@ def run():
|
|
|
|
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(['useradd', '-c', '"Linux Mint Display Manager"',
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
'-u', '128', '-g', 'mdm', '-d', '/var/lib/mdm',
|
|
|
|
['useradd', '-c', '"Linux Mint Display Manager"',
|
|
|
|
'-s', '/usr/bin/nologin', 'mdm'])
|
|
|
|
'-u', '128', '-g', 'mdm', '-d', '/var/lib/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(default_desktop_environment.desktop_file,root_mount_point))
|
|
|
|
"sed -i \"s|default.desktop|{!s}.desktop|g\" {!s}/etc/mdm/custom.conf".format(
|
|
|
|
|
|
|
|
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")
|
|
|
@ -314,7 +331,8 @@ def run():
|
|
|
|
['chmod', '+r', '/etc/lxdm/lxdm.conf'])
|
|
|
|
['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(default_desktop_environment.executable,root_mount_point))
|
|
|
|
"sed -i -e \"s|^.*session=.*|session={!s}|\" {!s}/etc/lxdm/lxdm.conf".format(
|
|
|
|
|
|
|
|
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")
|
|
|
@ -326,8 +344,9 @@ def run():
|
|
|
|
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(['useradd', '-u', '135', '-g', 'kdm', '-d',
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
'/var/lib/kdm', '-s', '/bin/false', '-r', '-M', 'kdm'])
|
|
|
|
['useradd', '-u', '135', '-g', 'kdm', '-d',
|
|
|
|
|
|
|
|
'/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:
|
|
|
|