-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoodurl
executable file
·101 lines (91 loc) · 2.11 KB
/
oodurl
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
# generate OOD session URL
if [ $# -ne 1 ]; then
echo "Usage: `basename $0` JobID"
exit 1
fi
URLPREFIX="https://rivanna-portal.hpc.virginia.edu"
VNC="1.3.0"
function unsupported {
echo "$1 is not yet supported by this script. Sorry!"
exit 0
}
JOBID=$1
JOBINFO=$(scontrol show job $1)
if [ $? -ne 0 ]; then
echo "$JOBID is not an active job"
exit 1
fi
USERNAME=$(echo "$JOBINFO" | sed -n 's/^\s*UserId=\([a-z0-9]*\)(.*$/\1/p')
DIR=$(echo "$JOBINFO" | awk -F= '/WorkDir/ {print $2}')
echo "$DIR"
# check if job is an OOD session
if [[ ! "$DIR" =~ "/home/$USERNAME/ondemand".* ]]; then
echo "Not an OOD session"
exit 1
fi
# check if connection.yml exists
if [ ! -e $DIR/connection.yml ]; then
echo "connection.yml not found. Perhaps connection not yet established."
exit 1
fi
# assign variables host, port, password, websocket
eval "$(sudo -i -u $USERNAME cat $DIR/connection.yml | sed 's/: /=/g')"
[ -z "$host" ] && {
echo "Error: host not found"
exit 1
}
[ -z "$port" ] && {
echo "Error: port not found"
exit 1
}
[ -z "$password" ] && {
echo "Error: password not found"
exit 1
}
APP=$(basename $(realpath $DIR/../..))
case $APP in
jupyter_lab)
URL="${URLPREFIX}/node/${host}/${port}/lab"
;;
rstudio)
URL="${URLPREFIX}/rnode/${host}/${port}/?"
;;
uva_vscode*)
URL="${URLPREFIX}/rnode/${host}/${port}/?"
;;
uva_*)
[ -z "$websocket" ] && {
echo "Error: websocket not found"
exit 1
}
URLVNC="${URLPREFIX}/pun/sys/dashboard/noVNC-${VNC}/vnc.html?utf8=%E2%9C%93&autoconnect=true&path=rnode%2F${host}%2F${websocket}%2Fwebsockify&resize=remote&compressionsetting=6&qualitysetting=2&commit=Launch+"
case $APP in
uva_matlab)
URL="${URLVNC}MATLAB"
;;
uva_desktop)
URL="${URLVNC}Desktop"
;;
uva_blender)
URL="${URLVNC}Blender"
;;
uva_paraview)
URL="${URLVNC}ParaView"
;;
uva_qgis)
URL="${URLVNC}QGIS"
;;
*)
unsupported $1
;;
esac
;;
*)
unsupported $1
;;
esac
echo
echo $URL
echo
echo $password