[cli] improved wrapper script
This commit is contained in:
parent
4330483db3
commit
5140ff7700
|
@ -2,17 +2,14 @@
|
|||
|
||||
pidfile=/tmp/sparkleshare/sparkleshare.pid
|
||||
|
||||
# Create a directory to save the pid to
|
||||
case $1 in
|
||||
start)
|
||||
start() {
|
||||
if [ -e "${pidfile}" ]; then
|
||||
sparklepid=`cat ${pidfile}`
|
||||
if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]
|
||||
then
|
||||
echo "SparkleShare is already running"
|
||||
if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then
|
||||
echo "SparkleShare is already running."
|
||||
exit 0
|
||||
else
|
||||
echo "SparkleShare stale pid file found, starting a new instance"
|
||||
echo "SparkleShare stale pid file found, starting a new instance."
|
||||
rm -f $pidfile
|
||||
fi
|
||||
fi
|
||||
|
@ -21,12 +18,11 @@ case $1 in
|
|||
mkdir -p /tmp/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 $! > ${pidfile}
|
||||
echo "Done."
|
||||
;;
|
||||
}
|
||||
|
||||
stop)
|
||||
stop() {
|
||||
if [ -e "${pidfile}" ]; then
|
||||
sparklepid=`cat ${pidfile}`
|
||||
if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then
|
||||
|
@ -35,43 +31,30 @@ case $1 in
|
|||
rm -f ${pidfile}
|
||||
echo "Done."
|
||||
else
|
||||
echo "SparkleShare isn't running, removing stale pid file"
|
||||
echo "SparkleShare is not running, removing stale pid file."
|
||||
rm -f ${pidfile}
|
||||
fi
|
||||
else
|
||||
echo "SparkleShare isn't running."
|
||||
echo "SparkleShare is not running."
|
||||
fi
|
||||
}
|
||||
|
||||
case $1 in
|
||||
start|--start)
|
||||
start
|
||||
;;
|
||||
|
||||
restart)
|
||||
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
|
||||
stop|--stop)
|
||||
stop
|
||||
;;
|
||||
|
||||
--help | help)
|
||||
restart|--restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
help|--help)
|
||||
mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" --help
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: sparkleshare {start|stop|restart|help}"
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
|
Loading…
Reference in a new issue