Ticket #54: labwiki-metadata-irods-dumper.sh

File labwiki-metadata-irods-dumper.sh, 1.8 KB (added by Olivier Mehani, 11 years ago)
Line 
1#!/bin/bash
2#
3# Script storing any file it into IRODS.
4# Copyright 2013 National ICT Australia (NICTA), Australia
5#
6# Permission is hereby granted, free of charge, to any person obtaining a copy
7# of this software and associated documentation files (the "Software"), to deal
8# in the Software without restriction, including without limitation the rights
9# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10# copies of the Software, and to permit persons to whom the Software is
11# furnished to do so, subject to the following conditions:
12#
13# The above copyright notice and this permission notice shall be included in
14# all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22# THE SOFTWARE.
23#
24irodsHost=irods.example.com
25#irodsPort=1247
26export irodsHost irodsPort
27
28LOGFILE=oml2-irods-dumper.log
29function log ()
30{
31        echo "$@" >&2
32        echo "$@" >> ${LOGFILE}
33}
34
35IPUT=iput
36
37CONT=0
38while [ $CONT = 0 ] ; do
39        case "$1" in
40                --file)
41                        shift
42                        FILE=$1
43                        ;;
44                --token)
45                        shift
46                        ITICKET=$1
47                        ;;
48                --path)
49                        shift
50                        IPATH=$1
51                        ;;
52                "")
53                        ;;
54                *)
55                        log "WARN       Unknown parameter '$1'"
56                        ;;
57        esac
58        shift
59        CONT=$?
60done
61
62if [ -z "${FILE}" -o -z "${IPATH}" ]; then
63        log "ERROR      Missing parameters"
64        log "usage: $0 --file FILE --path IPATH [--token ITICKET]"
65        exit 1
66fi
67
68log "INFO       Pushing ${FILE} to irods://irodsHost:irodsPort${IPATH}"
69${IPUT} ${ITICKET:+-t ${ITICKET}} ${FILE} ${IPATH}
70rm ${FILE}