home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / etc / gdm / XKeepsCrashing < prev    next >
Encoding:
Text File  |  2009-04-03  |  4.1 KB  |  149 lines

  1. #!/bin/sh
  2.  
  3. if test "x$UNSAFE_TO_TRANSLATE" = "xyes" ; then
  4.   LANG=C
  5.   unset LC_ALL
  6.   unset LC_MESSAGES
  7. fi
  8.  
  9. if test -x "$LIBEXECDIR/gdmtranslate" ; then
  10.   GDMTRANSLATE="$LIBEXECDIR/gdmtranslate"
  11. else
  12.   GDMTRANSLATE=
  13. fi
  14.  
  15. # Set the console to UTF-8 if needed.
  16. CHARMAP=`locale charmap`
  17. if test "$CHARMAP" = "UTF-8"
  18. then
  19.   unicode_start 2> /dev/null || true
  20. else
  21.   unicode_stop 2> /dev/null || true
  22. fi
  23.  
  24. gettextfunc () {
  25.   if test "x$GDMTRANSLATE" != "x" ; then
  26.     "$GDMTRANSLATE" "$1"
  27.   else
  28.     echo "$1"
  29.   fi
  30. }
  31.  
  32. OLD_IFS=$IFS
  33.  
  34. gdmwhich () {
  35.   COMMAND="$1"
  36.   OUTPUT=
  37.   IFS=:
  38.   for dir in $PATH
  39.   do
  40.     if test -x "$dir/$COMMAND" ; then
  41.       if test "x$OUTPUT" = "x" ; then
  42.         OUTPUT="$dir/$COMMAND"
  43.       fi
  44.     fi
  45.   done
  46.   IFS=$OLD_IFS
  47.   echo "$OUTPUT"
  48. }
  49.  
  50. # X has a bad habit of not restoring the vt settings on exit.  Make sure that
  51. # the keyboard is restored to xlate mode, since we're going to try to interact
  52. # with the user
  53. # (http://bugzilla.ubuntu.com/show_bug.cgi?id=6286)
  54. KBD_MODE=`gdmwhich kbd_mode`
  55. if test "x$KBD_MODE" != "x" ; then
  56.   kbd_mode -a
  57. fi
  58.  
  59. 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."`
  60. MSG4=`gettextfunc "Would you like to try to configure the X server?  Note that you will need the root password for this."`
  61. MSG5=`gettextfunc "Please type in the root (privileged user) password."`
  62. MSG6=`gettextfunc "Trying to restart the X server."`
  63. MSG7=`gettextfunc "The X server is now disabled.  Restart GDM when it is configured correctly."`
  64. 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?"`
  65. MSG9=`gettextfunc "Would you like to view the detailed X server output as well?"`
  66.  
  67. # there are some env vars defined:
  68. # XLOG = the log file for the X server
  69. # BINDIR = location of gdm binaries
  70. # SBINDIR = location of gdm system binaries
  71. # LIBEXECDIR = location of gdm libexec binaries (gdmaskpass, gdmopen)
  72.  
  73. # return values are
  74. # 0 = try again, runs this server again
  75. # 1 = abort this display, removes this server from the list
  76. # 32 = something went very wrong, things will just get logged.
  77. #      this means this script didnt work so do alternative things
  78. #      to tell the user if possible
  79.  
  80. #
  81. # Now we check for dialog and gdmaskpass
  82. #
  83. DIALOG_OPTS=
  84. DIALOG=`gdmwhich dialog`
  85. if test "x$DIALOG" = "x" ; then
  86.   DIALOG=`gdmwhich whiptail`
  87.   DIALOG_OPTS="--scrolltext"
  88. fi
  89. if test -x "$LIBEXECDIR/gdmaskpass" ; then
  90.   ASKPASS="$LIBEXECDIR/gdmaskpass"
  91. else
  92.   ASKPASS=
  93. fi
  94.  
  95. # we require 'gdmopen', to open a console, because we really dont
  96. # have one.  Perhaps someone should try to figure out some shell
  97. # black magic to get this to work on other then linux systems
  98. if test ! -x "$LIBEXECDIR/gdmopen" ; then
  99.   exit 32
  100. fi
  101.  
  102. # when we run ourselves from the open we will pass a -noopen argument
  103. if test "x$1" = "x-noopen" ; then
  104.   shift
  105. else
  106.   #
  107.   # We do a lot of work wastefully over again, but oh well,
  108.   # perhaps this needs fixing.
  109.   #
  110.   "$LIBEXECDIR/gdmopen" -l /bin/sh -c "$0 -noopen $@"
  111.   exit $?
  112. fi
  113.  
  114. clear
  115.  
  116. # Note, dialog required, though this script could be fixed to not require it
  117. # I suppose
  118. if test "x" = "x$DIALOG" ; then
  119.   echo =======================================================================
  120.   echo 
  121.   cat "$XLOG"
  122.   echo 
  123.   echo =======================================================================
  124.   echo
  125.   if test -x /usr/bin/fmt ; then
  126.     echo  "$MSG3" | /usr/bin/fmt
  127.   else
  128.     echo  "$MSG3"
  129.   fi
  130.   echo
  131.   echo =======================================================================
  132.   read
  133.   exit 1
  134. fi
  135.  
  136. if "$DIALOG" --yesno "$MSG8" 10 50 ; then 
  137.   "$DIALOG" $DIALOG_OPTS --textbox "$XLOG" 22 76
  138.   # Support XFree86 v4 logfile thingie
  139.   if grep '^(..) Log file: "' "$XLOG" 2> /dev/null ; then
  140.     XLOG_DETAIL=`grep '^(..) Log file: "' "$XLOG" | sed 's/^[^"]*"\([^"]*\)".*$/\1/'`
  141.     if "$DIALOG" --yesno "$MSG9" 10 50 ; then 
  142.       "$DIALOG" $DIALOG_OPTS --textbox "$XLOG_DETAIL" 22 76
  143.     fi
  144.   fi
  145. fi
  146.  
  147. "$DIALOG" --msgbox "$MSG7" 8 50
  148. exit 1
  149.