#!/bin/bash
## Directory where zhe zbnfjax-folder will be copied
DST="/usr/share/vishia"
## Directory where the zbnfjax-shell command will be copied
BATDST="/usr/bin"
echo Symbolic links from /usr/-tree to this files:
echo This setup will create a symbolic link to the 'ZBNF/zbnfjax' directory tree 
echo from $DST/zbnfjax
echo and create $BATDST/zbnfjax which calls 'zbnfjax\batch_template\zbnfjax'-shell file 
echo So the files of this download were used immediately, 
echo though there will be found in /usr/...
echo If it is not desired, please edit this file
if test "$USER" == "root"; then
	
	if test ! -d $DST; then mkdir -p $DST; fi
	## remove exisiting folder because it may be confuse.
	if test -d $DST/zbnfjax; then rm -r $DST/zbnfjax; fi
	##symbolic link of the directory zbnfjax from DST to the current dir
	ln -f -s $PWD/../zbnfjax $DST/zbnfjax
	
	## Copy an existing $BATDST/zbnfjax-script as zbnfjax_old, because there may be some user changes.
	##delete it because a hard link isn't possible
	if test -f $BATDST/zbnfjax; then 
		cp $BATDST/zbnfjax $BATDST/zbnfjax.old
    rm $BATDST/zbnfjax 
	fi
	## Copy start file
  cp $PWD/../zbnfjax/batch_template/zbnfjax-call $BATDST/zbnfjax
	##
	echo show symbolic link on usr/share/vishia:
	ls -all /usr/share/vishia
	echo show copied file on /usr/bin:
	ls -all /usr/bin/zbnfjax
  cat /usr/bin/zbnfjax
	echo done.
else
	echo ...	
	echo Hint This batch works only correct if you have access rights.
	echo Please type the root password:
	sudo ./setup_Unix_symblink.sh
fi

