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

export INSTALLPATH=${HOME}/wang600apc

# 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 ~/Wang600Files
	cp -v progs/* ~/Wang600Files
fi
base="wang600"
title="Wang600"
if [[ ( -d ~/.gnome || -d ~/.gnome2 ) && -d ~/Desktop ]]; then
	echo "installing GNOME desktop shortcuts..."
	export WANG600PATH="${INSTALLPATH}"
	cat ${base}.desktop.tmplt | while read line; do
		eval "echo \"${line}\""
	done >~/Desktop/${title}.desktop

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

java -cp wang600.jar w600initProps

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