Here's one that can start/stop/restart/status without using terminal commands. Requires the zenity package, which I think is fairly common.
I haven't figured out a good way to get a sudo prompt if needed, although another script could ask for sudo password and then pass it to this script as described at
http://techrepublic.com.com/5208-12853- ... ID=2541628
- Code: Select all
#!/bin/bash
PID=""
function get_pid {
PID=`ps ax |grep java |grep subsonic |cut -d " " -f 1`
}
function stop {
(
echo "# Stopping Subsonic..."
get_pid
until [ -z $PID ]; do
kill $PID; sleep 1
get_pid
done
echo "# Subsonic stopped."; sleep 1
) |
zenity --progress --pulsate
}
function start {
(
echo "# Starting Subsonic..."
get_pid
/var/subsonic/standalone/subsonic.sh | $ZENITY
echo "# " $ZENITY
while [ -z $PID ]; do
get_pid; sleep 1
done
get_pid;
echo "# Subsonic started. PID = " $PID
) |
zenity --progress --pulsate
}
get_pid
if [ -z $PID ]; then
ans=$(zenity --list \
--text "Subsonic is not running. What do you want to do?" \
--radiolist \
--column "" --column "Action" \
TRUE "Start Subsonic")
case $ans in
"Start Subsonic")
start
;;
*)
esac
else
ans=$(zenity --list \
--text "Subsonic is running with PID=$PID. What do you want to do?" \
--radiolist \
--column "" --column "Action" \
TRUE "Restart Subsonic" \
FALSE "Stop Subsonic")
case $ans in
"Restart Subsonic")
stop
start
;;
"Stop Subsonic")
stop
;;
*)
esac
fi
exit 0