File: wdm.postinst

package info (click to toggle)
wdm 1.28-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,004 kB
  • ctags: 1,144
  • sloc: ansic: 11,448; sh: 945; makefile: 452; perl: 29; cpp: 10
file content (110 lines) | stat: -rw-r--r-- 3,297 bytes parent folder | download
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
# Debian wdm package post-installation script
# Copyright 2001 Branden Robinson.
# Licensed under the GNU General Public License, version 2.  See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.

set -e

# source debconf library
. /usr/share/debconf/confmodule

THIS_PACKAGE=wdm
THIS_DISPLAY_MANAGER=/usr/bin/X11/wdm
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager

message () {
  # pretty-print messages of arbitrary length
  echo "$*" | fold -s -w ${COLUMNS:-80} >&2;
}

message_nonl () {
  # pretty-print messages of arbitrary length (no trailing newline)
  echo -n "$*" | fold -s -w ${COLUMNS:-80} >&2;
}

errormsg () {
  # exit script with error
  message "$*"
  exit 1;
}

# debconf is not a registry, so we only fiddle with the default file if it
# does not exist
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
if [ ! -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
  DEFAULT_DISPLAY_MANAGER=
  if db_get shared/default-x-display-manager; then
    DEFAULT_DISPLAY_MANAGER="$RET"
  fi
  if [ -n "$DEFAULT_DISPLAY_MANAGER" ]; then
    DAEMON_NAME=
    if db_get "$DEFAULT_DISPLAY_MANAGER"/daemon_name; then
      DAEMON_NAME="$RET"
    fi
    if [ ! -n "$DAEMON_NAME" ]; then
      # if we were unable to determine the name of the selected daemon (for
      # instance, if the selected default display manager doesn't provide a
      # daemon_name question), guess
      DAEMON_NAME=$(which "$DEFAULT_DISPLAY_MANAGER" 2>/dev/null)
      if [ ! -n "$DAEMON_NAME" ]; then
        echo .
        # FIXME - redo this part uses shell-lib.sh from xfree86
        #warn "unable to determine path to default X display manager" \
        #     "$DEFAULT_DISPLAY_MANAGER; not updating" \
        #     "$DEFAULT_DISPLAY_MANAGER_FILE"
      fi
    fi
    if [ -n "$DAEMON_NAME" ]; then
      # FIXME - redo this part uses shell-lib.sh from xfree86
      #observe "committing change of default X display manager"
      echo "$DAEMON_NAME" > "$DEFAULT_DISPLAY_MANAGER_FILE"
    fi
  fi
fi

NOSTART=
WDM_RUNNING=
# don't start wdm if we are upgrading without stopping it
if [ -e /var/run/wdm.upgrade ]; then
  NOSTART=yes
fi
# or if we're currently in X on the display it attempts to manage by default
for HOSTNAME in "" "localhost" "$(hostname)" "$(hostname -f)"; do
  if echo $DISPLAY | grep -q "^$HOSTNAME:0.*"; then
    NOSTART=yes
  fi
done
# or if it's already running
if start-stop-daemon --stop --quiet --signal 0 --pid /var/run/wdm.pid --exec /usr/bin/X11/wdm; then
  NOSTART=yes
  WDM_RUNNING=yes
fi
# or if the options file says not to
if ! grep -qs ^restart-on-upgrade /etc/X11/wdm/wdm.options; then
  NOSTART=yes
fi

if [ -n "$WDM_RUNNING" ]; then
  if [ -d /var/state/wdm ]; then
    message "Note: obsolete directory /var/state/wdm cannot be removed" \
            "because wdm is still running.  Reinstall the wdm package" \
            "(or remove the directory manually) when wdm is not running."
  fi
else
  if [ -d /var/state/wdm ]; then
    rm -r /var/state/wdm
  fi
fi

update_wdm_wmlist
update-rc.d wdm defaults 99 01 > /dev/null 2>&1

# redirect stdout to /dev/tty so debconf doesn't choke on it
[ -n "$NOSTART" ] || /etc/init.d/wdm start > /dev/tty || true

#DEBHELPER#

exit 0

# vim:set ai et sts=2 sw=2 tw=0: