| 1 |
#! /bin/sh |
| 2 |
# postinst script for nodm, partially based on gdm3.postinst |
| 3 |
|
| 4 |
set -e |
| 5 |
|
| 6 |
THIS_PACKAGE=nodm |
| 7 |
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager |
| 8 |
|
| 9 |
. /usr/share/debconf/confmodule |
| 10 |
|
| 11 |
# debconf is not a registry, so we only fiddle with the default file if |
| 12 |
# the configure script requested an update |
| 13 |
if [ -e $DEFAULT_DISPLAY_MANAGER_FILE.debconf-update ]; then |
| 14 |
rm -f $DEFAULT_DISPLAY_MANAGER_FILE.debconf-update |
| 15 |
if db_get shared/default-x-display-manager; then |
| 16 |
# workaround debconf passthru bug (#379198) |
| 17 |
if [ -z "$RET" ]; then |
| 18 |
RET="$THIS_PACKAGE" |
| 19 |
fi |
| 20 |
if [ "$THIS_PACKAGE" != "$RET" ]; then |
| 21 |
echo "Please be sure to run \"dpkg --configure $RET\"." >&2 |
| 22 |
fi |
| 23 |
if db_get "$RET"/daemon_name; then |
| 24 |
echo "$RET" > $DEFAULT_DISPLAY_MANAGER_FILE |
| 25 |
fi |
| 26 |
fi |
| 27 |
fi |
| 28 |
|
| 29 |
DEFAULT_SERVICE=/etc/systemd/system/display-manager.service |
| 30 |
# set default-display-manager systemd service link according to our config |
| 31 |
if [ "$1" = configure ] && [ -d /etc/systemd/system/ ]; then |
| 32 |
if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then |
| 33 |
SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service |
| 34 |
if [ -h "$DEFAULT_SERVICE" ] && [ $(readlink "$DEFAULT_SERVICE") = /dev/null ]; then |
| 35 |
echo "Display manager service is masked" >&2 |
| 36 |
elif [ -e "$SERVICE" ]; then |
| 37 |
ln -sf "$SERVICE" "$DEFAULT_SERVICE" |
| 38 |
else |
| 39 |
echo "WARNING: $SERVICE is the selected default display manager but does not exist" >&2 |
| 40 |
rm -f "$DEFAULT_SERVICE" |
| 41 |
fi |
| 42 |
else |
| 43 |
rm -f "$DEFAULT_SERVICE" |
| 44 |
fi |
| 45 |
fi |
| 46 |
|
| 47 |
if [ "$1" = "configure" ] ; then |
| 48 |
if [ -n "$2" ] && dpkg --compare-versions "$2" lt "0.2"; then |
| 49 |
# Before version 0.2, nodm was only used on the OpenMoko. To |
| 50 |
# guarantee a smooth upgrade, we can safely override debconf here |
| 51 |
# using the openmoko parameters. |
| 52 |
db_set nodm/enabled true |
| 53 |
db_set nodm/first_vt "3" |
| 54 |
db_set nodm/x_options "-nolisten tcp" |
| 55 |
fi |
| 56 |
if [ -n "$2" ] && dpkg --compare-versions "$2" lt "0.5"; then |
| 57 |
# Add the NODM_FIRST_VT entry to the config file if it is missing |
| 58 |
if [ -s /etc/default/nodm ] && ! grep -q NODM_FIRST_VT /etc/default/nodm |
| 59 |
then |
| 60 |
cat <<EOF >> /etc/default/nodm |
| 61 |
|
| 62 |
# First vt to try when looking for free VTs |
| 63 |
NODM_FIRST_VT=7 |
| 64 |
EOF |
| 65 |
fi |
| 66 |
fi |
| 67 |
|
| 68 |
# Update /etc/default/nodm |
| 69 |
db_get nodm/enabled |
| 70 |
NODM_ENABLED="$RET" |
| 71 |
db_get nodm/user |
| 72 |
NODM_USER="$RET" |
| 73 |
db_get nodm/first_vt |
| 74 |
NODM_FIRST_VT="$RET" |
| 75 |
db_get nodm/x_options |
| 76 |
NODM_X_OPTIONS="$RET" |
| 77 |
db_get nodm/min_session_time |
| 78 |
NODM_MIN_SESSION_TIME="$RET" |
| 79 |
db_get nodm/xsession |
| 80 |
NODM_XSESSION="$RET" |
| 81 |
db_get nodm/x_timeout |
| 82 |
NODM_X_TIMEOUT="$RET" |
| 83 |
|
| 84 |
if [ -s /etc/default/nodm ] ; then |
| 85 |
sed -i -r -e "s,^NODM_ENABLED=.*,NODM_ENABLED=$NODM_ENABLED," \ |
| 86 |
-e "s,^NODM_USER=.*,NODM_USER=$NODM_USER," \ |
| 87 |
-e "s,^NODM_FIRST_VT=.*,NODM_FIRST_VT='$NODM_FIRST_VT'," \ |
| 88 |
-e "s,^NODM_X_OPTIONS=.*,NODM_X_OPTIONS='$NODM_X_OPTIONS'," \ |
| 89 |
-e "s,^NODM_MIN_SESSION_TIME=.*,NODM_MIN_SESSION_TIME=$NODM_MIN_SESSION_TIME," \ |
| 90 |
-e "s,^NODM_XSESSION=.*,NODM_XSESSION=$NODM_XSESSION," \ |
| 91 |
-e "s,^NODM_X_TIMEOUT=.*,NODM_X_TIMEOUT=$NODM_X_TIMEOUT," \ |
| 92 |
/etc/default/nodm |
| 93 |
else |
| 94 |
cat <<EOF > /etc/default/nodm |
| 95 |
# nodm configuration |
| 96 |
|
| 97 |
# Set NODM_ENABLED to something different than 'false' to enable nodm |
| 98 |
NODM_ENABLED=$NODM_ENABLED |
| 99 |
|
| 100 |
# User to autologin for |
| 101 |
NODM_USER=$NODM_USER |
| 102 |
|
| 103 |
# First vt to try when looking for free VTs |
| 104 |
NODM_FIRST_VT=$NODM_FIRST_VT |
| 105 |
|
| 106 |
# X session |
| 107 |
NODM_XSESSION=$NODM_XSESSION |
| 108 |
|
| 109 |
# Options for nodm itself |
| 110 |
NODM_OPTIONS= |
| 111 |
|
| 112 |
# Options for the X server. |
| 113 |
# |
| 114 |
# Format: [/usr/bin/<Xserver>] [:<disp>] <Xserver-options> |
| 115 |
# |
| 116 |
# The Xserver executable and the display name can be omitted, but should |
| 117 |
# be placed in front, if nodm's defaults shall be overridden. |
| 118 |
NODM_X_OPTIONS='$NODM_X_OPTIONS' |
| 119 |
|
| 120 |
# If an X session will run for less than this time in seconds, nodm will wait an |
| 121 |
# increasing bit of time before restarting the session. |
| 122 |
NODM_MIN_SESSION_TIME=$NODM_MIN_SESSION_TIME |
| 123 |
|
| 124 |
# Timeout (in seconds) to wait for X to be ready to accept connections. If X is |
| 125 |
# not ready before this timeout, it is killed and restarted. |
| 126 |
NODM_X_TIMEOUT=$NODM_X_TIMEOUT |
| 127 |
EOF |
| 128 |
fi |
| 129 |
fi |
| 130 |
|
| 131 |
#DEBHELPER# |
| 132 |
|
| 133 |
# tell debconf we are done. otherwise, it hangs waiting for the daemon. |
| 134 |
db_stop; |
| 135 |
|
| 136 |
if [ "$1" = configure ] && [ -n "$2" ]; then |
| 137 |
touch /var/run/reboot-required || true |
| 138 |
fi |
| 139 |
|
| 140 |
exit 0 |