3
get_giis_from_section() { # args: file_name, section_name; output: array of URLs
4
# sed script to find all the sections in file_name with the given section_name and parse out the URLs
7
# if a section start is found, jump to ":section" to process it
9
# if this line is not a section start, append it to the hold buffer
11
# if this is the last line, jump to ":section" to process it
13
# otherwise skip the ":section" part
17
# put the lines from the hold buffer (containing the whole
18
# previous section) the patter space and also put the line
19
# from the pattern space (containing the header of the next
20
# section) to the hold buffer
22
# if it starts with the section name we want, print it
23
/^\s*\[\s*'$2'\s*\]/ p
24
# otherwise dont do anything: skip this section
25
}' $1 | sed -n 's/^\s*giis\s*=\s*"\(.*\)"\s*$/\1/p' # get the URLs from the lines starting with giis=
29
get_giis_from_file() { # args: file_name; output: array of URLs
36
echo '=== ARC client configuration conversion ==='
39
# 1. giis options in client section in $HOME/.arc/client.conf
40
giislist=`get_giis_from_section $HOME/.arc/client.conf client`
41
if [[ ! $giislist ]]; then
42
# 2. giis options in common section in $HOME/.arc/client.conf
43
giislist=`get_giis_from_section $HOME/.arc/client.conf common`
44
if [[ ! $giislist ]]; then
45
# 3. $HOME/.nggiislist (one GIIS per line, ARC <= 0.5.48)
46
giislist=`get_giis_from_file $HOME/.nggiislist`
47
if [[ ! $giislist ]]; then
48
# 4. giis options in client section in $ARC_LOCATION/etc/arc.conf
49
giislist=`get_giis_from_section $ARC_LOCATION/etc/arc.conf client`
50
if [[ ! $giislist ]]; then
51
# 5. giis options in common section in $ARC_LOCATION/etc/arc.conf
52
giislist=`get_giis_from_section $ARC_LOCATION/etc/arc.conf common`
53
if [[ ! $giislist ]]; then
54
# 6. $ARC_LOCATION/etc/giislist (one GIIS per line)
55
giislist=`get_giis_from_file $ARC_LOCATION/etc/giislist`
56
if [[ ! $giislist ]]; then
57
# 7. giis options in client section in /etc/arc.conf
58
giislist=`get_giis_from_section /etc/arc.conf client`
59
if [[ ! $giislist ]]; then
60
# 8. giis options in common section in /etc/arc.conf
61
giislist=`get_giis_from_section /etc/arc.conf common`
62
if [[ ! $giislist ]]; then
63
# 9. /etc/giislist (one GIIS per line)
64
giislist=`get_giis_from_file /etc/giislist`
74
conffile=$HOME/.arc/client.conf
76
echo '--- GIIS URLs ---'
79
if [[ $giislist ]]; then
81
if [[ -f $conffile ]]; then
85
if [[ ! $conffile_exists ]]; then
86
echo "Please create the file $HOME/.arc/client.conf. Edit the following as needed and put it into that file!"
88
echo "Please edit the following if needed and put it into your $HOME/.arc/client.conf!"
92
for giis in ${giislist[@]}; do
93
# use hostname as alias
94
hostname=`echo $giis | sed 's#^ldap://\(.*\):.*#\1#'`
95
# check if index or local ARIS
96
islocal=`echo $giis | grep -i "mds-vo-name=local"`
98
if [[ $islocal ]]; then
99
echo "[computing/$hostname]"
101
echo "infointerface=org.nordugrid.ldapng"
102
echo "jobinterface=org.nordugrid.gridftpjob"
104
echo "[registry/$hostname]"
106
echo "registryinterface=org.nordugrid.ldapegiis"
108
# In ARC 0.x all giises were used by default
115
echo 'No GIIS URLs found in the old configs.'
120
echo '--- ALIASes ---'
123
tempfile=`mktemp /tmp/ngclient2arc.XXXXXXXXXX`
125
if [[ $? = 0 ]]; then
126
if [[ -f $HOME/.arc/client.conf ]]; then
127
sed -n 's/^\s*alias\s*=\s*\"\s*\(.*\)\s*\"\s*$/\1/p' $HOME/.arc/client.conf > $tempfile
129
if [[ -f $HOME/.ngalias ]]; then
130
cat $HOME/.ngalias >> $tempfile
133
if [[ -s $tempfile ]]; then
135
if [[ -f $conffile ]]; then
141
if [[ ! $conffile_exists ]]; then
142
echo "Please create the file $HOME/.arc/client.conf. Edit the following as needed and put it into that file!"
144
echo "Please edit the following if needed and put it into your $HOME/.arc/client.conf!"
149
# channel the file into stdin
153
# for each alias line
155
# get the alias name (before the '=')
156
newalias=`echo $line | sed -n 's/^\s*\([^=]*\)\s*=.*$/\1/p'`
157
# get the URLs (after the '=')
158
urls=`echo $line | sed -n 's/^[^=]*=\(.*\)$/\1/p'`
161
# if the URL can be found among the aliases (before an '=')
162
if [[ `sed -n '/^\s*'$url'\s*=.*$/ p' $tempfile` ]]; then
163
# then this is an alias and not a URL
164
# TODO: automatically add group= to each section
165
echo "To use $newalias as a group alias put group=$newalias in the [computing/$url] block"
167
# else this is a real URL
168
echo "[computing/$newalias]"
170
echo "infointerface=org.nordugrid.ldapng"
171
echo "jobinterface=org.nordugrid.gridftpjob"
182
echo 'No aliases found in the old config files.'
192
echo ' Error creating tempfile: alias conversion failed.'
197
echo '--- Active jobs ---'
199
echo 'In order to use arc* commands to manipulate the jobs you submitted with ngsub,'
200
echo 'you have to run the arcsync command with specifying clusters and/or GIISes:'
201
echo ' arcsync [-c cluster1 -c cluster2 ...] [-g giis1 -g giis2 ...]'
b'\\ No newline at end of file'