]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - debian/lightdm.postinst
7c8686e1da53606dd4333882e019c40ad8504b2a
[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 case "$1" in
73     configure)
74         # LP: #1189948
75         if dpkg --compare-versions "$2" lt "1.7.0-0ubuntu6" ; then
76             if [ -f /etc/apparmor.d/abstractions/lightdm ]; then
77                 chmod 0644 /etc/apparmor.d/abstractions/lightdm || true
78             fi
79             if [ -f /etc/apparmor.d/abstractions/lightdm_chromium-browser ]; then
80                 chmod 0644 /etc/apparmor.d/abstractions/lightdm_chromium-browser || true
81             fi
82         fi
83
84         # set default-display-manager systemd service link according to our config
85         if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" -a -d /etc/systemd/system/ ]; then
86             SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service
87             if [ -e "$SERVICE" ]; then
88                 ln -sf "$SERVICE" /etc/systemd/system/display-manager.service
89             else
90                 echo "ERROR: $SERVICE is the selected default display manager but does not exist" >&2
91             fi
92         fi
93         ;;
94 esac
95
96 #DEBHELPER#
97
98 exit 0