setup-site: Use cp -p and sed -i instead of just sed old > new
[deb/packages.git] / bin / setup-site
1 #!/bin/bash
2
3 topdir=$1
4 site=$2
5
6 if [ -z "$topdir" -o -z "$site" ];
7 then
8         echo "Usage: setup-site <topdir> <site>" >&2
9         exit 1
10 fi
11
12 echo -e "Using\n\ttopdir=$topdir\n\tsite=$site"
13
14 find "$topdir" -maxdepth 2 -name '*.sed.in' | while read file;
15 do
16         wdir=$(dirname "$file")
17         newfile="$wdir/"$(basename "$file" .sed.in)
18         echo -e "processing\n\t$file\n->\t$newfile"
19         cp -p "$file" "$newfile"
20         sed -i -e "s#%SITE%#$site#g;s#%TOPDIR%#$topdir#g" "$newfile"
21         diff -u "$file" "$newfile"
22 done