Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JCookie.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2#
3# \author mdejong
4#
5script=${0##*/}
6
7if [ -z $JPP_DIR ]; then
8 echo "Variable JPP_DIR undefined."
9 exit
10fi
11
12source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
13
14set_variable COOKIE `getCookie`
15set_variable TIMEOUT_S 20
16
17if do_usage $*; then
18 usage "$script"\
19 "\nUtility script to check database cookie file."\
20 "\nIf needed, the user is prompted to create new cookie file."
21fi
22
23# test cookie
24
25if [[ -f $COOKIE ]]; then
26
27 JPrintDB -C $COOKIE -q detector >& /dev/null
28
29 if (( $? != 0 )); then
30 echo "Remove broken cookie file $COOKIE";
31 rm -f $COOKIE
32 fi
33fi
34
35if [[ ! -f $COOKIE ]]; then
36
37 if [[ -z "$DBCOOKIE" ]]; then
38
39 echo "Enter input within $TIMEOUT_S seconds."
40 echo -n "User name: "
41 read -t $TIMEOUT_S USR
42 if (( $? != 0 )); then
43 fatal "Timeout at user input."
44 fi
45 echo -n "Password: "
46 read -t $TIMEOUT_S -s PWD
47 echo
48 if (( $? != 0 )); then
49 fatal "Timeout at user input."
50 fi
51
52 set_variable SERVER `JServerDB`
53
54 wget --no-check-certificate -q \
55 "https://${SERVER}/home.htm?usr=${USR}&pwd=${PWD}&persist=y&freenetbits=16" \
56 -O $COOKIE && sed -i -- "s/sid=/.in2p3.fr\\tTRUE\\t\/\\tTRUE\\t0\\tsid\\t/g" $COOKIE
57
58 if [[ ! -f $COOKIE ]]; then
59 fatal "No cookie $COOKIE"
60 fi
61 else
62
63 echo "Using DBCOOKIE; unset to disable."
64 fi
65fi
66
67JPrintDB -C $COOKIE -q detector >& /dev/null
68
69CHECK_EXIT_CODE