From 23c6dbb18b991ee31b04a032c3168e13cfdefd19 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Mon, 10 Dec 2007 19:37:46 +0100 Subject: [PATCH] setup-site: Various improvements Allow reading the variables from a config file ./setup-site.conf so that one doesn't have to specify them each time. Be less chatty per default but add -v option the get the old behaviour. Warn about too many arguments. --- bin/setup-site | 28 +++++++++++++++++++++------- setup-site.conf | 2 ++ 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 setup-site.conf diff --git a/bin/setup-site b/bin/setup-site index a0a7839..a3ceb98 100755 --- a/bin/setup-site +++ b/bin/setup-site @@ -1,22 +1,36 @@ #!/bin/bash -topdir=$1 -site=$2 +[ -f ./setup-site.conf ] && source ./setup-site.conf -if [ -z "$topdir" -o -z "$site" ]; +if [ "$1" = "-v" ]; then - echo "Usage: setup-site " >&2 + verbose=1 + shift +fi + +if [ -n "$1" -a -n "$2" ]; +then + topdir=$1 + site=$2 + shift + shift +fi + +if [ -z "$topdir" -o -z "$site" -o \( "$#" -gt 0 \) ]; +then + echo "Usage: setup-site [-v] [ ]" >&2 exit 1 fi echo -e "Using\n\ttopdir=$topdir\n\tsite=$site" -find "$topdir" -maxdepth 2 -name '*.sed.in' | while read file; +find "$topdir" -maxdepth 4 -name '*.sed.in' | while read file; do wdir=$(dirname "$file") newfile="$wdir/"$(basename "$file" .sed.in) - echo -e "processing\n\t$file\n->\t$newfile" + echo -e "processing\t$file" + [ -n "$verbose" ] && echo -e "->\t$newfile" cp -p "$file" "$newfile" sed -i -e "s#%SITE%#$site#g;s#%TOPDIR%#$topdir#g" "$newfile" - diff -u "$file" "$newfile" + [ -n "$verbose" ] && diff -u "$file" "$newfile" done diff --git a/setup-site.conf b/setup-site.conf new file mode 100644 index 0000000..edaf9b6 --- /dev/null +++ b/setup-site.conf @@ -0,0 +1,2 @@ +topdir=/srv/packages.debian.org +site=packages.debian.net -- 2.39.2