#!/bin/bash # # Example event hook for the OML server, copying an Sqlite database elsewhere # when the last client has exited. # Copyright 2012 National ICT Australia (NICTA), Australia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # irodsUserName=rods irodsHost=emmy9.casa.umass.edu irodsPort=1247 irodsZone=geniRenci export irodsUserName irodsHost irodsPort irodsZone # XXX: You might need to initialise the iRODS password for the UNIX user # running tho oml2-server by running 'iinit' to create ~/.irods/.irodsA on its # behalf for iput to work IPUT=iput echo "OML HOOK READY" while read COMMAND ARGUMENTS; do echo "`date` '${COMMAND}' '${ARGUMENTS}'" >> /tmp/oml2-server-hook.log case "${COMMAND}" in "DBCLOSED") case "${ARGUMENTS}" in file:*) DBFILE=${ARGUMENTS/file:/} echo ${IPUT} ${OPTION} ${DBFILE} >> /tmp/oml2-server-hook.log FILENAME=`echo $DBFILE | awk -F"/" '{print $5}'` SLICE=`echo $FILENAME | awk -F"-" '{print $1}'` EXP=`echo $FILENAME | awk -F"-" '{print $2}'` EXP=`echo $EXP | awk -F"." '{print $1}'` DATE=`date` echo "b db ${DBFILE} closed, pushing to iRODS..." >> /tmp/oml2-server-hook.log if [[ $SLICE =~ ^gimi[0-40] ]]; then echo "Entered iput and imeta phase" >> /tmp/oml2-server-hook.log iput -f ${DBFILE} /geniRenci/home/$SLICE/$FILENAME ichmod -M own $SLICE /geniRenci/home/$SLICE/$FILENAME imeta add -d /geniRenci/home/$SLICE/$FILENAME Date ${DATE} imeta add -d /geniRenci/home/$SLICE/$FILENAME SliceName ${SLICE} imeta add -d /geniRenci/home/$SLICE/$FILENAME ExpName ${EXP} fi echo "a iRODS operation finished" >> /tmp/oml2-server-hook.log ;; *) echo "db ${ARGUMENTS} closed, but don't know how to handle it..." >&2 ;; esac ;; "EXIT") echo "exiting..." >&2 exit 0 ;; *) ;; esac done