#!/usr/bin/bash # # MPMV # # Microphoto Image Mover and Renamer # # Takes TIF images submitted by a petrologist # to the configured drop-box and renames them, # and places them for consumption on the # IODP-USIO web site. # # To rename files, this script depends on the # association madehis script depends on the TS/Microphoto application # for data entry and handling accomplished using the # java Thin Section & Microphoto application. The camera files # dropped are renamed according to the name # generated and stored in the database by the # closeup application. # # Run this script from the pubsweb # crontab every 30 minutes # Must invoke bash shell so as to pick up predefined # environment variables, e.g.: # # 17,47 * * * * /usr/bin/bash --login /image2/microphoto/mpmv 1>> /image2/microphoto/mpmv.log 2>> /image2/microphoto/mpmv.log # # mpmv.conf # # Configuration file specifying: # - database login to use for data lookup # - drop location for incoming images to be processed # - web server location to which JPG images are published # the %leg% field is required and is replaced by the current leg # # e.g. # :: mpmv.conf :: # DBLOGIN=guest/guest@ship # DROPBOX=/image2/microphoto # WEBPATH=/image/%leg%_ER/VOLUME/CORES/microphoto # # The entries may appear in any order. # # # Dependencies # # Script is dependent on these facilities being # available on the search path: # # bash, chmod, cp, grep, ls, perl, sed, sqlplus, tr # # No file is renamed unless it can be uniquely associated # with a database record via a unique combination of leg and # image number. # # This script is designed for the shipboard environment. # Only one leg is operated on at a time based on the value # of the defaults.leg field. # # Script is dependent on these environment variables # currently assumed to have been set in the login profile: # # MAGICK_HOME=/usr/local/ImageMagick # ORACLE_BASE=/usr/local/oracle/u01/app/oracle # ORACLE_HOME=$ORACLE_BASE/product/8.1.7 # ORACLE_SID=SHIP # TNS_ADMIN=$ORACLE_HOME/network/admin # LD_LIBRARY_PATH=/usr/local/lib:$MAGICK_HOME/lib # PATH=.:/usr/bin:/usr/local/bin:$ORACLE_HOME/bin:/usr/ccs/bin:/usr/ucb:/usr/xpg4/bin:$MAGICK_HOME/bin # echo MICROPHOTO IMAGE MOVE AND PROCESSING date # Test for the presence of our configuration file if [ ! -f ${0}.conf ]; then echo Expected the configuration file ${0}.conf echo with content similar to these lines: echo ' ' echo DBLOGIN=guest/guest@ship echo DROPBOX=/image2/microphoto echo WEBPATH=/image/%leg%_ER/VOLUME/CORES/microphoto echo ' ' echo Configuration file must reside in the same echo location as this script and have the same name. exit 1 fi # mpmv.conf: read the configuration file # Define database login to use DBLOGIN=`grep DBLOGIN ${0}.conf | sed -e 's/^.*=//'` # Incoming TIFs go here DROPBOX=`grep DROPBOX ${0}.conf | sed -e 's/^.*=//'` # Get the current leg from the database LEG=`sqlplus -s ${DBLOGIN}<