From cfd5fd7555334c19e09483a0dbbe0d9297d4769b Mon Sep 17 00:00:00 2001 From: "Aaron W. Swenson" Date: Fri, 14 Nov 2014 13:44:39 -0500 Subject: [PATCH] Loop Over AWL Directory Candidates Using this method we're able to loop over the candidate directories until we find what should be suitable AWL location. Further, adding additional locations is as simple as adding a new line to ${awldirs}. It does have the limitation that if the path has a new line in it (/some/ridic ulous/path), it'll treat it as two different paths. However, if somebody seriously has that, they deserve the pain. --- dba/create-database.sh | 35 ++++++++++++++++++------------ scripts/po/rebuild-translations.sh | 31 ++++++++++++++++++-------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/dba/create-database.sh b/dba/create-database.sh index b1dd1faf..d25f9d91 100755 --- a/dba/create-database.sh +++ b/dba/create-database.sh @@ -10,22 +10,29 @@ DBADIR="`dirname \"$0\"`" INSTALL_NOTE_FN="`mktemp -t tmp.XXXXXXXXXX`" -testawldir() { - [ -f "${1}/dba/awl-tables.sql" ] -} -# -# Attempt to locate the AWL directory -AWLDIR="${DBADIR}/../../awl" -if ! testawldir "${AWLDIR}"; then - AWLDIR="/usr/share/awl" - if ! testawldir "${AWLDIR}"; then - AWLDIR="/usr/local/share/awl" - if ! testawldir "${AWLDIR}"; then - echo "Unable to find AWL libraries" - exit 1 +# Candidate locations of the AWL directory +awldirs="${DBADIR}/../../awl +/usr/share/awl +/usr/share/php/awl +/usr/local/share/awl" + +# Disable globbing and use newline as seperator +set -f; IFS=' +' +for d in $awldirs ; do + if [ -f "${d}/dba/awl-tables.sql" ] ; then + AWLDIR="${d}" + break fi - fi +done + +# Renable file globbing and reset seperator +set +f; unset IFS + +if [ -z "${AWLDIR}" ] ; then + echo "Unable to find AWL libraries" + exit 1 fi export AWL_DBAUSER=davical_dba diff --git a/scripts/po/rebuild-translations.sh b/scripts/po/rebuild-translations.sh index 71916153..809fa8c2 100755 --- a/scripts/po/rebuild-translations.sh +++ b/scripts/po/rebuild-translations.sh @@ -10,17 +10,30 @@ PODIR="po" LOCALEDIR="locale" APPLICATION="davical" -AWL_LOCATION="../awl" -if [ ! -d "${AWL_LOCATION}" ]; then - AWL_LOCATION="`find .. -type d -name 'awl-*.*'`" - if [ ! -d "${AWL_LOCATION}" ]; then - AWL_LOCATION=/usr/share/awl - if [ ! -d "${AWL_LOCATION}" ]; then - echo "I can't find a location for the AWL libraries and I need those strings too" - exit 1 +awldirs="../awl +`find .. -type d -name 'awl-*.*'` +/usr/share/awl +/usr/share/php/awl +/usr/local/share/awl" + +# Disable globbing and use newline as seperator +set -f; IFS=' +' + +for d in $awldirs ; do + if [ -d "${d}" ] ; then + AWL_LOCATION="${d}" + break fi - fi +done + +# Renable file globbing and reset seperator +set +f; unset IFS + +if [ -z "${AWL_LOCATION}" ] ; then + echo "I can't find a location for the AWL libraries and I need those strings too" + exit 1 fi egrep -l '(i18n|translate)' htdocs/*.php inc/*.php inc/ui/*.php > ${PODIR}/pofilelist.tmp1