#! /bin/bash

. /app/DBus/function.sh

DaemomPid=`ps | grep "dbus-daemon" | grep "\-\-fork" | awk -F' ' '{print $1}'`;

if [ "$DaemomPid" == "" ]; then
    CreateDbus;
elif [ "$DaemomPid" != "" ]; then
    Pid=`cat /app/DBus/DBUS_SESSION_BUS_PID`;
    ADDRESS=`cat /app/DBus/DBUS_SESSION_BUS_ADDRESS`;
    if [ "$Pid" == "$DaemomPid" ]; then
        ExportVariable;
    else
        kill $DaemomPid;
        CreateDbus;
    fi
fi
