summaryrefslogtreecommitdiffstats
path: root/debian/gdm3.postinst
blob: bcf8366ca1f68ad0eb4377b7fd66e41fce246ae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

set -e

. /usr/share/debconf/confmodule

THIS_PACKAGE=gdm3
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager

# creating Debian-gdm group if it isn't already there
if ! getent group Debian-gdm >/dev/null; then
        addgroup --system --force-badname --quiet Debian-gdm
fi

# creating Debian-gdm user if it isn't already there
if ! getent passwd Debian-gdm >/dev/null; then
        adduser --system --force-badname --quiet \
            --ingroup Debian-gdm \
            --home /var/lib/gdm3 --no-create-home \
            --shell /bin/false \
            Debian-gdm
        usermod -c "Gnome Display Manager" Debian-gdm
fi

# debconf is not a registry, so we only fiddle with the default file if 
# the configure script requested an update
if [ -e $DEFAULT_DISPLAY_MANAGER_FILE.debconf-update ]; then
  rm -f $DEFAULT_DISPLAY_MANAGER_FILE.debconf-update
  if db_get shared/default-x-display-manager; then
    # workaround debconf passthru bug (#379198)
    if [ -z "$RET" ]; then
      RET="$THIS_PACKAGE"
    fi
    if [ "$THIS_PACKAGE" != "$RET" ]; then
      echo "Please be sure to run \"dpkg --configure $RET\"."
    fi
    if db_get "$RET"/daemon_name; then
      echo "$RET" > $DEFAULT_DISPLAY_MANAGER_FILE
    fi
  fi
fi

DEFAULT_SERVICE=/etc/systemd/system/display-manager.service
# set default-display-manager systemd service link according to our config
if [ "$1" = configure ] && [ -d /etc/systemd/system/ ]; then
  if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
    SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service
    if [ -h "$DEFAULT_SERVICE" ] && [ $(readlink "$DEFAULT_SERVICE") = /dev/null ]; then
      echo "Display manager service is masked" >&2
    elif [ -e "$SERVICE" ]; then
      ln -sf "$SERVICE" "$DEFAULT_SERVICE"
    else
      echo "WARNING: $SERVICE is the selected default display manager but does not exist" >&2
      rm -f "$DEFAULT_SERVICE"
    fi
  else
    rm -f "$DEFAULT_SERVICE"
  fi
fi

ucf --debconf-ok --three-way /usr/share/gdm/greeter.dconf-defaults /etc/gdm3/greeter.dconf-defaults
ucfr gdm3 /etc/gdm3/greeter.dconf-defaults

# debconf hangs if gdm3 gets started below without this
db_stop || true

chown -R Debian-gdm:Debian-gdm /var/lib/gdm3

#DEBHELPER#

if [ -x /etc/init.d/gdm3 ]; then
  update-rc.d gdm3 defaults >/dev/null 2>&1
  invoke-rc.d gdm3 reload || true
fi