-
Notifications
You must be signed in to change notification settings - Fork 0
/
site-pkgtool.sh
executable file
·95 lines (79 loc) · 1.77 KB
/
site-pkgtool.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
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
#!/bin/sh
# Install software at a given site, using pkgsrc-cmd.
# Site is first argument
# the software is the remainder
#
function usage {
echo "Usage: $0 <site> <install | remove | update> [ package ... ]" > /dev/stderr
echo " $0 <site> <init | reinit | check | dump | info | version>" > /dev/stderr
}
JIDS=site-pkgtool.jids
# Check if a VO manager proxy is available
if ! voms-proxy-info --all|grep -q Role=sgm ; then
echo "No VO manager proxy!"
exit 1
fi
# Check for Site
site=$1
shift
if [ -z "$site" ]; then
usage
exit 1
fi
resource=`awk '$1=="'$site'" { print $2 }' etc/resources.dat`
if [ -z "$resource" ]; then
echo "Site '$site' not found in etc/resources.dat." > /dev/stderr
usage
exit 1
fi
if [ $# -gt 0 ]; then
case $1 in
init | reinit | check | dump | info | version)
command=$1
shift
if [ $# -gt 0 ]; then
usage;
exit 1
fi
;;
install | remove | update)
command=$1
shift
if [ $# -le 0 ]; then
echo "No package(s) given."
usage;
exit 1
fi
;;
*)
echo "Unknown command given."
usage;
exit 1
;;
esac
else
echo "No command given."
usage
exit 1
fi
jdl=`mktemp site-pkg.jdl-XXXXXXXXXX`
cat > $jdl <<EOF
Executable = "pkgsrc-cmd.sh";
Arguments = "$command $@";
Stdoutput = "stdout";
StdError = "stderror";
InputSandbox = "pkgsrc-cmd.sh";
OutputSandbox = {"stdout","stderror"};
PerusalFileEnable = true;
PerusalTimeInterval = 60;
EOF
glite-wms-job-submit -d $USER -o $JIDS -r $resource $jdl
if [ $? -ne 0 ]; then
echo "Failed to submit job $jdl to $resource" > /dev/stderr
exit 1
fi
# enabling perusal for stdout and stderr
glite-wms-job-perusal --set -f stdout -f stderror `tail -1 $JIDS`
echo "Job submitted; check back later for results."
rm $jdl
exit 0