-
Notifications
You must be signed in to change notification settings - Fork 0
/
vomsdir.sh.in
93 lines (82 loc) · 2.36 KB
/
vomsdir.sh.in
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
#!/bin/sh
# File: vo-support-vomsdir/vomsdir.sh
# Author: Dennis van Dok <[email protected]>
#
# Copyright 2012 Stichting FOM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script is installed as a module in
# /usr/share/vo-support/module/vomsdir.sh
# It is normally run by %post or %preun scriptlets in RPM packages
# for each installed VO. The first argument is the main command.
# Commands understood by this script are:
# configure [list of VOs to add]
# deconfigure [list of VOs to remove]
#
# Other commands are silently ignored. The list of VOs may be empty.
#
# The configure command will install the VO's .lsc file(s) in
# $X509_VOMS_DIR/$vo/
# from /usr/share/vo-support/vos/$vo/.
# The default if X509_VOMS_DIR is not set is to use
# /etc/grid-security/vomsdir/
#
# The deconfigure command will uninstall these files.
sysconfdir=@sysconfdir@
if [ $# -lt 1 ] ; then
echo "$0 requires a command" >&2
exit 1
fi
if [ -n "$VO_DATA_DIR" ]; then
# must be absolute path because we symlink to it
if ! echo "$VO_DATA_DIR" | grep -q '^/' ; then
VO_DATA_DIR=`pwd`/"$VO_DATA_DIR"
fi
vosdir="$VO_DATA_DIR/vos"
else
vosdir=/usr/share/vo-support/vos
fi
if [ -n "$X509_VOMS_DIR" ]; then
vomsdir="$X509_VOMS_DIR"
else
vomsdir=$sysconfdir/grid-security/vomsdir
fi
cmd="$1"
shift
add_vo_to_vomsdir() {
if [ -d "$vosdir/$1" ]; then
test -d "$vomsdir/$1" || mkdir -p "$vomsdir/$1"
for i in "$vosdir/$1"/*.lsc ; do
if [ ! -e "$vomsdir/$1"/`basename "$i"` ]; then
ln -s "$i" "$vomsdir/$1/"
fi
done
fi
}
remove_vo_from_vomsdir() {
rm -f "$vomsdir/$1"/*
test -d "$vomsdir/$1" && rmdir "$vomsdir/$1"
}
case "$cmd" in
configure)
test -e $vomsdir || mkdir -p $vomsdir
for vo in "$@" ; do
add_vo_to_vomsdir $vo
done
;;
deconfigure)
for vo in "$@" ; do
remove_vo_from_vomsdir $vo
done
;;
esac