#!/bin/bash # # a first shot at automating an install of the LOGON open-source MT platform. # # # the root directory for the DELPH-IN installation; everything else will end up # in sub-directories of $LOGONROOT. the default is a directory `logon' in the # user home directory. # if [ -z "${LOGONROOT}" ]; then LOGONROOT=${HOME}/logon fi # # for the script to be independent of where specific OS versions keep their # files (e.g. on some Solaris boxes one might have to use `gtar' for a decent # GNU tar(1)). # MKDIR=mkdir LS=ls RM=rm LN="ln -s" GREP=grep WGET="wget --quiet --timestamping" GUNZIP="gunzip -c" TAR="tar xf -" SED=sed build="latest" # # process command-line options; for now, either set root directory and toggle # choice of target OS. # while [ $# -gt 0 ]; do case ${1} in -r|--root) LOGONROOT=${2}; shift 2; ;; *) echo "install: invalid parameter \`${1}'."; exit 1; ;; esac done # # create the target directory, unless it exists already. if the target exists # as a non-directory (e.g. plain file), then stop here. # if [ ! -d ${LOGONROOT} -a -e ${LOGONROOT} ]; then echo "install: \`${LOGONROOT}' exists as a non-directory." exit 1; fi [ -d ${LOGONROOT} ] || ${MKDIR} ${LOGONROOT} # # next, determine the current operating system, one of `linux' (x86), `solaris' # (sparc), or `windows' (x86); anything else will require manual installation. # if [ "$OSTYPE" = "linux" -o "$OSTYPE" = "linux-gnu" ]; then # # apparently, (some) Debian installations come with an older uname(1), where # `-i' is not available :-{. (11-mar-05; oe) # if uname -i > /dev/null 2>&1; then cpu=$(uname -i) if [ "${cpu}" = "unknown" ]; then cpu=$(uname -m); fi else cpu=$(uname -m) fi case "${cpu}" in i?86) os="linux.x86.32" ;; x86_64) os="linux.x86.64" ;; *) echo "install: unknown Linux architecture (check \`uname -m'); exit." exit 1; esac elif [ "$OSTYPE" = "darwin" ]; then # # _fix_me_ # work out what OSTYPE et al. actually are for MacOS. (31-mar-06; oe) # : else echo "install: unknown target architecture (check \`uname -m'); exit." exit 1; fi # # for use by the LKB, make sure there is a temporary directory available. # if [ "${os%%.*}" == "linux" -o "$os" == "macos" ]; then [ -d ${HOME}/tmp ] || ${MKDIR} ${HOME}/tmp; fi # # now, obtain all the installation archives, defaulting to the latest version # for those packages distributed from the LOGON download server # cd ${LOGONROOT} [ -d ${LOGONROOT}/Archives ] || ${MKDIR} ${LOGONROOT}/Archives for i in lkb_data.tgz lkb_${os}.tgz lkb_source.tgz; do echo -n "install: \`${i}' ..."; ( cd Archives; ${WGET} http://lingo.stanford.edu/ftp/${build}/${i}; ) if [ -f Archives/${i} ]; then ( cd lkb; ${GUNZIP} ${LOGONROOT}/Archives/${i} | ${TAR}; ) echo " done."; else echo " missing."; fi if [ -f ${LOGONROOT}/lkb/etc/lkb ]; then [ -f ${LOGONROOT}/bin/lkb ] && ${RM} ${LOGONROOT}/bin/lkb; ${LN} ${LOGONROOT}/lkb/etc/lkb ${LOGONROOT}/bin/lkb; fi done # # the [incr tsdb()] software, for now, is only available on Linux and Solaris # and shares a source directory with the LKB # if [ "${os%%.*}" == "linux" -o "$os" == "solaris" ]; then for i in itsdb_libraries.tgz itsdb_tsdb.tgz itsdb_capi.tgz \ itsdb_${os}.tgz itsdb_data.tgz itsdb_documentation.tgz \ itsdb_source.tgz; do echo -n "install: \`${i}' ..."; ( cd Archives; ${WGET} http://lingo.stanford.edu/ftp/${build}/${i}; ) ( cd lkb; ${GUNZIP} ${LOGONROOT}/Archives/${i} | ${TAR}; ) if [ -f Archives/${i} ]; then ( cd lkb; ${GUNZIP} ${LOGONROOT}/Archives/${i} | ${TAR}; ) echo " done."; else echo " missing."; fi done fi # # for integration of the LKB et al. with emacs(1), we need the following # echo -n "install: \`eli.tgz' ..."; ( cd Archives; ${WGET} http://lingo.stanford.edu/ftp/etc/eli.tgz ) ${GUNZIP} ${LOGONROOT}/Archives/eli.tgz | ${TAR} echo " done."; # # finally, a couple of grammars (and the Matrix `meta-grammar') ... # for i in erg.tgz matrix.tgz spanish.tgz; do echo -n "install: \`${i}' ..."; ( cd Archives; ${WGET} http://lingo.stanford.edu/ftp/${build}/${i}; ) if [ -f Archives/${i} ]; then ( cd ${LOGONROOT}; ${GUNZIP} ${LOGONROOT}/Archives/${i} | ${TAR}; ) echo " done."; else echo " missing."; fi done # # some grammars remain optional packages, for right now. # if [ -n "${JACY}" ]; then echo -n "install: \`japanese.tar.gz' ..."; ( cd Archives; ${WGET} -O japanese.tgz ${JACY}; ) ${GUNZIP} ${LOGONROOT}/Archives/japanese.tgz | ${TAR}; echo " done."; fi # # # on demand, also get the Redwoods treebanks and corresponding versions of the # ERG; by default, only get the latest growth (currently the fifth). # if [ -n "${TSDBHOME}" ]; then echo -n "install: \`erg.jan-06.tgz' ..."; ( cd Archives; ${WGET} http://redwoods.stanford.edu/ftp/6th/erg.jan-06.tgz; ) ${GUNZIP} ${LOGONROOT}/Archives/erg.jan-06.tgz | ${TAR}; echo " done."; for i in vm ec jh; do file="itsdb_${i}.tgz" echo -n "install: \`${file}' ..."; ( \ cd Archives; \ ${WGET} http://redwoods.stanford.edu/ftp/6th/${file}; \ if [ -f ${file} ]; then \ cd ${TSDBHOME}; \ ${GUNZIP} ${LOGONROOT}/Archives/${file} | ${TAR}; \ echo " done."; \ else \ echo " missing."; \ fi; \ ) done fi # # on Linux, we need to make sure that a (good) version of the Motif library is # available for the LKB; unless we find one in `/usr/X11R6/lib' that looks as # if it were right, install our own and suggest that the user that they tell # their shell how to find it. this all is a little iffy ... # if [ false -a "${os}" == "linux.x86.32" ]; then if [ -e /usr/X11R6/lib/libXm.so.2 ]; then link=$(${LS} -l /usr/X11R6/lib/libXm.so.2 | grep -i "lesstif") if [ -n "${link}" ]; then echo echo "most likely the Motif library \`/usr/X11R6/lib/libXm.so.2' is not" echo "suitable for the LKB; un-install LessTiff and install OpenMotif." echo sleep 5; fi fi [ -d ${LOGONROOT}/lib ] || ${MKDIR} ${LOGONROOT}/lib; [ -d ${LOGONROOT}/lib/${os} ] || ${MKDIR} ${LOGONROOT}/lib/${os}; ( \ cd lib/${os}; \ ${WGET} http://lingo.stanford.edu/ftp/lib/linux/libXm.so.2; \ ${WGET} http://lingo.stanford.edu/ftp/lib/linux/libXm.so.3; \ ) fi # # finally, instruct users on how to set-up their local start-up files # echo echo "add the following to the file \`~/.bashrc' in your home directory:" echo echo " export LOGONROOT=${LOGONROOT}" echo echo "to permanently record the root directory of your DELPH-IN installation;" echo "if you are a (t)csh(1) user, use \`setenv' rather than \`export'; e.g." echo echo " setenv LOGONROOT ${LOGONROOT}" echo echo "in the file \`~/.cshrc' (or \`~/.tcshrc') in your home directory." echo echo "to run the LKB and [incr tsdb()] from within emacs(1), add the following" echo "to the file \`.emacs' in your home directory:" echo echo " (let ((root (or (getenv \"LOGONROOT\")" echo " \"${LOGONROOT}\")))" echo " (if (file-exists-p (format \"%s/lkb/etc/dot.emacs\" root))" echo " (load (format \"%s/lkb/etc/dot.emacs\" root) nil t t)))" echo