123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #!/bin/sh
- # script to aid copying all data and index-tmp files to one host\
- # for final combine and hash stages
- ERROR()
- {
- echo error: $*
- exit 1
- }
- USAGE()
- {
- [ -z "$1" ] || echo error: $*
- echo usage: $(basename "$0") '<options>'
- echo ' --help -h this message'
- echo ' --verbose -v more messages'
- echo ' --base=<dir> -b <dir> set the base directory [samo]'
- echo ' --to=<host> -t <host> where to rsync the files to {1 => <this_host_prefix>1}'
- echo ' --language=<xx> -l <xx> set language [en]'
- echo ' --suffix=<s> -s <s> set language suffix [pedia]'
- echo ' --work=<dir> -w <dir> workdir [work]'
- echo ' --dest=<dir> -d <dir> destdir [image]'
- exit 1
- }
- verbose=no
- base_dir=samo
- work=work
- dest=image
- debug=no
- language=en
- suffix=pedia
- to=
- getopt=/usr/local/bin/getopt
- [ -x "${getopt}" ] || getopt=getopt
- args=$(${getopt} -o hvb:t:l:s:w:d: --long=help,verbose,base:,to:,language:,suffix:,work:,dest:,debug -- "$@") ||exit 1
- # replace the arguments with the parsed values
- eval set -- "${args}"
- while :
- do
- case "$1" in
- -v|--verbose)
- verbose=yes
- shift
- ;;
- -b|--base)
- base_dir="$2"
- shift 2
- ;;
- -t|--to)
- to="$2"
- shift 2
- ;;
- -l|--language)
- language="$2"
- shift 2
- ;;
- -s|--suffix)
- suffix="$2"
- shift 2
- ;;
- -w|--work)
- work="$2"
- shift 2
- ;;
- -d|--dest)
- dest="$2"
- shift 2
- ;;
- --debug)
- debug=yes
- shift
- ;;
- --)
- shift
- break
- ;;
- -h|--help)
- USAGE
- ;;
- *)
- USAGE invalid option: $1
- ;;
- esac
- done
- [ -z "${language}" ] && USAGE language is not set
- [ -z "${to}" ] && USAGE to host is not set
- work="${work}/${language}${suffix}"
- dest="${dest}/${language}${suffix}"
- # extract numeric suffix from host name
- # expect that the rendering hosts are numbered from zero
- this_host=$(hostname --short)
- this_host_prefix=${this_host%%[0-9]}
- this_id=${this_host##*[^0-9]}
- [ -z "${this_id}" ] && this_id=0
- [ -z "${to%%[0-9]}" ] && to="${this_host_prefix}${to}"
- if [ X"${this_host}" != X"${to}" ]
- then
- d="${to}:${base_dir}/${dest}"
- case "${verbose}" in
- [yY][eE][sS])
- echo copying files to: ${d}
- ;;
- *)
- ;;
- esac
- rsync -cavHx --progress "${dest}"/*.dat "${dest}"/*.idx-tmp "${d}/"
- else
- echo warning: transfer to self ignored
- fi
|