#!/bin/bash
#  version date: 2010-06-15 22:44:57 -0400 
#
#  launcher:  launches code from a bundled script
#
#  Copyright 2010, Sugar Labs
#  Frederick Grose <fgrose@sugarlabs.org>
#
#  Usage:
#       ${TMPDIR}/launcher $*
#
#       Used with the 'bundle' package builder to control the launch environment
#       for a bundled script.  See 'bundle' documentation.
#        
#       $*  are options or arguments given to the bundleFile and passed on to
#       launcher.
#        
#  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; version 2 of the License.
#
#  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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

TMPDIR=${TMPDIR:-/tmp}

su --session-command="pwd" 2>/dev/null 1>2&
case $? in
    0)
        su_option=--session-command
        ;;
    *)
        su_option=--command
        ;;
esac
su ${su_option}="${TMPDIR}/newSugarStick $* " root
exit 0
