home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / update701 / root.18 / usr / X / bin / netscape / netscape
Encoding:
Text File  |  1998-08-18  |  7.2 KB  |  226 lines

  1. #!/bin/sh
  2. #
  3. #       @(#) netscape 14.1 98/03/18 
  4. #
  5. # Copyright (c) 1997 The Santa Cruz Operation, Inc.. All Rights Reserved.
  6. # THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE SANTA CRUZ OPERATION INC.
  7. # The copyright notice above does not evidence any actual or intended
  8. # publication of such source code.
  9. #
  10. # Netscape Navigator wrapper
  11. #
  12. # This is in lieu of a full set of resources in the app-defaults
  13. # file. For instance, this allows our default installation to specify
  14. # a system-wide default home document (working around the fact that
  15. # there is no homeDocument X11 resource for Netscape Navigator).
  16. #
  17.  
  18. # This shell script is set up to automatically start a child browser
  19. # window from an already-running Netscape browser on the desktop.  This can
  20. # save system resources, but can also be confusing - for example, if you
  21. # use this feature and have a 3.0.1 browser running, you will get another
  22. # 3.0.1 window, rather than the 3.0.3 browser that you might expect.  It
  23. # does however improve performance for some configurations, especially
  24. # those where there is no mix of browser releases.  If you want to disable
  25. # this feature, set a value for the env variable NETSCAPE_NOAUTOREMOTE.
  26.  
  27. # Note that the above feature is bypassed if the script is invoked as
  28. # netscape-scohelp.
  29. SCOHELP=0
  30. [ "`basename $0`" = "netscape-scohelp" ] && SCOHELP=1
  31.  
  32. # Set the directory where Java and other support files live
  33. DEF_CLASSPATH=/usr/ns-home/lib/netscape
  34. export DEF_CLASSPATH
  35.  
  36. # if $CLASSPATH not set, then set it to the default location
  37. [ "$CLASSPATH" ] || CLASSPATH=$DEF_CLASSPATH
  38. export CLASSPATH
  39.  
  40. # Set this to the location of the real Netscape executable
  41. REAL_NETSCAPE=$DEF_CLASSPATH/netscape
  42.  
  43. # Set this to the location of the default preferences file.
  44. DEF_PREFS=$DEF_CLASSPATH/default-netscape-preferences
  45.  
  46. # Set this to the location of the default bookmarks.html file.
  47. DEF_BOOKMARKS=$DEF_CLASSPATH/bookmarks.html
  48.  
  49. # Set this to the location of the default address-book.html file.
  50. DEF_ADDRBOOK=$DEF_CLASSPATH/address-book.html
  51.  
  52. # Set this to the location of the default .mailcap and .mime.types files
  53. DEF_MAILCAP=$DEF_CLASSPATH/default-mailcap
  54. DEF_MIMETYPES=$DEF_CLASSPATH/default-mime.types
  55.  
  56. # Timeout in mS for the starting popup
  57. POPUPTIME="20000"
  58.  
  59. # Information for default homepages added to preferences; two different
  60. # pages may be set depending on whether the system is connected to the
  61. # Internet or not.  Set a value for NETSCAPE_INITIALHOMEPAGE to override
  62. # these checks and pages with one of your own choosing
  63. DEF_HOMEPAGE_NOWEB="file:/usr/ns-home/nsnav-html/${LANG:-C}/navhome.html"
  64. if [ ! -f $DEF_HOMEPAGE_NOWEB ]; then
  65.     DEF_HOMEPAGE_NOWEB="file:/usr/ns-home/nsnav-html/C/navhome.html"
  66. fi
  67. DEF_HOMEPAGE_WEBOK="http://www.sco.com/uw7/nav304/home"
  68. TEST_ADDRESS="198.41.0.4"
  69. TEST_TIMEOUT=2
  70. TEST_LOOPS="1 2 3 4 5"
  71. TEST_POPUPTIME="30000"
  72.  
  73. # first check for preferences file, and if it doesn't exist, create it
  74. # with reasonable defaults set for the user invoking it
  75. waiting_popup=0
  76. [ -f $HOME/.netscape/preferences ] || {
  77.     [ -d $HOME/.netscape ] || mkdir -p $HOME/.netscape
  78.     UID=`id -u`
  79.     NID=`id -u -n`
  80.     [ -x "/usr/ucb/hostname" ] && HOST=`/usr/ucb/hostname`
  81.     [ -z "$HOST" ] && HOST="localhost"
  82.     PASSWD_F=/etc/passwd
  83.     GECOS=`egrep -e "^${NID}" "${PASSWD_F}" | awk -F":" '{ print $5 }' | \
  84.             awk -F"," '{ print $1 }' 2>/dev/null`
  85.     [ "$GECOS" ] || GECOS=$NID
  86.     if [ -n "$NETSCAPE_INITIALHOMEPAGE" ]; then
  87.         HOMEPAGE="$NETSCAPE_INITIALHOMEPAGE"
  88.     else
  89.         HOMEPAGE="$DEF_HOMEPAGE_NOWEB"
  90.         if [ -x /usr/X/bin/net_hello -a -x /bin/vtcl \
  91.                 -a $SCOHELP -eq 0 ]; then
  92.             /usr/X/bin/net_hello $TEST_POPUPTIME &
  93.             waiting_popup=1
  94.         fi
  95.         for i in $TEST_LOOPS; do
  96.             response="`/usr/sbin/ping -n $TEST_ADDRESS $TEST_TIMEOUT 2>&1`"
  97.             case "$response" in
  98.             *alive)
  99.                 HOMEPAGE="$DEF_HOMEPAGE_WEBOK"
  100.                 break ;;
  101.             esac
  102.         done
  103.     fi
  104.     cat $DEF_PREFS | sed -e "s/__uid__/$UID/g" -e "s/__nid__/$NID/g" \
  105.             -e "s/__gecos__/$GECOS/g" -e "s/__host__/$HOST/g" \
  106.             -e "s@__homepage__@$HOMEPAGE@g" \
  107.             > $HOME/.netscape/preferences
  108.     [ -d $HOME/.netscape/cache ] || mkdir -p $HOME/.netscape/cache
  109. }
  110.  
  111. # if no mailcap or mime.types files then put default ones in
  112. [ -f $HOME/.mailcap ] || {
  113.     cp $DEF_MAILCAP $HOME/.mailcap
  114. }
  115. [ -f $HOME/.mime.types ] || {
  116.     cp $DEF_MIMETYPES $HOME/.mime.types
  117. }
  118.  
  119. # next, check for bookmarks.html file, and if it doesn't exist, create it
  120. # with SCO supplied bookmark list...
  121. [ -f $HOME/.netscape/bookmarks.html ] || {
  122.     [ -d $HOME/.netscape ] || mkdir -p $HOME/.netscape
  123.     NID=`id -u -n`
  124.     PASSWD_F=/etc/passwd
  125.     GECOS=`egrep -e "^${NID}" "${PASSWD_F}" | awk -F":" '{ print $5 }' \
  126.             | awk -F"," '{ print $1 }' 2>/dev/null`
  127.     [ "$GECOS" ] || GECOS=$NID
  128.     cat $DEF_BOOKMARKS | sed -e "s/__gecos__/$GECOS/g" \
  129.             > $HOME/.netscape/bookmarks.html
  130. }
  131.  
  132. # do the same for the address-book.html file...
  133. [ -f $HOME/.netscape/address-book.html ] || {
  134.     [ -d $HOME/.netscape ] || mkdir -p $HOME/.netscape
  135.     NID=`id -u -n`
  136.     PASSWD_F=/etc/passwd
  137.     GECOS=`egrep -e "^${NID}" "${PASSWD_F}" | awk -F":" '{ print $5 }' \
  138.             | awk -F"," '{ print $1 }' 2>/dev/null`
  139.     [ "$GECOS" ] || GECOS=$NID
  140.     cat $DEF_ADDRBOOK | sed -e "s/__gecos__/$GECOS/g" \
  141.             > $HOME/.netscape/address-book.html
  142. }
  143.  
  144. # at this point, if we were invoked as netscape-scohelp then we do
  145. # nothing more - just run the real netscape binary with the arguments
  146. # we were given
  147. [ $SCOHELP -eq 1 ] && exec $REAL_NETSCAPE "$@"
  148.  
  149. # ...not netscape-scohelp...
  150. # pick out the Home Document setting in the preferences file
  151. # if no URL is specified on the command line
  152. echo $* | fgrep 'http:
  153. ftp:
  154. file:
  155. gopher:
  156. telnet:
  157. rlogin:
  158. tn3270:' > /dev/null || {
  159.     DOCUMENT=`grep HOME_DOCUMENT $HOME/.netscape/preferences | \
  160.             awk '{ print $2 }'`
  161. }
  162.  
  163. # use an alternate app-defaults file if installing a private colormap
  164. #
  165. #for arg in $*
  166. #do
  167. #    [ "$arg" = "-install" ] && {
  168. #        APDEF=/usr/lib/X11/app-defaults/Netscape-cmap
  169. #        XUSERFILESEARCHPATH=$APDEF:$XUSERFILESEARCHPATH
  170. #        export XUSERFILESEARCHPATH
  171. #    }
  172. #done
  173.  
  174. # if we are going to try automatic -remote, then we need to do some
  175. # additional work on the command line flags
  176. if [ -z "$NETSCAPE_NOAUTOREMOTE" ]; then
  177.  
  178.     # in the case that -remote has been used, simply apply it.
  179.     if echo $@ | egrep -- '( |^)-remote( |$)' > /dev/null
  180.     then
  181.         exec $REAL_NETSCAPE -name netscape "$@"
  182.     fi
  183.  
  184.     # take out the URL from argv, so that it can be used with -remote
  185.     new_argv=""
  186.     for i in $@; do
  187.         case $i in
  188.         http:*|ftp:*|file:*|gopher:*|telnet:*|rlogin:*|tn3270:*)
  189.             DOCUMENT="$DOCUMENT $i"    ;;
  190.         *)
  191.             new_argv="$new_argv $i"    ;;
  192.         esac
  193.     done
  194.  
  195.     # try -remote first, and if that fails, resort to starting a real
  196.     # browser process; the -name option is to avoid confusing the user's
  197.     # X resources
  198.     remotes=""
  199.     for doc in $DOCUMENT; do
  200.         remotes="$remotes -remote openURL($doc,new-window)"
  201.     done
  202.     $REAL_NETSCAPE $new_argv $remotes >/dev/null 2>&1
  203.     if [ $? -eq 0 ]; then
  204.         exit 0
  205.     else
  206.         if [ -x /usr/X/bin/net_hello -a -x /bin/vtcl \
  207.                     -a $waiting_popup -eq 0 ]; then
  208.             /usr/X/bin/net_hello $POPUPTIME &
  209.         fi
  210.         exec $REAL_NETSCAPE -name netscape $new_argv $DOCUMENT
  211.     fi
  212. else
  213.     # just start a browser process
  214.     if echo $@ | egrep -- '( |^)-remote( |$)' > /dev/null
  215.     then
  216.         continue
  217.     else
  218.         if [ -x /usr/X/bin/net_hello -a -x /bin/vtcl \
  219.                     -a $waiting_popup -eq 0 ]; then
  220.             /usr/X/bin/net_hello $POPUPTIME &
  221.         fi
  222.     fi
  223.     exec $REAL_NETSCAPE -name netscape "$@" $DOCUMENT
  224. fi
  225.