From a06a68c8764fd63ce5467d3fe60b0d56984bcb99 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 27 Apr 2010 23:37:29 +0100 Subject: [PATCH] allow to start/stop with the wrapper script --- src/sparklepony | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/sparklepony b/src/sparklepony index 7d2eef50..5ee39fa5 100644 --- a/src/sparklepony +++ b/src/sparklepony @@ -1,11 +1,29 @@ #!/bin/bash +# Create a directory to save the pid to +mkdir -p /tmp/sparklepony/ + if [[ "$1" == "start" ]]; then - mono /usr/share/local/sparklepony/SparklePony.exe -else - if [[ "$1" == "stop" ]]; then - # Stop SparklePony.exe + if [ -e "/tmp/sparklepony/sparklepony.pid" ]; then + echo "SparklePony is already running." else - # Usage + echo -n "Starting SparklePony..." + + # Start SparklePony in the background and save the pid + mono /usr/local/share/sparklepony/SparklePony.exe & + PID=$! + echo $PID > /tmp/sparklepony/sparklepony.pid + echo " Done." + fi +fi + +if [[ "$1" == "stop" ]]; then + if [ -e "/tmp/sparklepony/sparklepony.pid" ]; then + echo -n "Stopping SparklePony..." + kill `cat /tmp/sparklepony/sparklepony.pid` + rm -f /tmp/sparklepony/sparklepony.pid + echo " Done." + else + echo "SparklePony isn't running." fi fi