Add changes done by Klaumi Klingsporn <klaumikli@gmx.de>.
[debian/lxdm.git] / debian / lxdm.postinst
CommitLineData
6da61772
DB
1#!/bin/sh
2# Debian lxdm package post-installation script
3# Based on xdm.postinst
4# Copyright 1998-2001, 2003, 2004 Branden Robinson.
5# Licensed under the GNU General Public License, version 2. See the file
6# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
7# Acknowledgements to Stephen Early, Mark Eichin, and Manoj Srivastava.
8
9
10set -e
11
12# source debconf library
13. /usr/share/debconf/confmodule
14
15THIS_PACKAGE=lxdm
16
17DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
18
19# debconf is not a registry, so we only fiddle with the default file if it
20# does not exist
21if ! [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
22 DEFAULT_DISPLAY_MANAGER=
23 if db_get shared/default-x-display-manager; then
24 DEFAULT_DISPLAY_MANAGER="$RET"
25 fi
26 if [ -n "$DEFAULT_DISPLAY_MANAGER" ]; then
27 DAEMON_NAME=
28 if db_get "$DEFAULT_DISPLAY_MANAGER"/daemon_name; then
29 DAEMON_NAME="$RET"
30 fi
31 if [ -z "$DAEMON_NAME" ]; then
32 # if we were unable to determine the name of the selected daemon (for
33 # instance, if the selected default display manager doesn't provide a
34 # daemon_name question), guess
35 DAEMON_NAME=$(which "$DEFAULT_DISPLAY_MANAGER" 2>/dev/null)
36 fi
37 if [ -n "$DAEMON_NAME" ]; then
38 echo "$DAEMON_NAME" > "$DEFAULT_DISPLAY_MANAGER_FILE"
39 fi
40 fi
41fi
42
43# Registering the init scripts or starting the daemon may cause output to
44# stdout, which can confuse debconf.
400ad8c1
AG
45db_stop || true
46
47# update-rc.d levels (stolen from lightdm)
48S=30
49K=01
50
51if [ -x /etc/init.d/lxdm ]; then
52 update-rc.d lxdm defaults $S $K >/dev/null 2>&1
53fi
54
55if [ "$1" = "configure" ];
56then
57 invoke-rc.d dbus reload || true
58
59# set default-display-manager systemd service link according to our config (stolen from lightdm)
60 if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" -a -d /etc/systemd/system/ ]; then
61 SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service
62 if [ -e "$SERVICE" ]; then
63 ln -sf "$SERVICE" /etc/systemd/system/display-manager.service
64 else
65 echo "ERROR: $SERVICE is the selected default display manager but does not exist" >&2
66 fi
67 fi
68fi
6da61772
DB
69
70# Remove alternative file if it's not a symlink, workaround for broken upgrade
71# See bug #616188
72if [ -f /etc/alternatives/lxdm.conf ] ; then
73 if [ ! -h "/etc/alternatives/lxdm.conf" ] ; then
74 rm "/etc/alternatives/lxdm.conf"
75 fi
76fi
77
78# Add /etc/lxdm/lxdm.conf from alternative of lxdm configuration
79if [ "$1" = configure ]; then
80 update-alternatives --install /etc/lxdm/default.conf \
81 lxdm.conf /etc/lxdm/lxdm.conf 50
82fi
83
84#DEBHELPER#
85
86exit 0