head	1.1;
access;
symbols;
locks; strict;
comment	@# @;


1.1
date	2006.03.24.19.35.58;	author aflag;	state Exp;
branches;
next	;


desc
@@


1.1
log
@First CVS version. Already working software.
@
text
@#!/bin/sh
#  runbaby - A GUI program that let's you run other programs without opening a
#  shell or using the mouse.
#  Copyright (C) 2006 Rafael Cunha de Almeida
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

usage()
{
	echo "$0 {setpath path|install|uninstall}"
}

BIN=runbaby
GLADE=runbaby.glade

if [[ $# = "0" ]]; then
	usage
	exit 1
fi
if [[ $1 = "setpath" ]]; then
	if [ x$1 = "x" ]; then
		usage
		exit 1
	fi
	echo $2 > installpath;
elif [[ $1 = "install" ]]; then
	if [ -r installpath ]; then
		prefix=`cat installpath`
	else
		prefix=/usr/local
		echo $prefix > installpath
	fi
	PYTHON=`which python | sed s/\\\\//\\\\\\\\\\\\//g`
	if [[ x$PYTHON = "x" ]]; then
		echo -e "Dear $USER,\n\n"
		echo "You don't seem to have a python interpreter."
		echo "I'm sorry to say that it's necessary that you have one"
		echo "installed in your system. You can get a python"
		echo "interpreter from the site: www.python.org."
		echo "Once again, I'm very sorry and I wish you a good day."
		echo -e "\nSincerely,\nThe installer"
		exit 1
	fi
	echo -e "try:\n  import gtk; import gtk.glade;\nexcept:\n  print 'bad'"\
	> temp.py
	importtry=`python temp.py`
	rm -f temp.py
	if [[ x$importtry != "x" ]]; then
		echo -e "Dear $USER,\n\n"
		echo "You have a python interpreter, which is good! Althought,"
		echo "as you might already expect, I also have bad news. You"
		echo "will have to download a library called GTK and pygtk. You"
		echo "might already have GTK, but you definetly need pygtk."
		echo "Once you have them installed, you'll be able to run not"
		echo "only this piece of code, but also other programs written"
		echo "using pygtk."
		echo "The version I've tested this software is 2.8.12,"
		echo "althought it should work with gtk 2.4 and above. You can"
		echo "download gtk from www.gtk.org and pygtk from"
		echo "www.pygtk.org."
		echo -e "\nSincerely,\nThe installer"
		exit 1
	fi
	echo "Changing executable to the corrected PATH ..."
	sedprefix=`echo $prefix | sed s/\\\\//\\\\\\\\\\\\//g`
	sed s/\$GLADE_PATH/`echo $sedprefix\\\\/lib`/g runbaby.py |\
	sed s/\$PYTHON/`echo $PYTHON`/ > tmp.py
	echo "Copying files to the correct location ..."
	chmod 755 tmp.py
	if [ ! -e $prefix/bin ]; then mkdir -p $prefix/bin; fi
	if [ ! -e $prefix/lib ]; then mkdir -p $prefix/lib; fi
	cp tmp.py $prefix/bin/$BIN
	rm -f tmp.py
	cp runbaby.glade $prefix/lib/runbaby.glade
elif [[ $1 = "uninstall" ]]; then
	if [ ! -e installpath ]; then
		echo "Hi $USER!"
		echo "I couldn't find the file \"installpath\" in the current"
		echo "directory. Without it I don't know where I installed the"
		echo "program, so I can't uninstall it. Sorry."
		exit 1
	fi
	prefix=`cat installpath`
	echo "Warning: this will remove the following files"
	echo "$prefix/bin/$BIN"
	echo "$prefix/lib/runbaby.glade"
	echo "Do you want to continue? (y/n)"
	read x
	if [[ $x = "y" || $x = "Y" ]]; then
		rm -f $prefix/bin/$BIN $prefix/lib/runbaby.glade
	fi
fi
@
