home *** CD-ROM | disk | FTP | other *** search
Korn shell script | 1998-08-19 | 4.1 KB | 127 lines |
- #! /bin/ksh
- #####################################################################
- ### File: 0030.dttmpdir
- ###
- ### Default Location: /usr/dt/config/Xsession.d/
- ###
- ### Purpose: Create the temporary directory on a per-user,
- ### per-session basis, keying on the $DTUSERSESSION
- ### value, which can also be set by the dtsearchpath
- ### utility.
- ###
- ### Description:
- ### This script is invoked by means of the Xsession file
- ### at user login. It creates a temporary directory
- ### for files on behalf of the user.
- ###
- ### Invoked by: /usr/dt/bin/Xsession
- ###
- ### Product: @(#)TED 4.2 Alpha 99-4200-00
- ###
- ### Note: Creates the /var/dt directory if one doesn't exist.
- ### However, root privilege may be required. If /var/dt
- ### disappears, then logging in as root should restore it.
- ###
- ### Revision: $XConsortium: 0030.dttmpdir.src /main/cde1_maint/1 1995/07/15 00:56:26 drk $
- ###
- ### (c) Copyright 1994 TriTeal Corporation
- ### (c) Copyright 1993, 1994 Hewlett-Packard Company
- ### (c) Copyright 1993, 1994 International Business Machines Corp.
- ### (c) Copyright 1993, 1994 Sun Microsystems, Inc.
- ### (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
- ### Novell, Inc.
- #####################################################################
-
- if (( ${#DTUSERSESSION} == 0 ))
- then
- #
- # Set the DTAPPMANDIR directory component, which will control
- # the location of the user's Application Manager directory,
- # as well as the location of his or her temporary directory.
- #
- DTAPPDIR_HOST_COMPONENT=${DISPLAY%:*}
- DTAPPDIR_DISP_COMPONENT=${DISPLAY#*:}
-
- if [[ ${DTAPPDIR_HOST_COMPONENT} = "" ]]
- then
- DTAPPDIR_HOST_COMPONENT=`uname -n`
- fi
-
- #
- # If the screen number is "0" (e.g., "host:3.0"), then
- # strip off the screen number.
- #
- if [[ ${DTAPPDIR_DISP_COMPONENT#*.} = "0" ]]
- then
- DTAPPDIR_DISP_COMPONENT=${DTAPPDIR_DISP_COMPONENT%.0}
- fi
-
- DTUSERSESSION=${LOGNAME}-${DTAPPDIR_HOST_COMPONENT}-${DTAPPDIR_DISP_COMPONENT}
- export DTUSERSESSION
- fi
-
- #
- # Create the /var/dt subdirectory, if one doesn't exist
- #
- if [[ ! -d /var/dt ]]
- then
- #
- # This step probably requires root privilege
- #
- mkdir -p /var/dt >/dev/null 2>/dev/null
- chmod 777 /var/dt >/dev/null 2>/dev/null
- chgrp bin /var/dt >/dev/null 2>/dev/null
- chown bin /var/dt >/dev/null 2>/dev/null
- fi
-
- #
- # Create the /var/dt/appconfig subdirectory, if one doesn't exist
- #
- if [[ (-d /var/dt) && (-w /var/dt) && (! -d /var/dt/appconfig) ]]
- then
- mkdir -p /var/dt/appconfig >/dev/null 2>/dev/null
- chmod 777 /var/dt/appconfig >/dev/null 2>/dev/null
- chgrp bin /var/dt/appconfig >/dev/null 2>/dev/null
- chown bin /var/dt/appconfig >/dev/null 2>/dev/null
- fi
-
- #
- # Create the /var/dt/appconfig/appmanager subdirectory, if one doesn't
- # exist.
-
- if [[ (-d /var/dt/appconfig) && (-w /var/dt/appconfig) && (! -d /var/dt/appconfig/appmanager) ]]
- then
- mkdir -p /var/dt/appconfig/appmanager >/dev/null 2>/dev/null
- chmod 777 /var/dt/appconfig/appmanager >/dev/null 2>/dev/null
- chgrp bin /var/dt/appconfig/appmanager >/dev/null 2>/dev/null
- chown bin /var/dt/appconfig/appmanager >/dev/null 2>/dev/null
- fi
-
- if [[ -n $DTUSERSESSION ]]
- then
- if [[ (-d /var/dt) && (-w /var/dt) ]]
- then
- if [[ (-d /var/dt/tmp) && (-w /var/dt/tmp) ]]
- then
- rm -fr /var/dt/tmp/$DTUSERSESSION >/dev/null 2>/dev/null
- mkdir -p /var/dt/tmp/$DTUSERSESSION >/dev/null 2>/dev/null
- else
- mkdir -p /var/dt/tmp >/dev/null 2>/dev/null
- chmod 777 /var/dt/tmp >/dev/null 2>/dev/null
- chgrp bin /var/dt/tmp >/dev/null 2>/dev/null
- chown bin /var/dt/tmp >/dev/null 2>/dev/null
- mkdir -p /var/dt/tmp/$DTUSERSESSION >/dev/null 2>/dev/null
- fi
- else
- print ""
- print `date`
- print "$0: Unable to access the /var/dt directory."
- print "You may need to log in as root to restore /var/dt."
- print ""
- fi
- else
- print "Unable to make the temporary directory for the user."
- fi
-
- ########################## eof ########################
-