[PD] pd patch startup at boot - ubuntu-server

derek holzer derek at x-i.net
Sat Nov 4 15:34:24 CET 2006


Hi Mark,

mark edward grimm wrote:

> I took a look at this thread:
> http://lists.puredata.info/pipermail/pd-list/2004-10/022984.html
> 
> and gave it a whirl with no luck on ubuntu... it seems
> like there should be an easier way to do this.

I took a bunch of notes from various sources on this. Almost all are 
from posts on the PD list, however I don't have the authors names 
attached anymore. Apologies to the original posters!

But anyway, you should be able to find a solution somewhere in these 
suggestions! It largely depends on whether or not you are running X 
(which I imagine on a server you are not!)

best,
d.

-----------

to autostart on linux



put a symlink in your rc3.d (or with whatever runlevel you boot by default,
this is set in /etc/inittab)

called S19pd_start (any number, but be sure, all other important processes
are started before/lower numbers...) to a script named pd_start



linux then calls this script with the argument "start" when booting. the
script "pd_start" looks like:



#################################  beginning of script
#############################





#! /bin/sh

# Check for missing binaries (stale symlinks should not happen)
PD_BIN=/usr/local/pd/bin/pd
test -x $PD_BIN || exit 5

case "$1" in
     start)
       echo -n "Starting PD"
       ## Start daemon with startproc(8). If this fails
       ## the return value is set appropriately by startproc.
       /usr/local/pd/bin/pd -nogui -noadc -audiobuf 20 -r 22050 \
       -lib /usr/local/lib/pd/pdp/pdp \
       -lib /usr/local/lib/pd/externs/zexy \
       -path /home/marius \
       -path /usr/local/lib/pd/pdp \
       -path /usr/local/lib/pd/externs/zexy \
       /home/marius/application.pd &
       ;;
       ## mind the &!!!
     stop)
       echo -n "Shutting down FOO "
       ## Stop daemon with killproc(8) and if this fails
       ## killproc sets the return value according to LSB.

       kill 'cat /var/run/pd.pid'
       ;;

     restart)
       ## Stop the service and regardless of whether it was
       ## running or not, start it again.
       $0 stop
       $0 start
       ;;

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

################################## end of script #######################









-- /etc/rc.d/rc.local:
#!/bin/sh
echo -n "starting pd..."
PATH=/sbin:/bin:/usr/sbin:/usr/bin
/usr/local/bin/pd_start
-- 

-- /usr/local/bin/pd_start:
#! /bin/sh
echo -n "starting pd..."
PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin
cd /home/glui
pd -verbose -nogui -nomidi \
-lib /usr/lib/pd/extra/OSC \
-lib /usr/lib/pd/extra/zexy \
-open /home/glui/proj/LIDARmacher/pd/GPlayerStereo.pd &
-- 



########################


make an ".xinitrc" file in your home directory.  in it put something like:

	hdspmixer &

you can also safely put other stuff in there if you like:

	jackd -d alsa &
	pd -jack mypathc.pd &
	xterm

but you might be better off doing this in some other star script and
killing X after you know hdspmixer has been run.   you only need to run
hdspmixer once - this initializes the card somehow.

---------

to login to X automagically

use mingetty on tty1 with the option --autologin
you set that in /etc/inittab

mine says this:
	1:2345:respawn:/sbin/getty 38400 tty1

change it to something like this:
	1:2345:respawn:/sbin/mingetty  --autologin myusername tty1

where "myusername" is the name you want to log into.

then in .bash_profile under "myusername", you'll want somthing to
automatically startx, like this:

if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
   startx
fi



###################

Using this script you can run Pd as a daemon:

scripts/debian/init.d/pd

That means you can do this kind of stuff:

/etc/init.d/pd start
/etc/init.d/pd stop
/etc/init.d/pd restart

You'll most likely need to use it in -nogui mode, but it does that by 
default.  You can configure which user account pd runs as also.  If you 
have root access, you can run pd as any user, otherwise you'll have to 
run it as yourself.



########################



-- 
derek holzer ::: http://www.umatic.nl
---Oblique Strategy # 75:
"Ghost echoes"




More information about the Pd-list mailing list