]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - debian/lightdm.postinst
Bring Ubuntu packaging in-branch
[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
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 # migrate gdm configuration on first-time installation
73 if [ -z "$2" ]; then
74     if grep -q '^AutomaticLoginEnable *= *true$' /etc/gdm/custom.conf 2>/dev/null; then
75         user=`sed -n '/^AutomaticLogin *=/ { s/^.*= *//; p }' /etc/gdm/custom.conf`
76         if [ -n "$user" ]; then
77             /usr/lib/lightdm/lightdm-set-defaults --keep-old --autologin="$user"
78         fi
79     fi
80 fi
81
82 case "$1" in
83     configure)
84         # LP: #1189948
85         if dpkg --compare-versions "$2" lt "1.7.0-0ubuntu6" ; then
86             if [ -f /etc/apparmor.d/abstractions/lightdm ]; then
87                 chmod 0644 /etc/apparmor.d/abstractions/lightdm || true
88             fi
89             if [ -f /etc/apparmor.d/abstractions/lightdm_chromium-browser ]; then
90                 chmod 0644 /etc/apparmor.d/abstractions/lightdm_chromium-browser || true
91             fi
92         fi
93         ;;
94 esac
95
96 #DEBHELPER#
97
98 exit 0