Fix autostart because pid already exists even though program is not running
This commit is contained in:
parent
b11bad720c
commit
10ff054edb
32
sparkleshare
32
sparkleshare
|
@ -1,20 +1,28 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
pidfile=/tmp/sparkleshare/sparkleshare.pid
|
||||||
|
|
||||||
# Create a directory to save the pid to
|
# Create a directory to save the pid to
|
||||||
mkdir -p /tmp/sparkleshare/
|
|
||||||
|
|
||||||
if [[ "$1" == "start" ]]; then
|
if [[ "$1" == "start" ]]; then
|
||||||
if [ -e "/tmp/sparkleshare/sparkleshare.pid" ]; then
|
if [ -e "${pidfile}" ]; then
|
||||||
echo "SparkleShare is already running."
|
sparklepid=`cat ${pidfile}`
|
||||||
else
|
if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]
|
||||||
echo -n "Starting SparkleShare..."
|
then
|
||||||
|
echo "SparkleShare is already running"
|
||||||
# Start SparkleShare in the background and save the pid
|
exit 0
|
||||||
mono /usr/local/share/sparkleshare/SparkleShare.exe $2 &
|
else
|
||||||
PID=$!
|
echo "SparkleShare stale pid file found, starting a new instance"
|
||||||
echo $PID > /tmp/sparkleshare/sparkleshare.pid
|
rm -f $pidfile
|
||||||
echo " Done."
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -n "Starting SparkleShare..."
|
||||||
|
mkdir -p /tmp/sparkleshare/
|
||||||
|
# Start SparkleShare in the background and save the pid
|
||||||
|
mono /usr/local/share/sparkleshare/SparkleShare.exe $2 &
|
||||||
|
PID=$!
|
||||||
|
echo $PID > /tmp/sparkleshare/sparkleshare.pid
|
||||||
|
echo " Done."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$1" == "stop" ]]; then
|
if [[ "$1" == "stop" ]]; then
|
||||||
|
|
Loading…
Reference in a new issue