We use Scrobby at home to scrobble whatever MPD plays to our Last.fm account. One problem, when we reboot the server and we forget to start scrobby manually, well, sometimes days of data doesn’t get scrobbled.
Thus I wrote a†preliminary†init-script that should fix the problem for now. It’s based upon skeleton and, I know, it’s not the best script ever nor does it follow all the lsb rules and best practices, but it’s a start, it works and I’ll fix the ‘decency’ when I have time to spare.
Use at your own risk:
! /bin/sh
BEGIN INIT INFO
Provides: skeleton
Required-Start: $remote_fs
Required-Stop: $remote_fs
Default-Start: 2 3 4 5
Default-Stop: 0 1 6
Short-Description: Scrobby init-script
Description: An init-script to manage Scrobby,
a Last.fm scrobbler for MPD.
END INIT INFO
# Author: Daniele Sluiters
Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Last.fm MPD scrobbler"
NAME=scrobby
DAEMON=/usr/local/bin/$NAME
DAEMON_ARGS="/etc/scrobby.conf"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
Define LSB log_* functions.
Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
Function that starts the daemon/service
#
do_start()
{
$DAEMON $DAEMON_ARGS
}
#
Function that stops the daemon/service
#
do_stop()
{
/bin/kill cat $PIDFILE
rm -f $PIDFILE
}
case "$1" in
start)
if [ -e $PIDFILE ]; then
log_daemon_msg "$DESC $NAME already started"
log_end_msg 1
else
log_daemon_msg "Starting $DESC" "$NAME "
do_start
log_end_msg 0
fi
;;
stop)
if [ -ne $PIDFILE ]; then
log_daemon_msg "$DESC $NAME is not started "
log_end_msg 1
else
log_daemon_msg "Stopping $DESC" "$NAME "
do_stop
log_end_msg 0
fi
;;
restart|force-reload)
#
If the "reload" option is implemented then remove the
'force-reload' alias
# log_daemon_msg "Restarting $DESC" "$NAME" do_stop do_start ;; *)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2 exit 3 ;; esac :
Place that script named scrobby in /etc/init.d/ and then do the following:
sudo chmod +x scrobbysudo update-rc.d scorbby defaults
Now you have an init script and one that will be processed during boot so that scrobby is started.





0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.