#!/bin/sh
# 	Copyright (c) 2005-2008 Peter V. Saveliev
# 	Copyright (c) 2008 Eugene Prokopiev
#
# 	This file is part of Connexion project.
#
# 	Connexion 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 3 of the License, or
# 	(at your option) any later version.
#
# 	Connexion 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 Connexion; if not, write to the Free Software
# 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

p1="/usr/share/connexion-interface-cli"
p2="/usr/local/share/connexion-interface-cli"
p3="."
lib=""
socket_arg=""

[ -d $p1 ] && lib=$p1
[ -d $p2 -a -z "$lib" ] && lib=$p2
[ -d $p3 -a -z "$lib" ] && lib=$p3

echo $* | grep \-s >/dev/null 2>&1 || {
	instance=`head -1 /etc/sysconfig/connexion 2>/dev/null`
	[ ! -z "$instance" ] && socket_arg="-s /var/run/connexion/$instance-socket"
}

exec $lib/console.py $socket_arg "$@"
