-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwgetcern.sh
executable file
·60 lines (54 loc) · 1.03 KB
/
wgetcern.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
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash -e
case `uname` in
Linux) ECHO="echo -e" ;;
*) ECHO="echo" ;;
esac
usage() {
$ECHO "wgetcern.sh [options] <url>"
$ECHO
$ECHO "Options:"
$ECHO "--cert \tw/ --key, use certificate access for CERN SSO (otherwise kerberos)"
$ECHO "--key \tw/ --cert, use certificate access for CERN SSO (otherwise kerberos)"
exit 1
}
CERT=""
KEY=""
URL=""
while [ $# -gt 0 ]; do
case $1 in
--cert)
CERT=$2
shift; shift
;;
--key)
KEY=$2
shift; shift
;;
-*)
$ECHO "Unknown option $1"
exit 1
;;
*)
if [ -n "$URL" ]; then
$ECHO "Unexpected extra argument $1"
exit 1
fi
URL=$1
shift
;;
esac
done
if [ -z "$URL" ]; then
usage
fi
CONNECT=""
if [ -n "$CERT" ] && [ -n "$KEY" ]; then
CONNECT="--cert $CERT --key $KEY"
elif [ -z "$CERT" ] && [ -z "$KEY" ]; then
CONNECT="--krb"
else
usage
fi
cookie=~/private/ssocookie.txt
cern-get-sso-cookie $CONNECT -r -u $URL -o $cookie
wget -nv -e robots=off -nH --cut-dirs=10 --load-cookies=$cookie --save-cookies=$cookie --no-check-certificate -r --no-parent $URL