From 5ccbda4c78df4db47033dc66938cb73284287cd4 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Tue, 29 Jul 2008 02:27:27 +0200 Subject: localikiwikicreatesite: implemented interactive initial cleanup as needed. --- localikiwikicreatesite | 82 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 2 deletions(-) (limited to 'localikiwikicreatesite') diff --git a/localikiwikicreatesite b/localikiwikicreatesite index 5602456..4da465d 100755 --- a/localikiwikicreatesite +++ b/localikiwikicreatesite @@ -11,8 +11,9 @@ # # TODO: Explicitly replace ~ with $HOME for shell use, and $ENV{'HOME'} for Perl # TODO: Quote variables everywhere -# TODO: Implement --verbose option -# TODO: Check for name collision and ask (except when --force is enabled) +# TODO: Implement --verbose and --quiet options (and fail if both are set) +# TODO: Implement --force option +# TODO: check for required helper commands (like make for originated sites) # set -e @@ -67,6 +68,20 @@ exit1() { exit 1 } +ask() { + echo -n "$1 (y/N)? " + read response + case "$response" in + y|Y) + : + ;; + *) + return 1 + ;; + esac + return +} + git_setenv_work() { set -e @@ -150,6 +165,69 @@ CFGDIR=~/private_webdata/$project DESTDIR=~/public_websites/$host DESTSRCDIR=~/public_websites/$srchost +# Create parent if missing / remove if already existing +# (eg. leave out SRCDIR if subdir of CFGDIR) +mkdirchildlist="CFGDIR DESTDIR DESTSRCDIR" +rmdirlist="CFGDIR DESTDIR DESTSRCDIR" + +mkdirchildfoundlist='' +for item in $mkdirchildlist; do + eval "childdir=\"\$$item\"" + parentdir="`dirname "$childdir"`" + if [ ! -d "$parentdir" ]; then + eval "mkdirchild_$item='(will create parent dir)'" + mkdirchildfoundlist="$mkdirchildfoundlist $item" + fi +done + +rmdirfoundlist='' +for item in $rmdirlist; do + eval "dir=\"\$$item\"" + if [ -d "$dir" ]; then + eval "rmdir_$item='(will replace existing!)'" + rmdirfoundlist="$rmdirfoundlist $item" + fi +done + +if [ "$quiet" != 'yes' ]; then + cat <