summaryrefslogtreecommitdiff
path: root/config/XKeepsCrashing
blob: 5b7c4a884f641599779f33abf0aea8ff617f2944 (plain)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/bin/sh

if test "x$UNSAFE_TO_TRANSLATE" = "xyes" ; then
  LANG=C
  unset LC_ALL
  unset LC_MESSAGES
fi

if test -x "$LIBEXECDIR/gdmtranslate" ; then
  GDMTRANSLATE="$LIBEXECDIR/gdmtranslate"
else
  GDMTRANSLATE=
fi

gettextfunc () {
  if test "x$GDMTRANSLATE" != "x" ; then
    "$GDMTRANSLATE" "$1"
  else
    echo "$1"
  fi
}

OLD_IFS=$IFS

gdmwhich () {
  COMMAND="$1"
  OUTPUT=
  IFS=:
  for dir in $PATH
  do
    if test -x "$dir/$COMMAND" ; then
      if test "x$OUTPUT" = "x" ; then
        OUTPUT="$dir/$COMMAND"
      fi
    fi
  done
  IFS=$OLD_IFS
  echo "$OUTPUT"
}

MSG3=`gettextfunc "Failed to start the X server (your graphical interface).  It is likely that it is not set up correctly.  You will need to log in on a console and reconfigure the X server.  Then restart GDM."`
MSG4=`gettextfunc "Would you like to try to configure the X server?  Note that you will need the root password for this."`
MSG5=`gettextfunc "Please type in the root (privileged user) password."`
MSG6=`gettextfunc "Trying to restart the X server."`
MSG7=`gettextfunc "The X server is now disabled.  Restart GDM when it is configured correctly."`
MSG8=`gettextfunc "Failed to start the X server (your graphical interface).  It is likely that it is not set up correctly.  Would you like to view the X server output to diagnose the problem?"`
MSG9=`gettextfunc "Would you like to view the detailed X server output as well?"`

# there are some env vars defined:
# XLOG = the log file for the X server
# BINDIR = location of gdm binaries
# SBINDIR = location of gdm system binaries
# LIBEXECDIR = location of gdm libexec binaries (gdmaskpass, gdmopen)

# return values are
# 0 = try again, runs this server again
# 1 = abort this display, removes this server from the list
# 32 = something went very wrong, things will just get logged.
#      this means this script didnt work so do alternative things
#      to tell the user if possible

#
# First see if we can find an X configuration program
#  (first one in the list will be used)
#
XCONFIGURATOR=
for n in \
  /usr/bin/system-config-display \
  /usr/bin/redhat-config-xfree86 \
  /usr/sbin/XFdrake		 \
  /usr/bin/X11/XF86Setup	 \
  /usr/bin/X11/Xconfigurator	 \
  /usr/bin/X11/xf86cfg		 \
   ; do
  # standard shell test has no or and loops have no breaks, eek
  if test "x$XCONFIGURATOR" = "x" ; then
    if test -x "$n" ; then
      XCONFIGURATOR="$n"
    fi
  fi
done

#
# Now we check for dialog and gdmaskpass
#
DIALOG=`gdmwhich dialog`
if test "x$DIALOG" = "x" ; then
  DIALOG=`gdmwhich whiptail`
fi
if test -x "$LIBEXECDIR/gdmaskpass" ; then
  ASKPASS="$LIBEXECDIR/gdmaskpass"
else
  ASKPASS=
fi

#
#  If this is a mouse problem try mouseconfig and modify some
#  messages
#
if grep '^\(Cannot open mouse\|No core pointer\)' "$XLOG" 2> /dev/null ; then

  MSG8=`gettextfunc "Failed to start the X server (your graphical interface).  It seems that the pointer device (your mouse) is not set up correctly.  Would you like to view the X server output to diagnose the problem?"`

  if test -x /usr/sbin/mouseconfig ; then
    XCONFIGURATOR=/usr/sbin/mouseconfig
    # Note: we know this is a mouse problem and yay we have mouseconfig
    MSG4=`gettextfunc "Would you like to try to configure the mouse?  Note that you will need the root password for this."`
  fi

  if test -x /usr/bin/system-config-mouse ; then
    XCONFIGURATOR=/usr/bin/system-config-mouse
    # Note: we know this is a mouse problem and yay we have system-config-mouse
    MSG4=`gettextfunc "Would you like to try to configure the mouse?  Note that you will need the root password for this."`
  fi

fi

# we require 'gdmopen', to open a console, because we really dont
# have one.  Perhaps someone should try to figure out some shell
# black magic to get this to work on other then linux systems
if test ! -x "$LIBEXECDIR/gdmopen" ; then
  exit 32
fi

# when we run ourselves from the open we will pass a -noopen argument
if test "x$1" = "x-noopen" ; then
  shift
else
  #
  # We do a lot of work wastefully over again, but oh well,
  # perhaps this needs fixing.
  #
  "$LIBEXECDIR/gdmopen" -l /bin/sh -c "$0 -noopen $@"
  exit $?
fi

clear

# Note, dialog required, though this script could be fixed to not require it
# I suppose
if test "x" = "x$DIALOG" ; then
  echo =======================================================================
  echo 
  cat "$XLOG"
  echo 
  echo =======================================================================
  echo
  if test -x /usr/bin/fmt ; then
    echo  "$MSG3" | /usr/bin/fmt
  else
    echo  "$MSG3"
  fi
  echo
  echo =======================================================================
  read
  exit 1
fi

if "$DIALOG" --yesno "$MSG8" 10 50 ; then 
  "$DIALOG" --textbox "$XLOG" 22 76
  # Support XFree86 v4 logfile thingie
  if grep '^(..) Log file: "' "$XLOG" 2> /dev/null ; then
    XLOG_DETAIL=`grep '^(..) Log file: "' "$XLOG" | sed 's/^[^"]*"\([^"]*\)".*$/\1/'`
    if "$DIALOG" --yesno "$MSG9" 10 50 ; then 
      "$DIALOG" --textbox "$XLOG_DETAIL" 22 76
    fi
  fi
fi

if test "x$XCONFIGURATOR" = "x" ; then
  "$DIALOG" --msgbox "$MSG7" 8 50
  exit 1
fi

if "$DIALOG" --yesno "$MSG4" 10 50 ; then 
  clear
  echo
  echo "$MSG5"
  if test "x$ASKPASS" = "x" ; then
    # dirty trick to fool su into asking the root password even if were
    # root
    su nobody -c "su -c $XCONFIGURATOR"
  else
    if "$ASKPASS" ; then
      "$XCONFIGURATOR"
    fi
  fi
  clear
  "$DIALOG" --msgbox "$MSG6" 8 50
  exit 0
else
  "$DIALOG" --msgbox "$MSG7" 8 50
  exit 1
fi