From d6f542964d437f414f948c1a94adf63d361ca55c Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 2 Oct 2008 02:25:16 +0200 Subject: [PATCH] mktmpl.sh: do not force user to specify path to pkgfs.conf every time, rather look at default location (/usr/local/etc/pkgfs.conf), current directory, or error out. --HG-- extra : convert_revision : a9d76d181c1d384c98e635bcb1375d20098c030e --- mktmpl.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mktmpl.sh b/mktmpl.sh index 6f968eb373..20f3c534dd 100755 --- a/mktmpl.sh +++ b/mktmpl.sh @@ -39,6 +39,7 @@ : ${cksum_cmd:=/usr/bin/cksum -a rmd160} : ${sed_cmd:=/usr/bin/sed} : ${db_cmd:=/usr/bin/db -q} +: ${config_file:=/usr/local/etc/pkgfs.conf} required_deps= @@ -226,9 +227,22 @@ read_parameters() write_new_template } -config_file="$1" -[ -z "$config_file" ] && \ - echo "usage: $(basename $0) /path/to/pkgfs.conf" && exit 1 +# +# If user specified a full path to pkgfs.conf, use it. Otherwise look +# at default location, and as last resort current dir. +# +if [ -n "$1" ]; then + config_file="$1" +fi + +if [ ! -f "$config_file" ]; then + config_file="$(pwd -P 2>/dev/null)/pkgfs.conf" + if [ -f "$config_file" ]; then + echo "$(basename $0): cannot find configuration file" + echo "Please speficify it, e.g: $(basename $0) /path/to/pkgfs.conf" + exit 1 + fi +fi read_parameters exit $?