64 lines
1.3 KiB
Bash
64 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
pidfile=${HOME}/SparkleShare/.tmp/sparkleshare.pid
|
|
|
|
start() {
|
|
if [ -e "${pidfile}" ]; then
|
|
sparklepid=`cat ${pidfile}`
|
|
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."
|
|
rm -f $pidfile
|
|
fi
|
|
fi
|
|
|
|
echo -n "Starting SparkleShare... "
|
|
mkdir -p /tmp/sparkleshare/
|
|
if [ -n "$SSH_AGENT_PID" ]; then
|
|
mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 &
|
|
else
|
|
ssh-agent mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 &
|
|
fi
|
|
echo $! > ${pidfile}
|
|
echo "Done."
|
|
}
|
|
|
|
stop() {
|
|
if [ -e "${pidfile}" ]; then
|
|
sparklepid=`cat ${pidfile}`
|
|
if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then
|
|
echo -n "Stopping SparkleShare... "
|
|
kill ${sparklepid}
|
|
rm -f ${pidfile}
|
|
echo "Done."
|
|
else
|
|
echo "SparkleShare is not running, removing stale pid file."
|
|
rm -f ${pidfile}
|
|
fi
|
|
else
|
|
echo "SparkleShare is not running."
|
|
fi
|
|
}
|
|
|
|
case $1 in
|
|
start|--start)
|
|
start
|
|
;;
|
|
stop|--stop)
|
|
stop
|
|
;;
|
|
restart|--restart)
|
|
stop
|
|
start
|
|
;;
|
|
help|--help)
|
|
mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" --help
|
|
;;
|
|
*)
|
|
echo "Usage: sparkleshare {start|stop|restart|help}"
|
|
;;
|
|
esac
|
|
|