Skip to content

Commit 7d9daa3

Browse files
committed
#11 removing hardcoded age and gocryptfs paths
1 parent 6b59c47 commit 7d9daa3

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

client/job_preparation/utils/sbatch.template

+31-9
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,37 @@ export vault="VAULT_ADDRESS"
5353
WORKING_DIRECTORY=WORKDIR
5454
mkdir -p ${WORKING_DIRECTORY}
5555

56-
# Bring LUMI-SD logic
56+
# Clone HPCS repository if not already available
57+
echo -e "${YELLOW}[LUMI-SD]${NC}${BLUE}[Job]${NC} Cloning HPCS repository if it doesn't already exist"
58+
59+
if ! [ -d ~/HPCS ]; then
60+
git clone https://github.com/CSCfi/HPCS.git ~/HPCS
61+
fi
62+
63+
echo -e "${YELLOW}[LUMI-SD]${NC}${BLUE}[Job]${NC} Getting age and gocryptfs as static binaries"
64+
cd ~/HPCS || exit 1
65+
PATH=$PATH:$HOME/HPCS/bin
66+
67+
if ! which age ; then
68+
mkdir -p bin
69+
curl -O -L https://github.com/FiloSottile/age/releases/download/v1.1.1/age-v1.1.1-linux-amd64.tar.gz || exit 1
70+
tar xvf age-v1.1.1-linux-amd64.tar.gz
71+
mv age/age ./bin/
72+
rm -r age*
73+
fi
74+
75+
if ! which gocryptfs ; then
76+
mkdir -p bin
77+
curl -O -L https://github.com/rfjakob/gocryptfs/releases/download/v2.4.0/gocryptfs_v2.4.0_linux-static_amd64.tar.gz || exit 1
78+
tar xvf gocryptfs_v2.4.0_linux-static_amd64.tar.gz
79+
mv gocryptfs ./bin/
80+
rm -r gocryptfs*
81+
fi
5782

58-
## Clone repo in common directory if it doesn't already exists
59-
### For the moment : assume it's already cloned in ~/LUMI-secure-processing
6083

6184
echo -e "${YELLOW}[LUMI-SD]${NC}${BLUE}[Job]${NC} Running agent registration"
6285

6386
# Spawn spire-agent
64-
cd ~/HPCS || exit 1
6587
python3 ./utils/spawn_agent.py --config ~/.config/hpcs-client.conf -cn > $WORKING_DIRECTORY/agent.log 2> $WORKING_DIRECTORY/agent.log &
6688
spire_agent_pid=$!
6789

@@ -96,7 +118,7 @@ echo "$data_key" > /tmp/container_key
96118
echo "Decrypting container image ..."
97119

98120
# Decrypt the container image
99-
~/HPCS/client/container_preparation/input_logic/age --decrypt -i /tmp/container_key -o $WORKING_DIRECTORY/app.sif APPLICATION_PATH || exit 1
121+
age --decrypt -i /tmp/container_key -o $WORKING_DIRECTORY/app.sif APPLICATION_PATH || exit 1
100122

101123
echo -e "${YELLOW}[LUMI-SD]${NC}${BLUE}[Job]${NC} Creating encrypted volumes"
102124

@@ -110,17 +132,17 @@ password_in=$(tr -dc 'A-Za-z0-9!?%=' < /dev/urandom | head -c 25)
110132
password_out=$(tr -dc 'A-Za-z0-9!?%=' < /dev/urandom | head -c 25)
111133

112134
# Setup encrypted volumes
113-
/users/etellier/gocryptfs -q -init --extpass echo --extpass "$password_out" output
114-
/users/etellier/gocryptfs -q -init --extpass echo --extpass "$password_in" input
135+
gocryptfs -q -init --extpass echo --extpass "$password_out" output
136+
gocryptfs -q -init --extpass echo --extpass "$password_in" input
115137

116138
# Mounting cipher version of the output encrypted filesystem to write final encrypted results
117139
# Mounting the encrypted input data tgz to the container to decrypt it in the input encrypted filesystem
118140
BASIC_FLAGS="--bind ./output:/tmp/output --bind DATA_PATH:/sd-container/input/data.tgz:rw"
119141

120142
# Encrypted binds inside of the container
121143
BIND_ENCRYPTED_VOLUME_FLAG="--fusemount host:"
122-
BIND_ENCRYPTED_VOLUME_FLAG_MOUNT_INPUT="/users/etellier/gocryptfs -q --extpass echo --extpass ${password_in} ${WORKING_DIRECTORY}/input /sd-container/encrypted"
123-
BIND_ENCRYPTED_VOLUME_FLAG_MOUNT_OUTPUT="/users/etellier/gocryptfs -q --extpass echo --extpass ${password_out} ${WORKING_DIRECTORY}/output /sd-container/output"
144+
BIND_ENCRYPTED_VOLUME_FLAG_MOUNT_INPUT="gocryptfs -q --extpass echo --extpass ${password_in} ${WORKING_DIRECTORY}/input /sd-container/encrypted"
145+
BIND_ENCRYPTED_VOLUME_FLAG_MOUNT_OUTPUT="gocryptfs -q --extpass echo --extpass ${password_out} ${WORKING_DIRECTORY}/output /sd-container/output"
124146
BIND_INPUT="INPUT_SCRIPTS_DIR"
125147
BIND_OUTPUT="OUTPUT_SCRIPTS_DIR"
126148

0 commit comments

Comments
 (0)