How-tos/GetAListOfAllFilesOnAPool: print_actual_pool_files.sh

File print_actual_pool_files.sh, 2.6 KB (added by calestyo, 3 years ago)

prints the PNFS-IDs of all files that are actually within a given pool

Line 
1#!/bin/sh
2
3
4
5
6
7
8
9
10#********************************************************************************
11#*** Configuration                                                            ***
12#********************************************************************************
13DCACHE_HOME="/opt/d-cache"
14
15
16
17
18#********************************************************************************
19#*** Initialisations                                                          ***
20#********************************************************************************
21pool_name="$1"
22
23#check whether the “pool_name”-parameter was set
24if [ -z "${pool_name}" ]; then
25        printf "Please specify a pool name.\n" >&2
26        exit 2
27fi
28
29
30
31
32#********************************************************************************
33#*** Determine The Pool Directory                                             ***
34#********************************************************************************
35#get pool listing
36pool_listing="$( "${DCACHE_HOME}"/bin/dcache pool ls  |  grep "${pool_name}" )"
37
38#check whether exactly one result was found
39if [ "$( printf "%s\n" "${pool_listing}"  |  wc -l )"   -ne   1 ]; then
40        printf "The pool with the name “${pool_name}” was not found or the listing could not be parsed.\n" >&2
41        exit 1
42fi
43
44#parse the pool listing
45pool_directory="$( printf "%s" "${pool_listing}"  |  sed 's/.* //' )"
46#check whether the pool directory acutally exists
47if [ ! -d "${pool_directory}" ]; then
48        printf "The determined pool directory “${pool_directory}” does not exist.\n" >&2
49        exit 1
50fi
51
52
53
54
55#********************************************************************************
56#*** List The Files In The Pool’s “/data”-Directory                           ***
57#********************************************************************************
58ls -1 "${pool_directory}"/data
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75#Copyright © 2009, Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>.
76#All rights reserved.
77#
78#
79#This program is free software: you can redistribute it and/or modify
80#it under the terms of the GNU General Public License as published by
81#the Free Software Foundation, either version 3 of the License, or
82#(at your option) any later version.
83#
84#This program is distributed in the hope that it will be useful,
85#but WITHOUT ANY WARRANTY; without even the implied warranty of
86#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
87#GNU General Public License for more details.
88#
89#You should have received a copy of the GNU General Public License
90#along with this program.  If not, see <http://www.gnu.org/licenses/>.