#!/bin/sh








#********************************************************************************
#*** Configuration                                                            ***
#********************************************************************************
DCACHE_HOME="/opt/d-cache"




#********************************************************************************
#*** Initialisations                                                          ***
#********************************************************************************
pool_name="$1"

#check whether the “pool_name”-parameter was set
if [ -z "${pool_name}" ]; then
        printf "Please specify a pool name.\n" >&2
        exit 2
fi




#********************************************************************************
#*** Determine The Pool Directory                                             ***
#********************************************************************************
#get pool listing
pool_listing="$( "${DCACHE_HOME}"/bin/dcache pool ls  |  grep "${pool_name}" )"

#check whether exactly one result was found
if [ "$( printf "%s\n" "${pool_listing}"  |  wc -l )"   -ne   1 ]; then
        printf "The pool with the name “${pool_name}” was not found or the listing could not be parsed.\n" >&2
        exit 1
fi

#parse the pool listing
pool_directory="$( printf "%s" "${pool_listing}"  |  sed 's/.* //' )"
#check whether the pool directory acutally exists
if [ ! -d "${pool_directory}" ]; then
        printf "The determined pool directory “${pool_directory}” does not exist.\n" >&2
        exit 1
fi




#********************************************************************************
#*** List The Files In The Pool’s “/data”-Directory                           ***
#********************************************************************************
ls -1 "${pool_directory}"/data
















#Copyright © 2009, Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>.
#All rights reserved.
#
#
#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 3 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, see <http://www.gnu.org/licenses/>.

