begin_vo_export_to_cta.sh 2.69 KB
Newer Older
1
2
#!/bin/bash
#/******************************************************************************
3
# *                      begin_vo_export_to_cta.sh
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# *
# * This file is part of the Castor/CTA project.
# * See http://cern.ch/castor and http://cern.ch/eoscta
# * Copyright (C) 2019  CERN
# *
# * This program is free software; you can redistribute it and/or
# * modify it under the terms of the GNU General Public License
# * as published by the Free Software Foundation; either version 2
# * of the License, or (at your option) any later version.
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# * GNU General Public License for more details.
# * You should have received a copy of the GNU General Public License
# * along with this program; if not, write to the Free Software
# * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# *
21
22
23
24
# * command line tool to start preparing the export of a given VO to CTA,
# * the CAStOR successor. The tool firstly stores away CASTOR's B/W lists and
# * removes them to lock the instance, and then issues an import of all
# * CASTOR directories below a given set of top-level paths.
25
26
27
28
29
30
31
32
#
# * @author Castor Dev team, castor-dev@cern.ch
# *****************************************************************************/

# exit for any error from any command
set -e

print_usage() {
33
  echo Usage: $0 --dryrun|--doit dir1 dir2 ...
34
  echo '      dir1 dir2 ...  list of CASTOR top-level directories without prefix, e.g. /user'
35
  echo '      first option enables or disables dry-run mode'
36
37
38
39
40
41
42
43
44
45
  exit 1
}

# parse arguments
if [[ $# -eq 0 ]]; then
  print_usage
fi
while [[ $# -gt 0 ]]; do
  arg=$1
  case $arg in
46
47
48
    --dryrun) doit=0; shift;;
    --doit) doit=1; shift;;
    *) break;;
49
50
  esac
done
Giuseppe Lo Presti's avatar
Giuseppe Lo Presti committed
51
if [[ "$@" == "" ]]; then
52
53
54
55
  print_usage
fi

# if NOT dry-run
56
if [[ "$doit" == "1" ]]; then
57

Giuseppe Lo Presti's avatar
Giuseppe Lo Presti committed
58
  # backup relevant metadata from the stager
59
60
61
62
63
64
65
66
  mkdir -p ~/ctaexport
  cd ~/ctaexport
  [[ ! -x stager_listprivileges_output ]] && \
    stager_listprivileges > stager_listprivileges_output && \
    # pause the stager altogether (this destroys the B&W lists!)
    stager_removeprivilege -U:
fi

67
68
69
70
71
72
# execute the DB extraction and EOS metadata import for the given top-level dirs
for tld in $@; do
  echo `date +%Y-%m-%dT%H:%M:%S`'  Importing CASTOR tree below' $tld
  eos-import-dirs $tld
done
echo `date +%Y-%m-%dT%H:%M:%S`'  CASTOR directories import completed successfully'
Giuseppe Lo Presti's avatar
Giuseppe Lo Presti committed
73

74
75
76
77
78
79
80
# empty the CASTOR disk cache (not necessary)
#for h in `printdiskserver | grep cern.ch | awk '{print $1}'`; do
# for f in `seq -w 1 24`; do
#   deletediskcopy $h:/srv/castor/$f/
# done
#done