2014-08-11 13:23:12 +02:00
|
|
|
#!/usr/bin/env python3
|
2015-02-18 15:06:10 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2014-08-11 13:23:12 +02:00
|
|
|
# === This file is part of Calamares - <http://github.com/calamares> ===
|
|
|
|
#
|
2015-02-21 09:57:23 +01:00
|
|
|
# Copyright 2014-2015, Philip Müller <philm@manjaro.org>
|
2015-02-25 13:01:35 +01:00
|
|
|
# Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
2014-11-29 16:56:43 +01:00
|
|
|
# Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
2014-08-11 13:23:12 +02:00
|
|
|
#
|
|
|
|
# Calamares is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Calamares is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import os
|
2014-11-07 02:24:43 +01:00
|
|
|
import collections
|
2014-11-07 02:57:19 +01:00
|
|
|
import re
|
2014-08-11 13:23:12 +02:00
|
|
|
import libcalamares
|
|
|
|
|
2014-08-11 14:28:50 +02:00
|
|
|
|
2014-11-07 02:24:43 +01:00
|
|
|
DesktopEnvironment = collections.namedtuple('DesktopEnvironment', ['executable', 'desktop_file'])
|
|
|
|
|
|
|
|
desktop_environments = [
|
2015-02-18 16:03:57 +01:00
|
|
|
DesktopEnvironment('/usr/bin/startkde', 'plasma'), # KDE Plasma 5
|
|
|
|
DesktopEnvironment('/usr/bin/startkde', 'kde-plasma'), # KDE Plasma 4
|
2014-11-07 02:26:13 +01:00
|
|
|
DesktopEnvironment('/usr/bin/gnome-session', 'gnome'),
|
2014-11-07 02:24:43 +01:00
|
|
|
DesktopEnvironment('/usr/bin/startxfce4', 'xfce'),
|
|
|
|
DesktopEnvironment('/usr/bin/cinnamon-session', 'cinnamon-session'),
|
|
|
|
DesktopEnvironment('/usr/bin/mate-session', 'mate'),
|
|
|
|
DesktopEnvironment('/usr/bin/enlightenment_start', 'enlightenment'),
|
2014-11-07 14:04:15 +01:00
|
|
|
DesktopEnvironment('/usr/bin/lxsession', 'LXDE'),
|
|
|
|
DesktopEnvironment('/usr/bin/startlxde', 'LXDE'),
|
2014-11-28 08:23:46 +01:00
|
|
|
DesktopEnvironment('/usr/bin/lxqt-session', 'lxqt'),
|
2015-05-15 07:07:54 +02:00
|
|
|
DesktopEnvironment('/usr/bin/pekwm', 'pekwm'),
|
|
|
|
DesktopEnvironment('/usr/bin/pantheon-session', 'pantheon'),
|
2015-05-15 12:50:29 +02:00
|
|
|
DesktopEnvironment('/usr/bin/budgie-session', 'budgie-session'),
|
|
|
|
DesktopEnvironment('/usr/bin/i3', 'i3'),
|
|
|
|
DesktopEnvironment('/usr/bin/openbox-session', 'openbox')
|
2014-11-07 02:24:43 +01:00
|
|
|
]
|
|
|
|
|
2015-02-18 16:03:57 +01:00
|
|
|
|
2014-11-07 02:24:43 +01:00
|
|
|
def find_desktop_environment(root_mount_point):
|
2015-02-21 10:09:01 +01:00
|
|
|
""" Checks which desktop environment is currently installed.
|
2015-02-20 20:54:25 +01:00
|
|
|
|
|
|
|
:param root_mount_point:
|
|
|
|
:return:
|
|
|
|
"""
|
2014-11-07 02:24:43 +01:00
|
|
|
for desktop_environment in desktop_environments:
|
2015-02-18 16:03:57 +01:00
|
|
|
if os.path.exists(
|
|
|
|
"{!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)):
|
2014-11-07 02:24:43 +01:00
|
|
|
return desktop_environment
|
|
|
|
return None
|
|
|
|
|
2015-02-18 16:03:57 +01:00
|
|
|
|
2014-12-05 22:20:54 +01:00
|
|
|
def have_dm(dm_name, root_mount_point):
|
2015-02-21 10:09:01 +01:00
|
|
|
""" Checks if display manager is properly installed.
|
2015-02-20 20:54:25 +01:00
|
|
|
|
|
|
|
:param dm_name:
|
|
|
|
:param root_mount_point:
|
|
|
|
:return:
|
|
|
|
"""
|
2015-02-18 16:03:57 +01:00
|
|
|
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))
|
|
|
|
|
2014-12-05 22:20:54 +01:00
|
|
|
|
2015-02-18 16:03:57 +01:00
|
|
|
def set_autologin(username, displaymanagers, default_desktop_environment,
|
|
|
|
root_mount_point):
|
2015-02-21 10:09:01 +01:00
|
|
|
""" Enables automatic login for the installed desktop managers.
|
2015-02-20 20:54:25 +01:00
|
|
|
|
|
|
|
:param username:
|
|
|
|
:param displaymanagers:
|
|
|
|
:param default_desktop_environment:
|
|
|
|
:param root_mount_point:
|
|
|
|
"""
|
2015-02-25 17:54:38 +01:00
|
|
|
|
|
|
|
do_autologin = True
|
|
|
|
if username is None:
|
|
|
|
do_autologin = False
|
|
|
|
|
2014-08-11 13:23:12 +02:00
|
|
|
if "mdm" in displaymanagers:
|
|
|
|
# Systems with MDM as Desktop Manager
|
|
|
|
mdm_conf_path = os.path.join(root_mount_point, "etc/mdm/custom.conf")
|
|
|
|
if os.path.exists(mdm_conf_path):
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(mdm_conf_path, 'r') as mdm_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
text = mdm_conf.readlines()
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(mdm_conf_path, 'w') as mdm_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
for line in text:
|
|
|
|
if '[daemon]' in line:
|
2015-02-25 13:01:35 +01:00
|
|
|
if do_autologin:
|
|
|
|
line = "[daemon]\nAutomaticLogin={!s}\nAutomaticLoginEnable=True\n".format(username)
|
|
|
|
else:
|
2015-02-25 17:54:38 +01:00
|
|
|
line = "[daemon]\nAutomaticLoginEnable=False\n"
|
2014-08-11 13:23:12 +02:00
|
|
|
mdm_conf.write(line)
|
|
|
|
else:
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(mdm_conf_path, 'w') as mdm_conf:
|
2014-08-11 14:28:50 +02:00
|
|
|
mdm_conf.write(
|
2015-02-25 13:01:35 +01:00
|
|
|
'# Calamares - Configure automatic login for user\n')
|
2014-08-11 13:23:12 +02:00
|
|
|
mdm_conf.write('[daemon]\n')
|
2015-02-25 13:01:35 +01:00
|
|
|
if do_autologin:
|
2015-02-25 17:54:38 +01:00
|
|
|
mdm_conf.write("AutomaticLogin={!s}\n".format(username))
|
2015-02-25 13:01:35 +01:00
|
|
|
mdm_conf.write('AutomaticLoginEnable=True\n')
|
|
|
|
else:
|
|
|
|
mdm_conf.write('AutomaticLoginEnable=False\n')
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
if "gdm" in displaymanagers:
|
|
|
|
# Systems with GDM as Desktop Manager
|
|
|
|
gdm_conf_path = os.path.join(root_mount_point, "etc/gdm/custom.conf")
|
|
|
|
if os.path.exists(gdm_conf_path):
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(gdm_conf_path, 'r') as gdm_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
text = gdm_conf.readlines()
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(gdm_conf_path, 'w') as gdm_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
for line in text:
|
|
|
|
if '[daemon]' in line:
|
2015-02-25 13:01:35 +01:00
|
|
|
if do_autologin:
|
|
|
|
line = "[daemon]\nAutomaticLogin={!s}\nAutomaticLoginEnable=True\n".format(username)
|
|
|
|
else:
|
2015-02-25 17:54:38 +01:00
|
|
|
line = "[daemon]\nAutomaticLoginEnable=False\n"
|
2014-08-11 13:23:12 +02:00
|
|
|
gdm_conf.write(line)
|
|
|
|
else:
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(gdm_conf_path, 'w') as gdm_conf:
|
2014-08-11 14:28:50 +02:00
|
|
|
gdm_conf.write(
|
|
|
|
'# Calamares - Enable automatic login for user\n')
|
2014-08-11 13:23:12 +02:00
|
|
|
gdm_conf.write('[daemon]\n')
|
2015-02-25 13:01:35 +01:00
|
|
|
if do_autologin:
|
2015-02-25 17:54:38 +01:00
|
|
|
gdm_conf.write("AutomaticLogin={!s}\n".format(username))
|
2015-02-25 13:01:35 +01:00
|
|
|
mdm_conf.write('AutomaticLoginEnable=True\n')
|
|
|
|
else:
|
|
|
|
mdm_conf.write('AutomaticLoginEnable=False\n')
|
2015-02-25 17:54:38 +01:00
|
|
|
if do_autologin and os.path.exists("{!s}/var/lib/AccountsService/users".format(root_mount_point)):
|
2014-12-01 03:01:39 +01:00
|
|
|
os.system(
|
2015-02-18 16:03:57 +01:00
|
|
|
"echo \"[User]\" > {!s}/var/lib/AccountsService/users/{!s}".format(
|
|
|
|
root_mount_point, username))
|
2015-02-18 15:20:02 +01:00
|
|
|
if default_desktop_environment is not None:
|
2014-12-01 03:01:39 +01:00
|
|
|
os.system(
|
2015-02-18 16:03:57 +01:00
|
|
|
"echo \"XSession={!s}\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
|
|
|
default_desktop_environment.desktop_file, root_mount_point, username))
|
2014-12-01 03:01:39 +01:00
|
|
|
os.system(
|
2015-02-18 16:03:57 +01:00
|
|
|
"echo \"Icon=\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
|
|
|
root_mount_point, username))
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
if "kdm" in displaymanagers:
|
|
|
|
# Systems with KDM as Desktop Manager
|
2014-08-11 14:28:50 +02:00
|
|
|
kdm_conf_path = os.path.join(
|
|
|
|
root_mount_point, "usr/share/config/kdm/kdmrc")
|
2014-08-11 13:23:12 +02:00
|
|
|
text = []
|
|
|
|
if os.path.exists(kdm_conf_path):
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(kdm_conf_path, 'r') as kdm_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
text = kdm_conf.readlines()
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(kdm_conf_path, 'w') as kdm_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
for line in text:
|
2015-02-25 13:01:35 +01:00
|
|
|
if 'AutoLoginEnable=' in line:
|
|
|
|
if do_autologin:
|
|
|
|
line = 'AutoLoginEnable=true\n'
|
|
|
|
else:
|
|
|
|
line = 'AutoLoginEnable=false\n'
|
2015-02-25 17:54:38 +01:00
|
|
|
if do_autologin and 'AutoLoginUser=' in line:
|
2015-02-17 14:38:30 +01:00
|
|
|
line = "AutoLoginUser={!s}\n".format(username)
|
2014-08-11 13:23:12 +02:00
|
|
|
kdm_conf.write(line)
|
|
|
|
else:
|
2015-02-17 14:38:30 +01:00
|
|
|
return "Cannot write KDM configuration file", "KDM config file {!s} does not exist".format(kdm_conf_path)
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
if "lxdm" in displaymanagers:
|
|
|
|
# Systems with LXDM as Desktop Manager
|
|
|
|
lxdm_conf_path = os.path.join(root_mount_point, "etc/lxdm/lxdm.conf")
|
|
|
|
text = []
|
|
|
|
if os.path.exists(lxdm_conf_path):
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(lxdm_conf_path, 'r') as lxdm_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
text = lxdm_conf.readlines()
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(lxdm_conf_path, 'w') as lxdm_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
for line in text:
|
2015-02-25 13:01:35 +01:00
|
|
|
if 'autologin=' in line:
|
|
|
|
if do_autologin:
|
|
|
|
line = "autologin={!s}\n".format(username)
|
|
|
|
else:
|
2015-02-25 17:54:38 +01:00
|
|
|
line = "# autologin=\n"
|
2014-08-11 13:23:12 +02:00
|
|
|
lxdm_conf.write(line)
|
|
|
|
else:
|
2015-02-17 14:38:30 +01:00
|
|
|
return "Cannot write LXDM configuration file", "LXDM config file {!s} does not exist".format(lxdm_conf_path)
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
if "lightdm" in displaymanagers:
|
|
|
|
# Systems with LightDM as Desktop Manager
|
|
|
|
# Ideally, we should use configparser for the ini conf file,
|
2014-08-11 14:28:50 +02:00
|
|
|
# but we just do a simple text replacement for now, as it
|
|
|
|
# worksforme(tm)
|
|
|
|
lightdm_conf_path = os.path.join(
|
|
|
|
root_mount_point, "etc/lightdm/lightdm.conf")
|
2014-08-11 13:23:12 +02:00
|
|
|
text = []
|
|
|
|
if os.path.exists(lightdm_conf_path):
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(lightdm_conf_path, 'r') as lightdm_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
text = lightdm_conf.readlines()
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(lightdm_conf_path, 'w') as lightdm_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
for line in text:
|
2015-02-25 13:01:35 +01:00
|
|
|
if 'autologin-user=' in line:
|
|
|
|
if do_autologin:
|
|
|
|
line = "autologin-user={!s}\n".format(username)
|
|
|
|
else:
|
2015-02-25 17:54:38 +01:00
|
|
|
line = "#autologin-user=\n"
|
2014-08-11 13:23:12 +02:00
|
|
|
lightdm_conf.write(line)
|
|
|
|
else:
|
2015-02-17 14:38:30 +01:00
|
|
|
return "Cannot write LightDM configuration file", "LightDM config file {!s} does not exist".format(lightdm_conf_path)
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
if "slim" in displaymanagers:
|
|
|
|
# Systems with Slim as Desktop Manager
|
|
|
|
slim_conf_path = os.path.join(root_mount_point, "etc/slim.conf")
|
|
|
|
text = []
|
|
|
|
if os.path.exists(slim_conf_path):
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(slim_conf_path, 'r') as slim_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
text = slim_conf.readlines()
|
2014-08-12 11:19:51 +02:00
|
|
|
with open(slim_conf_path, 'w') as slim_conf:
|
2014-08-11 13:23:12 +02:00
|
|
|
for line in text:
|
|
|
|
if 'auto_login' in line:
|
2015-02-25 13:01:35 +01:00
|
|
|
if do_autologin:
|
|
|
|
line = 'auto_login yes\n'
|
|
|
|
else:
|
|
|
|
line = 'auto_login no\n'
|
2015-02-25 17:54:38 +01:00
|
|
|
if do_autologin and 'default_user' in line:
|
2015-02-17 14:38:30 +01:00
|
|
|
line = "default_user {!s}\n".format(username)
|
2014-08-11 13:23:12 +02:00
|
|
|
slim_conf.write(line)
|
|
|
|
else:
|
2015-02-17 14:38:30 +01:00
|
|
|
return "Cannot write SLIM configuration file", "SLIM config file {!s} does not exist".format(slim_conf_path)
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
if "sddm" in displaymanagers:
|
|
|
|
# Systems with Sddm as Desktop Manager
|
|
|
|
sddm_conf_path = os.path.join(root_mount_point, "etc/sddm.conf")
|
2014-10-28 16:18:10 +01:00
|
|
|
if os.path.isfile(sddm_conf_path):
|
2014-12-01 03:03:20 +01:00
|
|
|
libcalamares.utils.debug('SDDM config file exists')
|
2014-10-28 16:15:35 +01:00
|
|
|
else:
|
2014-11-07 01:03:31 +01:00
|
|
|
libcalamares.utils.check_chroot_call(["sh", "-c", "sddm --example-config > /etc/sddm.conf"])
|
2014-08-11 13:23:12 +02:00
|
|
|
text = []
|
2014-10-28 16:15:35 +01:00
|
|
|
with open(sddm_conf_path, 'r') as sddm_conf:
|
|
|
|
text = sddm_conf.readlines()
|
|
|
|
with open(sddm_conf_path, 'w') as sddm_conf:
|
|
|
|
for line in text:
|
2014-11-07 02:57:19 +01:00
|
|
|
# User= line, possibly commented out
|
|
|
|
if re.match('\\s*(?:#\\s*)?User=', line):
|
2015-02-25 13:01:35 +01:00
|
|
|
if do_autologin:
|
|
|
|
line = 'User={}\n'.format(username)
|
|
|
|
else:
|
2015-02-25 17:54:38 +01:00
|
|
|
line = '#User=\n'
|
2014-11-07 03:04:18 +01:00
|
|
|
# Session= line, commented out or with empty value
|
|
|
|
if re.match('\\s*#\\s*Session=|\\s*Session=$', line):
|
2015-02-18 15:20:02 +01:00
|
|
|
if default_desktop_environment is not None:
|
2015-02-25 13:01:35 +01:00
|
|
|
if do_autologin:
|
|
|
|
line = 'Session={}.desktop\n'.format(default_desktop_environment.desktop_file)
|
|
|
|
else:
|
|
|
|
line = '#Session={}.desktop\n'.format(default_desktop_environment.desktop_file)
|
2014-10-28 16:15:35 +01:00
|
|
|
sddm_conf.write(line)
|
2015-02-18 16:03:57 +01:00
|
|
|
|
2014-08-11 13:23:12 +02:00
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def run():
|
2015-02-21 10:18:46 +01:00
|
|
|
""" Configure display managers.
|
2015-02-20 22:18:21 +01:00
|
|
|
|
2015-02-20 20:54:25 +01:00
|
|
|
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.
|
|
|
|
Most distros will probably only ship one displaymanager.
|
|
|
|
If a displaymanager is in the list but not installed, a debugging message is printed and the entry ignored.
|
|
|
|
"""
|
2014-08-11 13:23:12 +02:00
|
|
|
if "displaymanagers" in libcalamares.job.configuration:
|
|
|
|
displaymanagers = libcalamares.job.configuration["displaymanagers"]
|
|
|
|
|
|
|
|
if libcalamares.globalstorage.contains("displaymanagers"):
|
|
|
|
displaymanagers = libcalamares.globalstorage.value("displaymanagers")
|
|
|
|
|
|
|
|
if displaymanagers is None:
|
2015-02-18 16:03:57 +01:00
|
|
|
return "No display managers selected for the displaymanager module.", \
|
2014-08-11 13:23:12 +02:00
|
|
|
"The displaymanagers list is empty or undefined in both globalstorage and displaymanager.conf."
|
|
|
|
|
2014-08-11 14:28:50 +02:00
|
|
|
username = libcalamares.globalstorage.value("autologinUser")
|
|
|
|
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
2015-02-18 16:03:57 +01:00
|
|
|
|
2014-11-28 09:06:33 +01:00
|
|
|
if "default_desktop_environment" in libcalamares.job.configuration:
|
2014-12-01 03:30:42 +01:00
|
|
|
entry = libcalamares.job.configuration["defaultDesktopEnvironment"]
|
2015-02-18 16:03:57 +01:00
|
|
|
default_desktop_environment = DesktopEnvironment(entry["executable"],
|
|
|
|
entry["desktopFile"])
|
2014-11-28 22:12:19 +01:00
|
|
|
else:
|
2014-11-28 09:06:33 +01:00
|
|
|
default_desktop_environment = find_desktop_environment(root_mount_point)
|
2014-08-11 13:23:12 +02:00
|
|
|
|
2014-12-01 03:14:33 +01:00
|
|
|
if "basicSetup" in libcalamares.job.configuration:
|
|
|
|
enable_basic_setup = libcalamares.job.configuration["basicSetup"]
|
|
|
|
else:
|
|
|
|
enable_basic_setup = False
|
|
|
|
|
2014-08-11 13:23:12 +02:00
|
|
|
# Setup slim
|
|
|
|
if "slim" in displaymanagers:
|
2014-12-05 22:20:54 +01:00
|
|
|
if not have_dm("slim", root_mount_point):
|
2014-11-29 17:14:17 +01:00
|
|
|
libcalamares.utils.debug("slim selected but not installed")
|
|
|
|
displaymanagers.remove("slim")
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
# Setup sddm
|
|
|
|
if "sddm" in displaymanagers:
|
2014-12-05 22:20:54 +01:00
|
|
|
if not have_dm("sddm", root_mount_point):
|
2014-11-29 17:14:17 +01:00
|
|
|
libcalamares.utils.debug("sddm selected but not installed")
|
|
|
|
displaymanagers.remove("sddm")
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
# setup lightdm
|
|
|
|
if "lightdm" in displaymanagers:
|
2014-12-05 22:20:54 +01:00
|
|
|
if have_dm("lightdm", root_mount_point):
|
2014-12-01 03:14:33 +01:00
|
|
|
if enable_basic_setup:
|
|
|
|
libcalamares.utils.chroot_call(['mkdir', '-p', '/run/lightdm'])
|
2014-12-01 03:20:55 +01:00
|
|
|
if libcalamares.utils.chroot_call(['getent', 'group', 'lightdm']) != 0:
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['groupadd', '-g', '620', 'lightdm'])
|
|
|
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'lightdm']) != 0:
|
2015-02-18 16:03:57 +01:00
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['useradd', '-c', '"LightDM Display Manager"',
|
|
|
|
'-u', '620', '-g', 'lightdm', '-d', '/var/run/lightdm',
|
|
|
|
'-s', '/usr/bin/nologin', 'lightdm'])
|
2014-12-01 03:14:33 +01:00
|
|
|
libcalamares.utils.chroot_call(['passwd', '-l', 'lightdm'])
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['chown', '-R', 'lightdm:lightdm', '/run/lightdm'])
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['chmod', '+r' '/etc/lightdm/lightdm.conf'])
|
2015-02-18 15:20:02 +01:00
|
|
|
if default_desktop_environment is not None:
|
2014-08-11 14:28:50 +02:00
|
|
|
os.system(
|
2015-02-18 16:03:57 +01:00
|
|
|
"sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format(
|
|
|
|
default_desktop_environment.desktop_file, root_mount_point))
|
2014-08-11 13:23:12 +02:00
|
|
|
else:
|
2014-11-29 17:14:17 +01:00
|
|
|
libcalamares.utils.debug("lightdm selected but not installed")
|
|
|
|
displaymanagers.remove("lightdm")
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
# Setup gdm
|
|
|
|
if "gdm" in displaymanagers:
|
2014-12-05 22:20:54 +01:00
|
|
|
if have_dm("gdm", root_mount_point):
|
2014-12-01 03:14:33 +01:00
|
|
|
if enable_basic_setup:
|
2014-12-01 03:20:55 +01:00
|
|
|
if libcalamares.utils.chroot_call(['getent', 'group', 'gdm']) != 0:
|
|
|
|
libcalamares.utils.chroot_call(['groupadd', '-g', '120', 'gdm'])
|
|
|
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'gdm']) != 0:
|
2015-02-18 16:03:57 +01:00
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['useradd', '-c', '"Gnome Display Manager"',
|
|
|
|
'-u', '120', '-g', 'gdm', '-d', '/var/lib/gdm',
|
|
|
|
'-s', '/usr/bin/nologin', 'gdm'])
|
2014-12-01 03:14:33 +01:00
|
|
|
libcalamares.utils.chroot_call(['passwd', '-l', 'gdm'])
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['chown', '-R', 'gdm:gdm', '/var/lib/gdm'])
|
2014-08-11 13:23:12 +02:00
|
|
|
else:
|
2014-11-29 17:14:17 +01:00
|
|
|
libcalamares.utils.debug("gdm selected but not installed")
|
|
|
|
displaymanagers.remove("gdm")
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
# Setup mdm
|
|
|
|
if "mdm" in displaymanagers:
|
2014-12-05 22:20:54 +01:00
|
|
|
if have_dm("mdm", root_mount_point):
|
2014-12-01 03:14:33 +01:00
|
|
|
if enable_basic_setup:
|
2014-12-01 03:20:55 +01:00
|
|
|
if libcalamares.utils.chroot_call(['getent', 'group', 'mdm']) != 0:
|
|
|
|
libcalamares.utils.chroot_call(['groupadd', '-g', '128', 'mdm'])
|
|
|
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'mdm']) != 0:
|
2015-02-18 16:03:57 +01:00
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['useradd', '-c', '"Linux Mint Display Manager"',
|
|
|
|
'-u', '128', '-g', 'mdm', '-d', '/var/lib/mdm',
|
|
|
|
'-s', '/usr/bin/nologin', 'mdm'])
|
2014-12-01 03:14:33 +01:00
|
|
|
libcalamares.utils.chroot_call(['passwd', '-l', 'mdm'])
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['chown', 'root:mdm', '/var/lib/mdm'])
|
|
|
|
libcalamares.utils.chroot_call(['chmod', '1770', '/var/lib/mdm'])
|
2015-02-18 15:20:02 +01:00
|
|
|
if default_desktop_environment is not None:
|
2014-08-11 14:28:50 +02:00
|
|
|
os.system(
|
2015-02-18 16:03:57 +01:00
|
|
|
"sed -i \"s|default.desktop|{!s}.desktop|g\" {!s}/etc/mdm/custom.conf".format(
|
|
|
|
default_desktop_environment.desktop_file, root_mount_point))
|
2014-08-11 13:23:12 +02:00
|
|
|
else:
|
2014-11-29 17:14:17 +01:00
|
|
|
libcalamares.utils.debug("mdm selected but not installed")
|
|
|
|
displaymanagers.remove("mdm")
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
# Setup lxdm
|
|
|
|
if "lxdm" in displaymanagers:
|
2014-12-05 22:20:54 +01:00
|
|
|
if have_dm("lxdm", root_mount_point):
|
2014-12-01 03:14:33 +01:00
|
|
|
if enable_basic_setup:
|
2014-12-01 03:20:55 +01:00
|
|
|
if libcalamares.utils.chroot_call(['getent', 'group', 'lxdm']) != 0:
|
|
|
|
libcalamares.utils.chroot_call(['groupadd', '--system', 'lxdm'])
|
2014-12-01 03:14:33 +01:00
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['chgrp', '-R', 'lxdm', '/var/lib/lxdm'])
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['chgrp', 'lxdm', '/etc/lxdm/lxdm.conf'])
|
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['chmod', '+r', '/etc/lxdm/lxdm.conf'])
|
2015-02-18 15:20:02 +01:00
|
|
|
if default_desktop_environment is not None:
|
2014-08-11 14:28:50 +02:00
|
|
|
os.system(
|
2015-02-18 16:03:57 +01:00
|
|
|
"sed -i -e \"s|^.*session=.*|session={!s}|\" {!s}/etc/lxdm/lxdm.conf".format(
|
|
|
|
default_desktop_environment.executable, root_mount_point))
|
2014-08-11 13:23:12 +02:00
|
|
|
else:
|
2014-11-29 17:14:17 +01:00
|
|
|
libcalamares.utils.debug("lxdm selected but not installed")
|
|
|
|
displaymanagers.remove("lxdm")
|
2014-08-11 13:23:12 +02:00
|
|
|
|
|
|
|
# Setup kdm
|
|
|
|
if "kdm" in displaymanagers:
|
2014-12-05 22:20:54 +01:00
|
|
|
if have_dm("kdm", root_mount_point):
|
2014-12-01 03:14:33 +01:00
|
|
|
if enable_basic_setup:
|
2014-12-01 03:20:55 +01:00
|
|
|
if libcalamares.utils.chroot_call(['getent', 'group', 'kdm']) != 0:
|
|
|
|
libcalamares.utils.chroot_call(['groupadd', '-g', '135', 'kdm'])
|
|
|
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'kdm']) != 0:
|
2015-02-18 16:03:57 +01:00
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['useradd', '-u', '135', '-g', 'kdm', '-d',
|
|
|
|
'/var/lib/kdm', '-s', '/bin/false', '-r', '-M', 'kdm'])
|
2014-12-01 03:14:33 +01:00
|
|
|
libcalamares.utils.chroot_call(
|
|
|
|
['chown', '-R', '135:135', 'var/lib/kdm'])
|
2014-08-11 13:23:12 +02:00
|
|
|
else:
|
2014-11-29 17:14:17 +01:00
|
|
|
libcalamares.utils.debug("kdm selected but not installed")
|
|
|
|
displaymanagers.remove("kdm")
|
2014-08-11 13:23:12 +02:00
|
|
|
|
2015-02-18 15:20:02 +01:00
|
|
|
if username is not None:
|
2014-08-11 14:28:50 +02:00
|
|
|
libcalamares.utils.debug(
|
2015-02-17 14:38:30 +01:00
|
|
|
"Setting up autologin for user {!s}.".format(username))
|
2015-02-25 13:01:35 +01:00
|
|
|
else:
|
2015-02-25 17:54:38 +01:00
|
|
|
libcalamares.utils.debug("Unsetting autologin.")
|
2015-02-25 13:01:35 +01:00
|
|
|
|
2015-02-25 17:54:38 +01:00
|
|
|
return set_autologin(username, displaymanagers, default_desktop_environment, root_mount_point)
|