-
Notifications
You must be signed in to change notification settings - Fork 12
/
init.sh
executable file
·48 lines (44 loc) · 1.23 KB
/
init.sh
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
#!/bin/sh
export SSTBASE=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
export CERTS=$SSTBASE/certs
export PYTHONPATH="$PYTHONPATH:$SSTBASE"
export SSTOUT="$SSTBASE/output"
export SSTLOG="$SSTBASE/log"
export SSTDATA="$SSTBASE/data"
export SSTMAIL="[email protected]"
SSTINITERR="$SSTLOG/sstInit.log"
if [ ! -d "$SSTOUT" ]; then
mkdir $SSTOUT
fi
if [ ! -d "$SSTLOG" ]; then
mkdir $SSTLOG
fi
# check Kerberos ticket and AFS token (author: slammel):
# ------------------------------------
echo "Checking Kerberos ticket/AFS token:"
/bin/rm ${SSTINITERR} 1>/dev/null 2>&1
/usr/bin/klist 2> ${SSTINITERR}
RC=$?
if [ ${RC} -ne 0 ]; then
MSG="no valid Kerberos ticket, klist=${RC}"
echo " ${MSG}"
if [ -t 0 ]; then
# attached terminal, prompt user to kinit for 25 hours
/usr/bin/kinit -l 25h [email protected]
if [ $? -ne 0 ]; then
exit ${RC}
fi
else
/usr/bin/Mail -s "$0 ${MSG}" ${SSTMAIL} < ${SSTINITERR}
exit ${RC}
fi
fi
/bin/rm ${SSTINITERR} 1>/dev/null 2>&1
/usr/bin/aklog 2> ${SSTINITERR}
RC=$?
if [ ${RC} -ne 0 ]; then
MSG="unable to acquire AFS token, aklog=${RC}"
echo " ${MSG}"
/usr/bin/Mail -s "$0 ${MSG}" ${SSTMAIL} < ${SSTINITERR}
exit ${RC}
fi