-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlaunch_atoken
executable file
·45 lines (36 loc) · 1.2 KB
/
launch_atoken
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
master_process=$1
##if [[ ! ${SLURM_JOB_ID+x} ]]; then
## echo ""
## echo "This command can only be used inside a batch job"
## exit 1
##fi
test=$(swift stat 2> /dev/null | grep -c "Account:")
if [[ $test -lt 1 ]]
then
echo "Unable to launch active token process as there is no authenticated connection to Allas!"
echo "Please try setting up the connection again"
echo "by running the command:"
echo ""
echo " source /appl/opt/allas_conf"
echo ""
if [ -n "$SLURM_JOB_ID" ]; then
echo "Ending the batch job."
scancel $SLURM_JOB_ID
fi
exit 1
fi
if [[ ! -e "${HOME}/.active_tokens" ]]; then
mkdir ${HOME}/.active_tokens
fi
password=$(openssl rand -base64 32| tr ":" "p" )
tokenfile=("${HOME}/.active_tokens/token_${master_process}")
#if this session already has an active token process, kill it before starting a new one
if [[ -e "$tokenfile" ]]; then
kill -9 $(cat ${tokenfile}_proc)
rm -f ${tokenfile}_proc ${tokenfile}
fi
#echo "keep_tokens_alive.sh $password $tokenfile $master_process "
#keep_tokens_alive.sh $password $tokenfile $master_process
keep_tokens_alive.sh $password $tokenfile $master_process > /dev/null 2>&1 &
echo ${password}:${tokenfile}