#!/bin/bash
#
# EnterSafe Token Manager 
#

if [ ! -f /usr/local/ngsrv/ngslotd ]; then
	echo "ERR: ngslotd is not installed!"
	echo "Please install ngslotd and start it before running the manager."
	exit 1
fi

ps ax|awk '{print $5}'|grep -q ngslotd
if [ $? != 0 ]; then
	echo "ERR: ngslotd is not started!"
	echo "Please start ngslotd before running the manager."
	exit 1
fi

ps ax|awk '{print $5}'|grep -q pkimanager_admin-bin
if [ $? == 0 ]; then
	echo "pkimanager_admin is running."
	exit 1
fi

ps ax|awk '{print $5}'|grep -q pkimanager-bin
if [ $? == 0 ]; then
	echo "Already running."
	exit 1
fi

TEMP_ENV=$GTK_IM_MODULE
export GTK_IM_MODULE="xim"

/usr/local/ngsrv/tools/pkimanager-bin &>/dev/null

export GTK_IM_MODULE=$TEMP_ENV
