aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmultihome73
1 files changed, 43 insertions, 30 deletions
diff --git a/multihome b/multihome
index 1c65b49..555665b 100755
--- a/multihome
+++ b/multihome
@@ -30,9 +30,8 @@ transfer_env=( .*profile .*login .*cshrc* .bash* )
hostname_short=$(hostname -s)
host_suffix=".stsci.edu"
home_remote_path=$HOME
-
-# If hostname does not match anything in clusters array, set a default
-cluster="standard"
+cluster=""
+cluster_force=false
if [ -f "$RC" ]; then
source $RC
@@ -49,38 +48,52 @@ if [ ${#clusters[@]} -gt 0 ]; then
done
fi
-# Assign directory structure
-home_local_path="/home/$USER/home_local/$cluster/$hostname_short"
-
-# If multi-home directory does not exist, create it
-if [ ! -d $home_local_path ]; then
- mkdir -p $home_local_path
- if [ $? -ne 0 ]; then
- echo "No write access: $home_local_path, aborting"
- home_local_path=/home/$USER
- fi
+if [ "$cluster_force" != false ]; then
+ echo "Forcing clustered environment"
+ cluster="standard"
fi
-# Generate symlink to original home directory
-( cd $home_local_path ;
- if [ ! -L HEAD_"$USER" ]; then
- ln -sf "$home_remote_path" HEAD_"$USER"
- fi )
+if [ ! -z "$cluster" ]; then
+ # Assign directory structure
+ home_local_path="/home/$USER/home_local/$cluster/$hostname_short"
-# Copy baseline enviroment
-( cd $home_local_path ;
- for file in "${transfer_env[@]}"
- do
- SRC="$home_remote_path/$file"
- DEST="$home_local_path"
- if [ "$file" == stsci_multihome ]; then
- continue
- fi
+ # If we are already inside, die
+ if [[ "$PWD" == $home_local_path* ]]; then
+ exit 2
+ fi
- if [ ! -f "$DEST/$file" ]; then
- cp -a $SRC $DEST 2>/dev/null
+ # If multi-home directory does not exist, create it
+ if [ ! -d $home_local_path ]; then
+ mkdir -p $home_local_path
+ if [ $? -ne 0 ]; then
+ echo "No write access: $home_local_path, aborting"
+ home_local_path=/home/$USER
fi
- done )
+ fi
+
+ # Generate symlink to original home directory
+ ( cd $home_local_path ;
+ if [ ! -L HEAD_"$USER" ]; then
+ ln -sf "$home_remote_path" HEAD_"$USER"
+ fi )
+
+ # Copy baseline enviroment
+ ( cd $home_local_path ;
+ for file in "${transfer_env[@]}"
+ do
+ SRC="$home_remote_path/$file"
+ DEST="$home_local_path"
+ if [ "$file" == stsci_multihome ]; then
+ continue
+ fi
+
+ if [ ! -f "$DEST/$file" ]; then
+ cp -a $SRC $DEST 2>/dev/null
+ fi
+ done )
+else
+ home_local_path=/home/$USER
+fi
SHELL_MODE=
SHELL_MODE_DELIMITER=