summaryrefslogtreecommitdiff
path: root/debian/lightdm.postinst
diff options
context:
space:
mode:
Diffstat (limited to 'debian/lightdm.postinst')
-rw-r--r--debian/lightdm.postinst78
1 files changed, 78 insertions, 0 deletions
diff --git a/debian/lightdm.postinst b/debian/lightdm.postinst
new file mode 100644
index 0000000..68f666d
--- /dev/null
+++ b/debian/lightdm.postinst
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+THIS_PACKAGE=lightdm
+DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
+
+# creating lightdm group if he isn't already there
+if ! getent group lightdm >/dev/null; then
+ addgroup --system lightdm
+fi
+
+# creating lightdm user if he isn't already there
+if ! getent passwd lightdm >/dev/null; then
+ adduser --system --ingroup lightdm --home /var/lib/lightdm lightdm
+ usermod -c "Light Display Manager" lightdm
+ usermod -d "/var/lib/lightdm" lightdm
+ usermod -g "lightdm" lightdm
+ usermod -s "/bin/false" lightdm
+fi
+
+mkdir -p /var/lib/lightdm
+chown -R lightdm:lightdm /var/lib/lightdm
+chmod 0750 /var/lib/lightdm
+
+# debconf is not a registry, so we only fiddle with the default file if it
+# does not exist
+if [ ! -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
+ 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
+
+# remove the displaced old default display manager file if it exists
+if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE.dpkg-tmp" ]; then
+ rm "$DEFAULT_DISPLAY_MANAGER_FILE.dpkg-tmp"
+fi
+
+# debconf hangs if lightdm gets started below without this
+db_stop || true
+
+# update-rc.d levels
+S=30
+K=01
+
+if [ -x /etc/init.d/lightdm ]; then
+ update-rc.d lightdm defaults $S $K >/dev/null 2>&1
+fi
+
+if [ "$1" = "configure" ];
+then
+ invoke-rc.d dbus reload || true
+
+ # set default-display-manager systemd service link according to our config
+ if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" -a -d /etc/systemd/system/ ]; then
+ SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service
+ if [ -e "$SERVICE" ]; then
+ ln -sf "$SERVICE" /etc/systemd/system/display-manager.service
+ else
+ echo "ERROR: $SERVICE is the selected default display manager but does not exist" >&2
+ fi
+ fi
+fi
+
+#DEBHELPER#
+
+exit 0