#!/bin/bash

dir=`dirname $0`
cmd="$dir/uninsui"

## check soffice.bin run##########################################################################
isrun=`ps ax  | grep /opt/neoshineoffice/program/soffice.bin |awk '{print $5}' |sed "/grep/d"`


#while [ "$isrun" == "/opt/neoshineoffice/program/soffice.bin" ];do
while [ -n "$isrun" ];do
	#zenity --question --title="中标普华Office " --text="中标普华Office程序或快速启动正在运行，请关闭后重试。"  --ok-label="重试(_R)" --cancel-label="取消"
	choseexit=`/opt/neoshineoffice/msg.py`
	if (( $choseexit == 1 ));then
		kill -9 `ps ax  | grep /opt/neoshineoffice/program/soffice.bin|awk '{print $1}'` >/dev/null 2>&1
		break;
	elif (( $choseexit == 2  ));then
		if [ -z `ps ax  | grep /opt/neoshineoffice/program/soffice.bin |awk '{print $5}' |sed "/grep/d"` ];then
			break;
		fi
	else
		exit 0;
	fi		
done

rm -rf ~/.neoshineoffice/
## check soffice.bin run##########################################################################

if [ ${UID} = 0 ]; then
        exec  $cmd  >/dev/null 2>&1
        exit 
fi

xsu=`which beesu gksu kdesu 2>&- | head -1`

if [ $xsu ]; then
        $xsu  $cmd  >/dev/null 2>&1
        exit
fi

xterm=`which gnome-terminal terminal  konsole xterm rxvt eterm 2>&- | head -1`

if [ -z "$xsu" ]; then  
	$xterm -e "$dir/textoutmod >/dev/null 2>&1" && exit
fi


