Home | History | Annotate | Download | only in ext-sources
      1 #!/bin/sh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License, Version 1.0 only
      7 # (the "License").  You may not use this file except in compliance
      8 # with the License.
      9 #
     10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     11 # or http://www.opensolaris.org/os/licensing.
     12 # See the License for the specific language governing permissions
     13 # and limitations under the License.
     14 #
     15 # When distributing Covered Code, include this CDDL HEADER in each
     16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     17 # If applicable, add the following below this CDDL HEADER, with the
     18 # fields enclosed by brackets "[]" replaced with your own identifying
     19 # information: Portions Copyright [yyyy] [name of copyright owner]
     20 #
     21 # CDDL HEADER END
     22 #
     23 #
     24 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 
     28 
     29 DT_BINPATH=/usr/dt/bin
     30 XPREFIXES='
     31 /usr/X11
     32 /usr/openwin
     33 '
     34 
     35 LING=${LC_CTYPE:-"$LC_ALL"}
     36 LING=${LING:-"$LANG"}
     37 LING=${LING:-"C"}
     38 
     39 for XPATH in $XPREFIXES
     40 do
     41   if [ -x $XPATH/bin/xset ] && [ x$XSET = x ] ; then
     42     XSET=$XPATH/bin/xset
     43   fi
     44   if [ -f $XPATH/lib/locale/$LING/OWfontpath ] && [ x$OWFONTPATH = x ] ; then
     45     OWFONTPATH=$XPATH/lib/locale/$LING/OWfontpath
     46   fi
     47 done
     48 
     49 XSET=${XSET:-"xset"}
     50 OWFONTPATH=${OWFONTPATH:-"/usr/openwin/lib/locale/$LING/OWfontpath"}
     51 
     52 # Copied from /usr/dt/bin/Xsession
     53 # ###########################################################################
     54 #  
     55 # Append desktop font aliases to font path
     56 #
     57 # ###########################################################################
     58 
     59 
     60 ADDFONTPATH_LOCAL() {
     61         # Combine lines together to make arguments for the xset command
     62         FP=`/usr/bin/awk '
     63         BEGIN { fp="fp+ " }
     64         /^[     ]*$/ { fp=" +fp " ; continue }
     65         { printf("%s%s", fp, $0) ; fp="," } ' $1`
     66         if [ -n "$FP" ]; then
     67                 eval "$XSET $FP"
     68         fi
     69 }
     70 
     71 ADDFONTPATH_REMOTE() {
     72         /usr/bin/nawk '  BEGIN {
     73                 fp=" fp+ "
     74                 }
     75                 /^[     ]*$/ {
     76                 fp=" +fp " ; continue }
     77                 {cmd = sprintf("%s%s%s%s",XSET,fp, $0," 1>/dev/null");
     78                 system(cmd); } ' $1
     79 }
     80 
     81 
     82 # 
     83 # Reset Xserver font path to its default values
     84 #
     85 
     86 $XSET fp default
     87 
     88 
     89 # Append desktop font paths. Note: these directories should be
     90 # accessable by the X server. The file precedence is:
     91 #
     92 #   /etc/dt/config/xfonts/C
     93 #   /usr/dt/config/xfonts/C
     94 #   /etc/dt/config/xfonts/$LING
     95 #   /usr/dt/config/xfonts/$LING
     96 #
     97 
     98 if [ "$DTXSERVERLOCATION" != "remote" -o "$XSERVERLOCATION" != "remote" ]; then
     99 
    100   #
    101   # Since X server is local, optimize by checking local desktop
    102   # font directories and making one call to xset.
    103   #
    104   if [ -r $OWFONTPATH ]; then
    105     ADDFONTPATH_LOCAL $OWFONTPATH
    106   fi
    107 
    108   if [ -f /etc/dt/config/xfonts/C/fonts.dir ]; then
    109     fontpath=/etc/dt/config/xfonts/C
    110   fi
    111 
    112   if [ -f /usr/dt/config/xfonts/C/fonts.dir ]; then
    113     if [ "x$fontpath" = x ]; then
    114       fontpath=/usr/dt/config/xfonts/C
    115     else
    116       fontpath=$fontpath,/usr/dt/config/xfonts/C
    117     fi
    118   fi
    119 
    120   if [ "$LING" != "C" ]; then
    121     if [ -f /etc/dt/config/xfonts/$LING/fonts.dir ]; then
    122       if [ "x$fontpath" = x ]; then
    123         fontpath=/etc/dt/config/xfonts/$LING
    124       else
    125         fontpath=$fontpath,/etc/dt/config/xfonts/$LING
    126       fi
    127     fi
    128 
    129     if [ -f /usr/dt/config/xfonts/$LING/fonts.dir ]; then
    130       if [ "x$fontpath" = x ]; then
    131         fontpath=/usr/dt/config/xfonts/$LING
    132       else
    133         fontpath=$fontpath,/usr/dt/config/xfonts/$LING
    134       fi
    135     fi
    136   fi
    137 
    138   if [ "x$fontpath" != x ]; then
    139     $XSET fp+ $fontpath
    140   fi
    141 else
    142   #
    143   # Since X server not local, we don't know if the desktop font
    144   # directories exist on the X server machine, so we have to
    145   # set them one at a time.
    146   #
    147   if [ -r $OWFONTPATH ]; then
    148       ADDFONTPATH_REMOTE $OWFONTPATH
    149   fi
    150 
    151   $XSET fp+ /etc/dt/config/xfonts/C 1>/dev/null
    152   $XSET fp+ /usr/dt/config/xfonts/C 1>/dev/null
    153 
    154   if [ "$LING" != "C" ]; then 
    155     $XSET fp+ /etc/dt/config/xfonts/$LING 1>/dev/null
    156     $XSET fp+ /usr/dt/config/xfonts/$LING 1>/dev/null
    157   fi
    158 
    159   #
    160   # Append Font Server to tail of path.  
    161   # Will server any "-dt-" fonts not found on the remote machine.
    162   # 
    163   if [ -x /usr/openwin/bin/fs ]; then
    164     Hostname=`/usr/bin/hostname`
    165     dom=`/usr/bin/domainname`
    166     FS_HOSTNAME=''
    167 
    168     if [ ! -z "$dom" ]; then
    169             dom=".`echo $dom | /usr/bin/cut -d. -f2-`"
    170     fi
    171 
    172     if [ -x /usr/bin/getent ] && \
    173        /usr/bin/getent ipnodes "${Hostname}" > /dev/null 2>&1; then
    174             FS_HOSTNAME=`/usr/bin/getent ipnodes "${Hostname}" | \
    175                          /usr/bin/head -1 | /usr/bin/cut -f1`
    176     elif /usr/sbin/ping "${Hostname}${dom}" 1 > /dev/null 2>&1; then
    177             FS_HOSTNAME="${Hostname}${dom}"
    178     fi
    179 
    180     if [ -z "$FS_HOSTNAME" ] || \
    181        ! /usr/sbin/ping "$FS_HOSTNAME" 1 >/dev/null 2>&1
    182     then
    183             FS_HOSTNAME="${Hostname}"
    184     fi
    185 
    186     $XSET fp+ "tcp/${FS_HOSTNAME}:7100"
    187   fi
    188 fi
    189 
    190