#!/bin/sh
# $Id: INSTALL,v 1.5 2013-12-09 17:04:26 drmiller Exp $

export INSTALLPATH=${HOME}/wang1200wps

# 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 examples ]]; then
        mkdir -p ~/Wang1200Files
        cp -v examples/* ~/Wang1200Files
fi
base="wang1200"
title="Wang1200"
if [[ ( -d ~/.gnome || -d ~/.gnome2 ) && -d ~/Desktop ]]; then
	echo "installing GNOME desktop shortcut..."
	export WANG1200PATH="${INSTALLPATH}"
	cat ${base}.desktop.tmplt | while read line; do
		eval "echo \"${line}\""
	done >~/Desktop/${title}.desktop
fi
echo "Ready to launch ${PWD}/run"
