2

I am running a headless raspberry pi system, that will eventually be a generative music player. I am now trying to get jackd to run at startup but not entirely sure how.

I can run the command

jackd -R -dalsa

And jack runs fine. However this stops me from being able to run any more commands in the console, with the last few lines being

ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback

I have put the jackd in an init.d script also, however the same problem appears. What I would like is a way for jackd to start up in a seperate process, or a way for it to hand "control" back to other startup scripts or the user.

M problem is different that the commented one in that I would like to start a daemon (I did not know this before, but now it seems like the sensible option)

2 Answers2

0

Depending upon distro and version, you can do the following (from old school to latest technique):

OLD SCHOOL:

vi /etc/rc.local
cd /path/where/jackd/
jackd -R dalsa &>/dev/null &

NEWER WAY:

vi /etc/init.d/jack

(paste this in then modify paths etc):

#!/bin/sh
#
# Startup script for Jack Daemon
#
# chkconfig: 2345 08 92
# description: Sample jackd init.d script.
# processname: jackd
# pidfile: /var/run/jackd/jackd.pid
# config: /etc/jackd.conf

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

[ -x /usr/sbin/jackd ] || exit 0

# Local jackd config
# test -f /etc/sysconfig/jackd && . /etc/sysconfig/jackd

# See how we were called.
case "$1" in
  start)
        echo -n "Starting Jack Daemon: "
        daemon jackd
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/jackd
        ;;
  stop)
        echo -n "Stopping Jack Daemon: "
        killproc jackd
        rm -f /var/run/jackd/jackd.pid
        RETVAL=$?
        echo
### heres the fix... we gotta remove the stale files on restart
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/jackd
        ;;
  status)
        status jackd
        RETVAL=$?
        ;;
  restart|reload)
        $0 stop
        $0 start
        RETVAL=$?
        ;;
  condrestart)
        [ -e /var/lock/subsys/jackd ] && $0 restart
        RETVAL=$?
        ;;
  *)
        echo "Usage: jackd {start|stop|status|restart|reload|condrestart}"
        exit 1
esac

exit $RETVAL

Now, save the above and do this:

chkconfig --help

(should return usage info)

chkconfig --add jackd
chkconfig --level 2345 jackd on

now you are ready to start it:

Old school:

/etc/init.d/jackd start

Newer way:

service jackd start
  • Hey, thanks for the long thought out answer! I am not entirely sure which method to use, for startup scripts in my buildroot system I have been using busybox, which has an rcs script in init.d that sequentally calls all scripts named S01-s99

    I am thinking that a nice way to do this would be to call the "newer way" script from within one of these. So I need to convert this script to run on my system. A few problems:

    /etc/rc.d/init.d/functions - this is not present on my system, what functions are needed?

    /etc/jackd.conf - this is also not present, what would you recomend to create?

    – jackdoff Feb 07 '18 at 10:55
  • 1
    Based upon your description, and you are learning - I would see if you have /etc/rc.local file - and add:

    cd /path/where/jackd/ (crlf) jackd -R dalsa &>/dev/null &

    – Ozz Nixon Feb 08 '18 at 02:15
0

I found a preexisiting script within init.d that was starting the log daemon and adapted it for starting jackd.

#!/bin/sh
    #
    # Start jackd
    #

    [ -x /usr/bin/jackd ] || exit 0

    start() {
        printf "Starting JACKD: "
        start-stop-daemon -b -S -m -p /var/run/jackd.pid --exec usr/bin/jackd -- -R -dalsa
        echo "JACK OK"
    }

    stop() {
        printf "Stopping JACKD: "
        start-stop-daemon -K -q -p /var/run/jackd.pid
        echo "JACK STOPPED OK"
    }

    case "$1" in
      start)
        start
        ;;
      stop)
        stop
        ;;
      restart|reload)
        stop
        start
        ;;
      *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
    esac

    sleep 1

    exit $?