Skip to content

Commit

Permalink
added usage to copy-in
Browse files Browse the repository at this point in the history
  • Loading branch information
bdevcich committed Oct 18, 2023
1 parent 01d1449 commit 4490d03
Showing 1 changed file with 49 additions and 16 deletions.
65 changes: 49 additions & 16 deletions remora/scripts/copy-in.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,67 @@

set -e

# ./copy-in.sh /lus/global test.in 1050 1051
# ./copy-in.sh /lus/global testuser/test.in 1050 1051
function usage() {
echo
echo "Create a file and/or directory at the rootpath with the given UID/GID."
echo "This is used prior to copy_in directives to ensure the FILEPATH/directory are in"
echo "place."
echo
echo "Syntax: copy-in.sh ROOT_DIR FILEPATH UID GID"
echo
echo "arguments:"
echo "ROOT_DIR root path directory; assume this is the global lustre"
echo " mount root (e.g. /lus/global)"
echo "FILEPATH filepath to the FILEPATH to create. This should be a"
echo " path (e.g. /testuser/test.in, test.in)"
echo "UID user ID of the filepath"
echo "GID groupd ID of the filepath"
echo
echo "examples:"
echo "copy-in.sh /lus/global test.in 1050 1051"
echo "copy-in.sh /lus/global testuser/test.in 1050 1051"
echo
}

ROOTDIR=$1
FILE=$2
ROOT_DIR=$1
FILEPATH=$2
MYUID=$3
MYGID=$4

# TODO: check args

# Get the base diectory on top of global lustre (if any) and create the directory
BASEDIR=$(dirname $FILE)
if [ "$BASEDIR" != "." ]; then
mkdir -p "$ROOTDIR"/"$BASEDIR"
if [[ -z "$ROOT_DIR" ]]; then
usage
exit 1
elif [[ -z "$FILEPATH" ]]; then
usage
exit 1
elif [[ -z "$MYUID" ]]; then
usage
exit 1
elif [[ -z "$MYGID" ]]; then
usage
exit 1
fi

# Use the perl binary as our test file
cp /usr/bin/perl "$ROOTDIR"/"$FILE"
# Get the base diectory on top of global lustre and create the directory
BASEDIR=$(dirname $FILEPATH)
mkdir -p "$ROOT_DIR"/"$BASEDIR"

# Use the perl binary as our test FILEPATH
cp /usr/bin/perl "$ROOT_DIR"/"$FILEPATH"

# Set the permissions of the base dir
# TODO: Only if set?
chown -R "$MYUID":"$MYGID" "$ROOTDIR"/"$BASEDIR"
if [ "$BASEDIR" != "." ]; then
chown -R "$MYUID":"$MYGID" "$ROOT_DIR"/"$BASEDIR"
# Otherwise just set the file directly if no base dir
else
chown "$MYUID":"$MYGID" "$ROOT_DIR"/"$FILEPATH"
fi

# List the basedir contents
ls -alhR "$ROOTDIR"/"$BASEDIR" #&>"$ROOTDIR"/"$MYUSER"/test.output
ls -alhR "$ROOT_DIR"/"$BASEDIR" #&>"$ROOT_DIR"/"$MYUSER"/test.output

# TODO md5sum

set +e

exit 0
exit 0

0 comments on commit 4490d03

Please sign in to comment.