#!/bin/sh
# $Id: INSTALL,v 1.7 2014-01-15 23:20:04 drmiller Exp $

export INSTALLPATH=${HOME}/wang700apc

# path might have blanks!!!
pgm="${0}"
if [[ -L "${pgm}" ]]; then
	pgm=$(readlink "${pgm}")
fi
cwd="${pgm%/*}"
if [[ ! "${cwd}" -ef "${INSTALLPATH}" ]]; then
	echo "Moving ${cwd}..."
	rm -rf "${INSTALLPATH}"
	cp -r "${cwd}" "${INSTALLPATH}"
	exec "${INSTALLPATH}/${0##*/}"
	exit 1
fi
cd "${INSTALLPATH}"

if [[ -d progs ]]; then
	mkdir -p ~/Wang700Files
	cp -v progs/* ~/Wang700Files
fi
base="wang700"
title="Wang700"
if [[ ( -d ~/.gnome || -d ~/.gnome2 ) && -d ~/Desktop ]]; then
	echo "installing GNOME desktop shortcuts..."
	export WANG700PATH=${PWD}
	cat ${base}.desktop.tmplt | while read line; do
		eval "echo \"${line}\""
	done >~/Desktop/${title}.desktop

	base="wang700edit"
	title="Wang714"
	cat ${base}.desktop.tmplt | while read line; do
		eval "echo \"${line}\""
	done >~/Desktop/${title}.desktop
fi

java -cp wang700.jar w700initProps

echo "Ready to launch ${PWD}/run"
