]> rtime.felk.cvut.cz Git - sojka/debian/lightdm.git/blob - debian/lightdm.postinst
* debian/control:
[sojka/debian/lightdm.git] / debian / lightdm.postinst
1 #!/bin/sh
2
3 set -e
4
5 . /usr/share/debconf/confmodule
6
7 THIS_PACKAGE=lightdm
8 DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
9
10 # creating lightdm group if he isn't already there
11 if ! getent group lightdm >/dev/null; then
12         addgroup --system lightdm
13 fi
14
15 # creating lightdm user if he isn't already there
16 if ! getent passwd lightdm >/dev/null; then
17         adduser --system --ingroup lightdm --home /var/lib/lightdm lightdm
18         usermod -c "Light Display Manager" lightdm
19         usermod -d "/var/lib/lightdm"      lightdm
20         usermod -g "lightdm"               lightdm
21         usermod -s "/bin/false"            lightdm
22 fi
23
24 if [ -d /var/lib/lightdm ]; then
25   chown -R lightdm:lightdm /var/lib/lightdm
26   chmod 0750 /var/lib/lightdm
27 fi
28
29 # debconf is not a registry, so we only fiddle with the default file if it
30 # does not exist
31 if [ ! -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
32   if db_get shared/default-x-display-manager; then
33     # workaround debconf passthru bug (#379198)
34     if [ -z "$RET" ]; then
35       $RET="$THIS_PACKAGE"
36     fi
37     if [ "$THIS_PACKAGE" != "$RET" ]; then
38       echo "Please be sure to run \"dpkg --configure $RET\"."
39     fi
40     if db_get "$RET"/daemon_name; then
41       echo "$RET" > $DEFAULT_DISPLAY_MANAGER_FILE
42     fi
43   fi
44 fi
45
46 # remove the displaced old default display manager file if it exists
47 if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE.dpkg-tmp" ]; then
48   rm "$DEFAULT_DISPLAY_MANAGER_FILE.dpkg-tmp"
49 fi
50
51 # debconf hangs if lightdm gets started below without this
52 db_stop || true
53
54 # update-rc.d levels
55 S=30
56 K=01
57
58 if [ -x /etc/init.d/lightdm ]; then
59   update-rc.d lightdm defaults $S $K >/dev/null 2>&1
60 fi
61
62 if [ "$1" = "configure" ];
63 then
64   invoke-rc.d dbus reload || true
65
66   # set default-display-manager systemd service link according to our config
67   if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" -a -d /etc/systemd/system/ ]; then
68     SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service
69     if [ -e "$SERVICE" ]; then
70       ln -sf "$SERVICE" /etc/systemd/system/display-manager.service
71     else
72       echo "ERROR: $SERVICE is the selected default display manager but does not exist" >&2
73     fi
74   fi
75 fi
76
77 #DEBHELPER#
78
79 exit 0