#!/bin/sh
# $Id: INSTALL,v 1.8 2012-02-18 23:30:51 drmiller Exp $

export INSTALLPATH=${HOME}/tele-sb-sim

# 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}"

e=0
for title in Switchboard Telephone; do
	if [[ ( -d ~/.gnome || -d ~/.gnome2 ) && -d ~/Desktop ]]; then
		echo "installing GNOME desktop ${title} shortcut..."
		cat ${title}.desktop.tmplt | while read line; do
			eval "echo \"${line}\""
		done >~/Desktop/${title}.desktop
		if [[ $? -ne 0 ]]; then ((e+=1)); fi
	fi
done
if [[ ${e} -gt 0 ]]; then
	sleep 5
	exit 1
fi
echo "Ready to launch ${PWD}/run-Switchboard and ${PWD}/run-Telephone"
