#! /bin/sh # postinst script for nodm, partially based on gdm3.postinst set -e THIS_PACKAGE=nodm DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager . /usr/share/debconf/confmodule # 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\"." >&2 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 if [ "$1" = "configure" ] ; then if [ -n "$2" ] && dpkg --compare-versions "$2" lt "0.2"; then # Before version 0.2, nodm was only used on the OpenMoko. To # guarantee a smooth upgrade, we can safely override debconf here # using the openmoko parameters. db_set nodm/enabled true db_set nodm/first_vt "3" db_set nodm/x_options "-nolisten tcp" fi if [ -n "$2" ] && dpkg --compare-versions "$2" lt "0.5"; then # Add the NODM_FIRST_VT entry to the config file if it is missing if [ -s /etc/default/nodm ] && ! grep -q NODM_FIRST_VT /etc/default/nodm then cat <> /etc/default/nodm # First vt to try when looking for free VTs NODM_FIRST_VT=7 EOF fi fi # Update /etc/default/nodm db_get nodm/enabled NODM_ENABLED="$RET" db_get nodm/user NODM_USER="$RET" db_get nodm/first_vt NODM_FIRST_VT="$RET" db_get nodm/x_options NODM_X_OPTIONS="$RET" db_get nodm/min_session_time NODM_MIN_SESSION_TIME="$RET" db_get nodm/xsession NODM_XSESSION="$RET" db_get nodm/x_timeout NODM_X_TIMEOUT="$RET" if [ -s /etc/default/nodm ] ; then sed -i -r -e "s,^NODM_ENABLED=.*,NODM_ENABLED=$NODM_ENABLED," \ -e "s,^NODM_USER=.*,NODM_USER=$NODM_USER," \ -e "s,^NODM_FIRST_VT=.*,NODM_FIRST_VT='$NODM_FIRST_VT'," \ -e "s,^NODM_X_OPTIONS=.*,NODM_X_OPTIONS='$NODM_X_OPTIONS'," \ -e "s,^NODM_MIN_SESSION_TIME=.*,NODM_MIN_SESSION_TIME=$NODM_MIN_SESSION_TIME," \ -e "s,^NODM_XSESSION=.*,NODM_XSESSION=$NODM_XSESSION," \ -e "s,^NODM_X_TIMEOUT=.*,NODM_X_TIMEOUT=$NODM_X_TIMEOUT," \ /etc/default/nodm else cat < /etc/default/nodm # nodm configuration # Set NODM_ENABLED to something different than 'false' to enable nodm NODM_ENABLED=$NODM_ENABLED # User to autologin for NODM_USER=$NODM_USER # First vt to try when looking for free VTs NODM_FIRST_VT=$NODM_FIRST_VT # X session NODM_XSESSION=$NODM_XSESSION # Options for nodm itself NODM_OPTIONS= # Options for the X server. # # Format: [/usr/bin/] [:] # # The Xserver executable and the display name can be omitted, but should # be placed in front, if nodm's defaults shall be overridden. NODM_X_OPTIONS='$NODM_X_OPTIONS' # If an X session will run for less than this time in seconds, nodm will wait an # increasing bit of time before restarting the session. NODM_MIN_SESSION_TIME=$NODM_MIN_SESSION_TIME # Timeout (in seconds) to wait for X to be ready to accept connections. If X is # not ready before this timeout, it is killed and restarted. NODM_X_TIMEOUT=$NODM_X_TIMEOUT EOF fi fi # Automatically added by dh_installinit/13.3.4 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -x "/etc/init.d/nodm" ]; then update-rc.d nodm defaults >/dev/null invoke-rc.d --skip-systemd-native nodm start || exit 1 fi fi # End automatically added section # Automatically added by dh_installsystemd/13.3.4 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true deb-systemd-invoke start 'nodm.service' >/dev/null || true fi fi # End automatically added section # tell debconf we are done. otherwise, it hangs waiting for the daemon. db_stop; if [ "$1" = configure ] && [ -n "$2" ]; then touch /var/run/reboot-required || true fi exit 0