home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # @(#) netscape 14.1 98/03/18
- #
- # Copyright (c) 1997 The Santa Cruz Operation, Inc.. All Rights Reserved.
- # THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE SANTA CRUZ OPERATION INC.
- # The copyright notice above does not evidence any actual or intended
- # publication of such source code.
- #
- #
- # Netscape Navigator wrapper
- #
- # This is in lieu of a full set of resources in the app-defaults
- # file. For instance, this allows our default installation to specify
- # a system-wide default home document (working around the fact that
- # there is no homeDocument X11 resource for Netscape Navigator).
- #
-
- # This shell script is set up to automatically start a child browser
- # window from an already-running Netscape browser on the desktop. This can
- # save system resources, but can also be confusing - for example, if you
- # use this feature and have a 3.0.1 browser running, you will get another
- # 3.0.1 window, rather than the 3.0.3 browser that you might expect. It
- # does however improve performance for some configurations, especially
- # those where there is no mix of browser releases. If you want to disable
- # this feature, set a value for the env variable NETSCAPE_NOAUTOREMOTE.
-
- # Note that the above feature is bypassed if the script is invoked as
- # netscape-scohelp.
- SCOHELP=0
- [ "`basename $0`" = "netscape-scohelp" ] && SCOHELP=1
-
- # Set the directory where Java and other support files live
- DEF_CLASSPATH=/usr/ns-home/lib/netscape
- export DEF_CLASSPATH
-
- # if $CLASSPATH not set, then set it to the default location
- [ "$CLASSPATH" ] || CLASSPATH=$DEF_CLASSPATH
- export CLASSPATH
-
- # Set this to the location of the real Netscape executable
- REAL_NETSCAPE=$DEF_CLASSPATH/netscape
-
- # Set this to the location of the default preferences file.
- DEF_PREFS=$DEF_CLASSPATH/default-netscape-preferences
-
- # Set this to the location of the default bookmarks.html file.
- DEF_BOOKMARKS=$DEF_CLASSPATH/bookmarks.html
-
- # Set this to the location of the default address-book.html file.
- DEF_ADDRBOOK=$DEF_CLASSPATH/address-book.html
-
- # Set this to the location of the default .mailcap and .mime.types files
- DEF_MAILCAP=$DEF_CLASSPATH/default-mailcap
- DEF_MIMETYPES=$DEF_CLASSPATH/default-mime.types
-
- # Timeout in mS for the starting popup
- POPUPTIME="20000"
-
- # Information for default homepages added to preferences; two different
- # pages may be set depending on whether the system is connected to the
- # Internet or not. Set a value for NETSCAPE_INITIALHOMEPAGE to override
- # these checks and pages with one of your own choosing
- DEF_HOMEPAGE_NOWEB="file:/usr/ns-home/nsnav-html/${LANG:-C}/navhome.html"
- if [ ! -f $DEF_HOMEPAGE_NOWEB ]; then
- DEF_HOMEPAGE_NOWEB="file:/usr/ns-home/nsnav-html/C/navhome.html"
- fi
- DEF_HOMEPAGE_WEBOK="http://www.sco.com/uw7/nav304/home"
- TEST_ADDRESS="198.41.0.4"
- TEST_TIMEOUT=2
- TEST_LOOPS="1 2 3 4 5"
- TEST_POPUPTIME="30000"
-
- # first check for preferences file, and if it doesn't exist, create it
- # with reasonable defaults set for the user invoking it
- waiting_popup=0
- [ -f $HOME/.netscape/preferences ] || {
- [ -d $HOME/.netscape ] || mkdir -p $HOME/.netscape
- UID=`id -u`
- NID=`id -u -n`
- [ -x "/usr/ucb/hostname" ] && HOST=`/usr/ucb/hostname`
- [ -z "$HOST" ] && HOST="localhost"
- PASSWD_F=/etc/passwd
- GECOS=`egrep -e "^${NID}" "${PASSWD_F}" | awk -F":" '{ print $5 }' | \
- awk -F"," '{ print $1 }' 2>/dev/null`
- [ "$GECOS" ] || GECOS=$NID
- if [ -n "$NETSCAPE_INITIALHOMEPAGE" ]; then
- HOMEPAGE="$NETSCAPE_INITIALHOMEPAGE"
- else
- HOMEPAGE="$DEF_HOMEPAGE_NOWEB"
- if [ -x /usr/X/bin/net_hello -a -x /bin/vtcl \
- -a $SCOHELP -eq 0 ]; then
- /usr/X/bin/net_hello $TEST_POPUPTIME &
- waiting_popup=1
- fi
- for i in $TEST_LOOPS; do
- response="`/usr/sbin/ping -n $TEST_ADDRESS $TEST_TIMEOUT 2>&1`"
- case "$response" in
- *alive)
- HOMEPAGE="$DEF_HOMEPAGE_WEBOK"
- break ;;
- esac
- done
- fi
- cat $DEF_PREFS | sed -e "s/__uid__/$UID/g" -e "s/__nid__/$NID/g" \
- -e "s/__gecos__/$GECOS/g" -e "s/__host__/$HOST/g" \
- -e "s@__homepage__@$HOMEPAGE@g" \
- > $HOME/.netscape/preferences
- [ -d $HOME/.netscape/cache ] || mkdir -p $HOME/.netscape/cache
- }
-
- # if no mailcap or mime.types files then put default ones in
- [ -f $HOME/.mailcap ] || {
- cp $DEF_MAILCAP $HOME/.mailcap
- }
- [ -f $HOME/.mime.types ] || {
- cp $DEF_MIMETYPES $HOME/.mime.types
- }
-
- # next, check for bookmarks.html file, and if it doesn't exist, create it
- # with SCO supplied bookmark list...
- [ -f $HOME/.netscape/bookmarks.html ] || {
- [ -d $HOME/.netscape ] || mkdir -p $HOME/.netscape
- NID=`id -u -n`
- PASSWD_F=/etc/passwd
- GECOS=`egrep -e "^${NID}" "${PASSWD_F}" | awk -F":" '{ print $5 }' \
- | awk -F"," '{ print $1 }' 2>/dev/null`
- [ "$GECOS" ] || GECOS=$NID
- cat $DEF_BOOKMARKS | sed -e "s/__gecos__/$GECOS/g" \
- > $HOME/.netscape/bookmarks.html
- }
-
- # do the same for the address-book.html file...
- [ -f $HOME/.netscape/address-book.html ] || {
- [ -d $HOME/.netscape ] || mkdir -p $HOME/.netscape
- NID=`id -u -n`
- PASSWD_F=/etc/passwd
- GECOS=`egrep -e "^${NID}" "${PASSWD_F}" | awk -F":" '{ print $5 }' \
- | awk -F"," '{ print $1 }' 2>/dev/null`
- [ "$GECOS" ] || GECOS=$NID
- cat $DEF_ADDRBOOK | sed -e "s/__gecos__/$GECOS/g" \
- > $HOME/.netscape/address-book.html
- }
-
- # at this point, if we were invoked as netscape-scohelp then we do
- # nothing more - just run the real netscape binary with the arguments
- # we were given
- [ $SCOHELP -eq 1 ] && exec $REAL_NETSCAPE "$@"
-
- # ...not netscape-scohelp...
- # pick out the Home Document setting in the preferences file
- # if no URL is specified on the command line
- echo $* | fgrep 'http:
- ftp:
- file:
- gopher:
- telnet:
- rlogin:
- tn3270:' > /dev/null || {
- DOCUMENT=`grep HOME_DOCUMENT $HOME/.netscape/preferences | \
- awk '{ print $2 }'`
- }
-
- # use an alternate app-defaults file if installing a private colormap
- #
- #for arg in $*
- #do
- # [ "$arg" = "-install" ] && {
- # APDEF=/usr/lib/X11/app-defaults/Netscape-cmap
- # XUSERFILESEARCHPATH=$APDEF:$XUSERFILESEARCHPATH
- # export XUSERFILESEARCHPATH
- # }
- #done
-
- # if we are going to try automatic -remote, then we need to do some
- # additional work on the command line flags
- if [ -z "$NETSCAPE_NOAUTOREMOTE" ]; then
-
- # in the case that -remote has been used, simply apply it.
- if echo $@ | egrep -- '( |^)-remote( |$)' > /dev/null
- then
- exec $REAL_NETSCAPE -name netscape "$@"
- fi
-
- # take out the URL from argv, so that it can be used with -remote
- new_argv=""
- for i in $@; do
- case $i in
- http:*|ftp:*|file:*|gopher:*|telnet:*|rlogin:*|tn3270:*)
- DOCUMENT="$DOCUMENT $i" ;;
- *)
- new_argv="$new_argv $i" ;;
- esac
- done
-
- # try -remote first, and if that fails, resort to starting a real
- # browser process; the -name option is to avoid confusing the user's
- # X resources
- remotes=""
- for doc in $DOCUMENT; do
- remotes="$remotes -remote openURL($doc,new-window)"
- done
- $REAL_NETSCAPE $new_argv $remotes >/dev/null 2>&1
- if [ $? -eq 0 ]; then
- exit 0
- else
- if [ -x /usr/X/bin/net_hello -a -x /bin/vtcl \
- -a $waiting_popup -eq 0 ]; then
- /usr/X/bin/net_hello $POPUPTIME &
- fi
- exec $REAL_NETSCAPE -name netscape $new_argv $DOCUMENT
- fi
- else
- # just start a browser process
- if echo $@ | egrep -- '( |^)-remote( |$)' > /dev/null
- then
- continue
- else
- if [ -x /usr/X/bin/net_hello -a -x /bin/vtcl \
- -a $waiting_popup -eq 0 ]; then
- /usr/X/bin/net_hello $POPUPTIME &
- fi
- fi
- exec $REAL_NETSCAPE -name netscape "$@" $DOCUMENT
- fi
-