3 # Configuration first : set the local repository
4 # where the code can be found
5 # Test number of arguments
8 echo " Usage : bash_nukem repository_directory vm (should be senslab or senslab2) and \
9 federation option (0 (not federated),1(other senslab) , 2(ple) 3 (senslab and ple))"
14 # Check if directory exists
18 echo "RESPOSITORY: " $git_local_repo
22 # Set which vm we are working on (sfa-vm or sfa-vm2)
23 if [[ $2 = "senslab" || $2 = "senslab2" ]]
28 echo "Vm options should be senslab or senslab2, not " $2
32 if [ $vm = "senslab" ]
34 federation_commented_line_nb=2
36 federation_commented_line_nb=3
39 # First restart sfa (prevents stalling when connecting
40 # to the DB and dropping tables)
41 sudo service sfa restart
44 sudo sfaadmin.py registry nuke
46 # Drop table in slab_sfa
47 # to avoid duplicates.
48 psql -d slab_sfa -U sfa -W -q -c "drop table slice_senslab;"
49 psql -d slab_sfa -U sfa -W -q -c "drop table slab_xp;"
51 # ATTENTION :Save the config file /etc/sfa/sfa_config
54 # Remove all the remaining gid, creds files
56 sudo rm -rf /var/lib/sfa
59 sudo service sfa restart
61 # Put back the config file that you saved before
65 sudo python setup.py install
66 # sudo service sfa restart
68 # Wrote /etc/sfa/configs/site.xml
70 # /etc/sfa/default_config.xml
71 # and /etc/sfa/configs/site.xml
72 # into /etc/sfa/sfa_config.xml
75 #sudo cp $git_local_repo/sfa/senslab/config/$vm/sfa_config /etc/sfa/sfa_config
76 sudo cp $git_local_repo/sfa/senslab/config/$vm/sfa_config.xml /etc/sfa/sfa_config.xml
77 sudo cp $git_local_repo/sfa/senslab/config/$vm/default_config.xml /etc/sfa/default_config.xml
78 # sudo cp $git_local_repo/sfa/senslab/config/$vm/site.xml /etc/sfa/site.xml
79 # sudo cp $git_local_repo/sfa/senslab/config/$vm/site_config /etc/sfa/configs/site_config
80 # sudo ln -s ldap_config.py /etc/sfa/ldap_config.py
81 sudo cp $git_local_repo/sfa/senslab/config/registries.xml /etc/sfa/registries.xml
82 sudo cp $git_local_repo/sfa/senslab/config/aggregates.xml /etc/sfa/aggregates.xml
86 0) echo "No federation at all"
87 #Insert a # on every beginning of line except if there is 'aggregates'
88 sed -i '/aggregates/!s/^/#/g' /etc/sfa/aggregates.xml
89 sed -i '/aggregates/!s/^/#/g' /etc/sfa/registries.xml
91 1) echo "Setting up federation with other senslab "
92 # Commenting out senslab and ple, lines 2 and 4 OR
93 # Commenting out senslab2 and ple, lines 3 and 4
94 sed -i "${federation_commented_line_nb} s/^/#/" /etc/sfa/aggregates.xml
95 sed -i "${federation_commented_line_nb} s/^/#/" /etc/sfa/registries.xml
96 sed -i '4 s/^/#/' /etc/sfa/aggregates.xml
97 sed -i '4 s/^/#/' /etc/sfa/registries.xml
100 2) echo "Setting up federation with ple "
101 sed -i '2 s/^/#/' /etc/sfa/aggregates.xml
102 sed -i '2 s/^/#/' /etc/sfa/registries.xml
103 sed -i '3 s/^/#/' /etc/sfa/aggregates.xml
104 sed -i '3 s/^/#/' /etc/sfa/registries.xml
107 3) echo "setting federation with other senslab and ple"
108 # Commenting out senslab or senslab2
109 sed -i "${federation_commented_line_nb} s/^/#/" /etc/sfa/aggregates.xml
110 sed -i "${federation_commented_line_nb} s/^/#/" /etc/sfa/registries.xml
114 #Senslab LDAP and OAR access config files
115 if [ ! -f /etc/sfa/ldap_config.py ]
117 sudo cp $git_local_repo/sfa/senslab/config/ldap_config.py /etc/sfa/ldap_config.py
120 if [ ! -f /etc/sfa/oar_config.py ]
122 sudo cp $git_local_repo/sfa/senslab/config/oar_config.py /etc/sfa/oar_config.py
125 sudo service sfa restart
127 # User stuff : clean your folder
129 rm *.sscert *.cred *.gid sfi_cache.dat
132 # Import the datbase form ldap
133 sudo sfaadmin.py registry import_registry
134 sudo service sfa restart
136 sudo rm -rf /var/lib/sfa/authorities/plc