#!/bin/sh

USER=`whoami`

# test if user match
if [ "$USER" == "kk" ]; then

echo "user $USER ok"

# test if 2 arguments aviable
 	if [ "$3" == "" ]; then
		echo first argument: file name 
		echo second argument: description in english, max 50 zeichen
		echo third argument: description in german, so viel wie möglich
	else 
		# test if second argument small then 50 bytes
		# 49 bytes for desc if IndexOptions +SuppressLastModified +SuppressSize
 		# in .htaccess defined

		BYTES=`echo $2 | wc -c`
		if  [ "$BYTES" -gt "49" ]; then
			echo description in english $2 ist zu gross: $BYTES 
			echo description muss kleiner als 50 sein
		else
			# writes desc to .htaccess
			echo AddDescription  '"'$2'"' $1
			echo AddDescription  '"'$2'"' $1 >> .htaccess

			echo -- `date +%y%m%d` --    >> README.txt
			echo     >> README.txt
			echo $1: >> README.txt
			echo     >> README.txt
			echo $3  >> README.txt
			echo     >> README.txt

			chmod -v 644 $1
			cp -vpr $1 $1.txt
		fi		
	fi
else 

echo wrong user!
fi

