#!/bin/bash unset DISPLAY; unset LUI; if [ -z "${LOGONROOT}" ]; then echo "parse: unable to determine \$LOGONROOT directory; exit."; exit 1; fi # # include a shared set of shell functions and global parameters, including the # architecture identifier .LOGONOS. # . ${LOGONROOT}/etc/library.bash; tsdb="$LOGONROOT/bin/tsdb" source="--source"; while [ $# -gt 0 -a "${1#-}" != "$1" ]; do case ${1} in --binary) source=""; shift 1; ;; --source) source="--source"; shift 1; ;; -c|--compress) action="compress"; shift 1; ;; -t|--thin) action="thin"; shift 1; ;; --drop) action="drop"; gold=${2}; shift 2; ;; --cat) cat="--cat"; shift 1; ;; *) echo "usage: itsdb { -c | -t } directory; exit."; exit 1; esac done if [ -z "${action}" ]; then echo "usage: itsdb { -c | -t } directory; exit."; exit 1; fi if [ ! -d ${1} ]; then echo "itsdb: invalid or missing directory \`${1}'; exit."; exit 1; fi directory="${1}"; if [ -z "${LOGONLOG}" ]; then LOGONLOG=${LOGONROOT}/log; fi LOG=${LOGONLOG}/itsdb.${date}.log; case "${action}" in compress) tmp="/tmp/.itsdb.tmp.${USER}.$$" find ${directory} -name relations | sed 's@/relations@@g' > ${tmp}.dbs while read i; do ${tsdb} -home "${i}" -query "info relations" \ | egrep '^[a-zA-Z0-9_-]+:$' | sed 's@:$@@g' > ${tmp}.files for j in $(cat ${tmp}.files); do file="${i}/${j}"; if [ -s "${file}" ]; then echo -n "compressing \`${file}' ... "; gzip -f -9 "${file}"; echo "done"; fi done done < ${tmp}.dbs /bin/rm -f ${tmp}.dbs ${tmp}.files ;; thin) # # _fix_me_ # the code below hard-wires the grammar to be used, viz. the ERG. use the # `--erg' et al. options much like the `parse' script. (30-jul-09; oe) # unset DISPLAY; unset LUI; # # erase the target directory, if need be, and invoke the normalizer # target="${directory}.1"; if [ -a ${target} ]; then /bin/rm -rf ${target}; fi { loadup; echo "(lkb:read-script-file-aux \"${LOGONROOT}/lingo/erg/lkb/script\")"; echo "(setf tsdb::*redwoods-trees-hook* nil)"; echo "(setf tsdb::*redwoods-semantix-hook* \"mrs::get-mrs-string\")"; echo "(setf tsdb::*redwoods-thinning-normalize-p* t)"; echo "(tsdb::browse-trees \"${directory}\" :strip \"${target}\")"; echo "(excl:exit)"; } | ${LOGONROOT}/bin/logon ${source} ${cat} \ -I base -locale no_NO.UTF-8 -qq 2>&1 | tee ${LOG} ;; drop) set -x; tmp="/tmp/.itsdb.tmp.${USER}.$$" ${tsdb} -home "${directory}" -query "info relations" \ | egrep '^[a-zA-Z0-9_-]+:$' | sed 's@:$@@g' > ${tmp} for j in $(cat ${tmp}); do file="${directory}/${j}"; if [ -f ${file} -a -z "$(cat ${file})" ]; then echo "cat ${file} > ${gold}/${j}"; elif [ -s ${file}.gz ]; then echo "cat ${file}.gz > ${gold}/${j}.gz"; else echo "itsdb: missing or invalid relation file for \`${j}'; exit." exit 1; fi done /bin/rm -f ${tmp} ;; esac