98 lines
1.7 KiB
Bash
Executable file
98 lines
1.7 KiB
Bash
Executable file
#!/bin/sh
|
|
# Parameter: Datenverzeichnis Zielverzeichnis [--copy (fuer cp statt ln -s)]
|
|
|
|
set -ue
|
|
|
|
ROOT_DIRS="doku ausLese cover"
|
|
ROOT_FILES="start.html autorun.inf news.txt favicon.ico"
|
|
REMOVE_LIST="ausLese/chaosradio"
|
|
|
|
DEFAULT_ACTION="ln -s"
|
|
|
|
|
|
filtere_verzeichnisse()
|
|
{
|
|
cd "$1"
|
|
find -xtype d -maxdepth 1 | sed 's#^\./##' | sed '/^.$/d ; /^\.svn/d; /^_/d ; /^_bilder$/d'
|
|
}
|
|
|
|
filtere_dateien()
|
|
{
|
|
cd "$1"
|
|
find -xtype f -maxdepth 1 | sed 's#^\./##' | sed '/^Makefile$/d ; /\.tex$/d ; /\.lyx$/d ; /^WARNINGS$/d ; /\.py$/d ; /\.make$/d ; /\.log$/d ; /\.pl$/d ; /-unpatched\.html$/d'
|
|
}
|
|
|
|
bearbeiteVerzeichnis()
|
|
{
|
|
[ ! -e "$1" ] && return 0
|
|
local old_pwd=`pwd`
|
|
mkdir "$2"
|
|
cd "$2"
|
|
for a in `filtere_verzeichnisse "$1"`
|
|
do [ "$a" != "." ] && bearbeiteVerzeichnis "$1/$a" "$2/$a"
|
|
done
|
|
|
|
for a in `filtere_dateien "$1"`
|
|
do $ACTION "$1/$a" .
|
|
done
|
|
cd "$old_pwd"
|
|
}
|
|
|
|
#### hier geht es los ########
|
|
|
|
# eventuelle Parameter auswerten
|
|
|
|
FERTIG=nein
|
|
|
|
while [ "$FERTIG" == "nein" -a $# -gt 2 ]
|
|
do case "$1" in
|
|
--copy )
|
|
ACTION="cp"
|
|
shift
|
|
;;
|
|
--link )
|
|
ACTION="ln -s"
|
|
shift
|
|
;;
|
|
--help )
|
|
echo "syntax: $0 [ --copy | --link ] DATENVERZEICHNIS ZIELVERZEICHNIS"
|
|
exit 0
|
|
;;
|
|
--* )
|
|
echo "unbekannter Parameter: $1"
|
|
exit 1
|
|
;;
|
|
* )
|
|
FERTIG=ja
|
|
;;
|
|
esac
|
|
done
|
|
|
|
[ $# -lt 2 ] && echo "falsche Anzahl von Parametern!" && exit 1
|
|
|
|
DATA=$1
|
|
ZIEL=$2
|
|
|
|
set +u
|
|
[ -z "$ACTION" ] && ACTION="$DEFAULT_ACTION"
|
|
set -u
|
|
|
|
# Verzeichnis anlegen
|
|
[ -d "$ZIEL" ] && rm -r "$ZIEL"
|
|
mkdir -p "$ZIEL"
|
|
cd "$ZIEL"
|
|
|
|
#### Wurzelverzeichnis ######
|
|
for a in $ROOT_FILES
|
|
do $ACTION "$DATA/$a" .
|
|
done
|
|
|
|
###### die anderen Verzeichnisse #########
|
|
|
|
for a in $ROOT_DIRS
|
|
do bearbeiteVerzeichnis "$DATA/$a" "$ZIEL/$a"
|
|
done
|
|
|
|
for a in $REMOVE_LIST
|
|
do rm -r "$a"
|
|
done
|