[cli] improved wrapper script

This commit is contained in:
Michael Monreal 2010-08-14 11:28:34 +01:00 committed by Hylke Bons
parent 1cd1ac4224
commit 38eb444e88

View file

@ -2,76 +2,59 @@
pidfile=/tmp/sparkleshare/sparkleshare.pid pidfile=/tmp/sparkleshare/sparkleshare.pid
# Create a directory to save the pid to start() {
case $1 in
start)
if [ -e "${pidfile}" ]; then if [ -e "${pidfile}" ]; then
sparklepid=`cat ${pidfile}` sparklepid=`cat ${pidfile}`
if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ] if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then
then echo "SparkleShare is already running."
echo "SparkleShare is already running"
exit 0 exit 0
else else
echo "SparkleShare stale pid file found, starting a new instance" echo "SparkleShare stale pid file found, starting a new instance."
rm -f $pidfile rm -f $pidfile
fi fi
fi fi
echo -n "Starting SparkleShare..." echo -n "Starting SparkleShare... "
mkdir -p /tmp/sparkleshare/ mkdir -p /tmp/sparkleshare/
# Start SparkleShare in the background and save the pid # Start SparkleShare in the background and save the pid
mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 & mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 &
PID=$! echo $! > ${pidfile}
echo $PID > /tmp/sparkleshare/sparkleshare.pid echo "Done."
echo " Done." }
;;
stop) stop() {
if [ -e "${pidfile}" ]; then if [ -e "${pidfile}" ]; then
sparklepid=`cat ${pidfile}` sparklepid=`cat ${pidfile}`
if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then
echo -n "Stopping SparkleShare..." echo -n "Stopping SparkleShare... "
kill ${sparklepid} kill ${sparklepid}
rm -f ${pidfile} rm -f ${pidfile}
echo " Done." echo "Done."
else else
echo "SparkleShare isn't running, removing stale pid file" echo "SparkleShare is not running, removing stale pid file."
rm -f ${pidfile} rm -f ${pidfile}
fi fi
else else
echo "SparkleShare isn't running." echo "SparkleShare is not running."
fi fi
}
case $1 in
start|--start)
start
;; ;;
stop|--stop)
restart) stop
if [ -e "/tmp/sparkleshare/sparkleshare.pid" ]; then
echo -n "Stopping SparkleShare..."
kill `cat /tmp/sparkleshare/sparkleshare.pid`
rm -f /tmp/sparkleshare/sparkleshare.pid
echo " Done."
else
echo "SparkleShare isn't running."
fi
if [ -e "/tmp/sparkleshare/sparkleshare.pid" ]; then
echo "SparkleShare is already running."
else
echo -n "Starting SparkleShare..."
# Start SparkleShare in the background and save the pid
mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 &
PID=$!
echo $PID > /tmp/sparkleshare/sparkleshare.pid
echo " Done."
fi
;; ;;
restart|--restart)
--help | help) stop
start
;;
help|--help)
mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" --help mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" --help
;; ;;
*) *)
echo "Usage: sparkleshare {start|stop|restart|help}" echo "Usage: sparkleshare {start|stop|restart|help}"
;; ;;
esac esac