]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - debian/lightdm.postinst
Load all users only when really needed
[sojka/lightdm.git] / debian / lightdm.postinst
1 #!/bin/sh
2
3 set -e
4
5 if dpkg-maintscript-helper supports mv_conffile; then
6   dpkg-maintscript-helper mv_conffile \
7     /etc/lightdm.conf \
8     /etc/lightdm/lightdm.conf \
9     0.3.7-0ubuntu2 -- "$@"
10 fi    
11
12 . /usr/share/debconf/confmodule
13
14 THIS_PACKAGE=lightdm
15 DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
16
17 # creating lightdm group if he isn't already there
18 if ! getent group lightdm >/dev/null; then
19         addgroup --system lightdm
20 fi
21
22 # creating lightdm user if he isn't already there
23 if ! getent passwd lightdm >/dev/null; then
24         adduser --system --ingroup lightdm --home /var/lib/lightdm lightdm
25         usermod -c "Light Display Manager" lightdm
26         usermod -d "/var/lib/lightdm"      lightdm
27         usermod -g "lightdm"               lightdm
28         usermod -s "/bin/false"            lightdm
29 fi
30
31 # Creating nopasswdlogin group if he isn't already there.
32 # That enables the password-less login feature in the users-admin
33 # tool of the gnome-system-tools for users that belong to it,
34 # and which is working thanks to LightDM's PAM policy.
35 if ! getent group nopasswdlogin >/dev/null; then
36         addgroup --system nopasswdlogin
37 fi
38
39 if [ -d /var/lib/lightdm ]; then
40   chown -R lightdm:lightdm /var/lib/lightdm || true
41   chmod 0750 /var/lib/lightdm
42 fi
43
44 # debconf is not a registry, so we only fiddle with the default file if it
45 # does not exist
46 if ! [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
47   DEFAULT_DISPLAY_MANAGER=
48   if db_get shared/default-x-display-manager; then
49     DEFAULT_DISPLAY_MANAGER="$RET"
50   fi
51   if [ -n "$DEFAULT_DISPLAY_MANAGER" ]; then
52     DAEMON_NAME=
53     if db_get "$DEFAULT_DISPLAY_MANAGER"/daemon_name; then
54       DAEMON_NAME="$RET"
55     fi
56     if [ -z "$DAEMON_NAME" ]; then
57       # if we were unable to determine the name of the selected daemon (for
58       # instance, if the selected default display manager doesn't provide a
59       # daemon_name question), guess
60       DAEMON_NAME=$(which "$DEFAULT_DISPLAY_MANAGER" 2>/dev/null)
61     fi
62     if [ -n "$DAEMON_NAME" ]; then
63       echo "$DAEMON_NAME" > "$DEFAULT_DISPLAY_MANAGER_FILE"
64     fi
65   fi
66 fi
67
68 # Registering the init scripts or starting the daemon may cause output to
69 # stdout, which can confuse debconf.
70 db_stop
71
72 DEFAULT_SERVICE=/etc/systemd/system/display-manager.service
73 # set default-display-manager systemd service link according to our config
74 if [ "$1" = configure ] && [ -d /etc/systemd/system/ ]; then
75   if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
76     SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service
77     if [ -h "$DEFAULT_SERVICE" ] && [ $(readlink "$DEFAULT_SERVICE") = /dev/null ]; then
78       echo "Display manager service is masked" >&2
79     elif [ -e "$SERVICE" ]; then
80       ln -sf "$SERVICE" "$DEFAULT_SERVICE"
81     else
82       echo "WARNING: $SERVICE is the selected default display manager but does not exist" >&2
83       rm -f "$DEFAULT_SERVICE"
84     fi
85   else
86     rm -f "$DEFAULT_SERVICE"
87   fi
88 fi
89
90 case "$1" in
91     configure)
92         # LP: #1189948
93         if dpkg --compare-versions "$2" lt "1.7.0-0ubuntu6" ; then
94             if [ -f /etc/apparmor.d/abstractions/lightdm ]; then
95                 chmod 0644 /etc/apparmor.d/abstractions/lightdm || true
96             fi
97             if [ -f /etc/apparmor.d/abstractions/lightdm_chromium-browser ]; then
98                 chmod 0644 /etc/apparmor.d/abstractions/lightdm_chromium-browser || true
99             fi
100         fi
101         ;;
102 esac
103
104 #DEBHELPER#
105
106 exit 0