home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / TEDdesk / reloc.8 / $TED_DIR / config / Xsession.d / 0030.dttmpdir < prev   
Encoding:
Korn shell script  |  1998-08-19  |  4.1 KB  |  127 lines

  1. #! /bin/ksh
  2. #####################################################################
  3. ###  File:              0030.dttmpdir
  4. ###
  5. ###  Default Location:  /usr/dt/config/Xsession.d/
  6. ###
  7. ###  Purpose:           Create the temporary directory on a per-user,
  8. ###                     per-session basis, keying on the $DTUSERSESSION
  9. ###                     value, which can also be set by the dtsearchpath 
  10. ###                     utility.
  11. ###
  12. ###  Description:
  13. ###                     This script is invoked by means of the Xsession file
  14. ###                     at user login.  It creates a temporary directory
  15. ###                     for files on behalf of the user.
  16. ###
  17. ###  Invoked by:        /usr/dt/bin/Xsession
  18. ###
  19. ###  Product:           @(#)TED 4.2 Alpha 99-4200-00
  20. ###
  21. ###  Note:              Creates the /var/dt directory if one doesn't exist.
  22. ###                     However, root privilege may be required.  If /var/dt
  23. ###                     disappears, then logging in as root should restore it.
  24. ###
  25. ###  Revision:          $XConsortium: 0030.dttmpdir.src /main/cde1_maint/1 1995/07/15 00:56:26 drk $
  26. ###
  27. ###  (c) Copyright 1994 TriTeal Corporation
  28. ###  (c) Copyright 1993, 1994 Hewlett-Packard Company
  29. ###  (c) Copyright 1993, 1994 International Business Machines Corp.
  30. ###  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  31. ###  (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  32. ###      Novell, Inc.
  33. #####################################################################
  34.  
  35. if (( ${#DTUSERSESSION} == 0 ))
  36. then
  37. #
  38. #  Set the DTAPPMANDIR directory component, which will control
  39. #  the location of the user's Application Manager directory,
  40. #  as well as the location of his or her temporary directory.
  41. #
  42.       DTAPPDIR_HOST_COMPONENT=${DISPLAY%:*}
  43.       DTAPPDIR_DISP_COMPONENT=${DISPLAY#*:}
  44.  
  45.       if [[ ${DTAPPDIR_HOST_COMPONENT} = "" ]]
  46.       then
  47.        DTAPPDIR_HOST_COMPONENT=`uname -n`
  48.       fi
  49.     
  50. #
  51. #  If the screen number is "0" (e.g., "host:3.0"), then
  52. #  strip off the screen number.
  53. #
  54.       if [[ ${DTAPPDIR_DISP_COMPONENT#*.} = "0" ]]
  55.       then
  56.           DTAPPDIR_DISP_COMPONENT=${DTAPPDIR_DISP_COMPONENT%.0}
  57.       fi
  58.     
  59.       DTUSERSESSION=${LOGNAME}-${DTAPPDIR_HOST_COMPONENT}-${DTAPPDIR_DISP_COMPONENT}
  60.       export DTUSERSESSION
  61. fi
  62.  
  63. #
  64. #    Create the /var/dt subdirectory, if one doesn't exist
  65. #
  66. if [[ ! -d /var/dt ]]
  67. then
  68. #
  69. #  This step probably requires root privilege
  70. #
  71.     mkdir -p /var/dt >/dev/null 2>/dev/null
  72.     chmod 777 /var/dt >/dev/null 2>/dev/null
  73.     chgrp bin /var/dt >/dev/null 2>/dev/null
  74.     chown bin /var/dt >/dev/null 2>/dev/null
  75. fi
  76.  
  77. #
  78. #    Create the /var/dt/appconfig subdirectory, if one doesn't exist
  79. #
  80. if [[ (-d /var/dt) && (-w /var/dt) && (! -d /var/dt/appconfig) ]]
  81. then
  82.     mkdir -p /var/dt/appconfig >/dev/null 2>/dev/null
  83.     chmod 777 /var/dt/appconfig >/dev/null 2>/dev/null
  84.     chgrp bin /var/dt/appconfig >/dev/null 2>/dev/null
  85.     chown bin /var/dt/appconfig >/dev/null 2>/dev/null
  86. fi
  87.  
  88. #
  89. #    Create the /var/dt/appconfig/appmanager subdirectory, if one doesn't 
  90. #      exist.
  91.  
  92. if [[ (-d /var/dt/appconfig) && (-w /var/dt/appconfig) && (! -d /var/dt/appconfig/appmanager) ]]
  93. then
  94.     mkdir -p /var/dt/appconfig/appmanager >/dev/null 2>/dev/null
  95.     chmod 777 /var/dt/appconfig/appmanager >/dev/null 2>/dev/null
  96.     chgrp bin /var/dt/appconfig/appmanager >/dev/null 2>/dev/null
  97.     chown bin /var/dt/appconfig/appmanager >/dev/null 2>/dev/null
  98. fi
  99.  
  100. if [[ -n $DTUSERSESSION ]]
  101. then
  102.     if [[ (-d /var/dt) && (-w /var/dt) ]]
  103.     then
  104.     if [[ (-d /var/dt/tmp) && (-w /var/dt/tmp) ]]
  105.     then
  106.         rm -fr /var/dt/tmp/$DTUSERSESSION  >/dev/null 2>/dev/null
  107.         mkdir -p /var/dt/tmp/$DTUSERSESSION >/dev/null 2>/dev/null
  108.     else
  109.         mkdir -p /var/dt/tmp >/dev/null 2>/dev/null
  110.         chmod 777 /var/dt/tmp >/dev/null 2>/dev/null
  111.         chgrp bin /var/dt/tmp >/dev/null 2>/dev/null
  112.         chown bin /var/dt/tmp >/dev/null 2>/dev/null
  113.         mkdir -p /var/dt/tmp/$DTUSERSESSION >/dev/null 2>/dev/null
  114.     fi
  115.     else
  116.     print ""
  117.     print `date`
  118.     print "$0:  Unable to access the /var/dt directory."
  119.     print "You may need to log in as root to restore /var/dt."
  120.     print ""
  121.     fi
  122. else
  123.     print "Unable to make the temporary directory for the user."
  124. fi
  125.  
  126. ##########################         eof       ########################
  127.