- Infos im HLRS Wiki sind nicht rechtsverbindlich und ohne Gewähr -
- Information contained in the HLRS Wiki is not legally binding and HLRS is not responsible for any damages that might result from its use -

HOME filesystem

From HLRS Platforms
Revision as of 10:35, 7 September 2012 by Hpcralf (talk | contribs)
Jump to navigationJump to search

Since the System update of Laki (NEC Nehalem Cluster) to Scientific Linux 6.2 the Home filesystem is shared between Hermit (Cray XE6) and Laki. For some users it may be convinient to have some content stored in the users HOME like application configuration directories and files seperated between the two systems. This can be done by the .profile example shown below.

#!/bin/bash
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# == Declaration of variables ======================================= XX   
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#
NEHALEM_SUBFOLDER=nehalem_home
CRAY_SUBFOLDER=cray_home
#
# -- Set your default home location ------------------------------------
#
# [1] : BlueArc with subdirectory
# [2] : Lustre workspace
#
HOME_LOC=2
#
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# == Declaration of functions ======================================= XX   
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#
# -- Function to set new HOME path -------------------------------------
set_new_home () {
   
   if  [ -d $HOME/$1 ]; then
      export HOME=$HOME/$1
   else
      echo "Found no subdirectory '$1' in current HOME path"
      echo $HOME
      ret=`mkdir $HOME/$1`
      if [ -n $ret ]; then
         echo "Created subdirectory '$1'"
         export HOME=$HOME/$1
      else
        echo "Subdirectory '$1' could not be created. Using"
        echo $HOME
        echo "as HOME path"
        export HOME=$HOME
      fi
   fi
}
#
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# == Preparation of HOME redirection ================================ XX   
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#
# -- Save original home path -------------------------------------------
ORIGINAL_HOME=$HOME
export ORIGINAL_HOME
#
# -- If X forwarding is enabled ----------------------------------------
if [[ -n "`echo $DISPLAY | grep localhost`" ]]; then
   # -- Get Display number ---------------------------------------------
   displ_nr=`echo $DISPLAY | sed -e "s/localhost//" | cut -d. -f1`
   #echo $displ_nr
   #
   # -- Extract magic cookie for current display -----------------------
   mgco=`xauth nextract - ${HOST}/unix${displ_nr}`
   #echo $mgco
else
   mgco=""
fi
#
# -- Set Home location to workspace if requested -----------------------
if [[ "$HOME_LOC" == "2" ]]; then
   HOME=`ws_find home`
   if [[ -z $HOME ]]; then
      echo "Please allocate workspace with name 'home' if choosing HOME_LOC=2"
      HOME=$ORIGINAL_HOME
   fi
fi
#
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# == Nehalem login ================================================== XX   
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#
if [[ $HOST == cl3* ]] || [[ -n `echo $HOST | grep -e "n[0-9]\{6\}$"` ]]; then
    set_new_home $NEHALEM_SUBFOLDER
fi
#
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# == Hermit login =================================================== XX   
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#
if [[ "$HOST" == "hermit1" ]] ||
   [[ -n `echo $HOST | grep -e "eslogin[0-9]\{3\}$"` ]] || 
   [[ -n `echo $HOST | grep -e "nid[0-9]\{5\}$"` ]]     || 
   [[ -n `echo $HOST | grep -e "pre[0-9]\{3\}$"` ]]          ; then
    set_new_home $CRAY_SUBFOLDER
fi
#
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# == Preparation of specific environment ============================ XX   
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#
if [[ -n $ORIGINAL_HOME ]]; then
   echo ""
   echo "=================================================================="
   echo ""
   echo " Please  be aware that the path to your home directory has been"
   echo " changed from"
   echo ""
   echo " $ORIGINAL_HOME"
   echo ""
   echo " to"
   echo ""
   echo " $HOME"
   echo ""
   #
   # -- Change to machine specific HOME -----------------------------------
   cd $HOME
   #
   # -- Link .ssh to new home ---------------------------------------------
   if [ ! -d .ssh ]; then
      ln -s $ORIGINAL_HOME/.ssh .ssh
   fi
   #
   if [[ -n "$mgco" ]]; then
      # -- Update .Xauthority in new home ---------------------------------
      if [ ! -e .Xauthority ]; then
         cp $ORIGINAL_HOME/.Xauthority .Xauthority
      else
         echo $mgco | xauth nmerge -
      fi
   fi
   #
   # -- Set machine specific environment ----------------------------------
   if [ -f .profile ]; then
      source .profile
   else
      echo "Found no .profile in new HOME location"
      echo ""
   fi
#
else
   echo ""
   echo "=================================================================="
   echo ""
   echo " Please  be aware that the path to your home directory has not"
   echo " been changed even though the .profile for HOME diverting was "
   echo " executed on login !"
   echo ""
   echo "This is becaus login came accross "$HOST
   echo ""
fi