HOW-TO: Run a Pure-Data (PD) Patch on Startup Boot in Ubuntu-server

11.06.06
This tutorial shows how I Run a Pure-Data (PD) Patch on Startup Boot in Ubuntu-server

I assume this can work in ubuntu (x-win) too – it wil just work on a different runlevel (see the end of this text). Took me a few days to figure this one out! Hope it helps to cut the time down for others.

I put the following script named “pd_start” in /etc/init.d/

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

#! /bin/sh

# Check for missing binaries (stale symlinks should not happen)
PD_BIN=/usr/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/bin/pd -nogui -noaudio \
-lib /usr/lib/pd/extra/zexy \
-lib /usr/lib/pd/extra/maxlib \
-path /usr/lib/pd/extra \
-path /home/mark \
/home/mark/netpd_server.pd &
;;
## mind the &!!
stop)
echo -n “Shutting down NetPd Server”
## Stop daemon with killproc(8) and it 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
#######################

Then I changed the permissions on the file:

$ sudo chmod 755 pd_start

Then I ran the following command:

$ sudo update-rc.d -f pd_start start 99 2 3 4 5 .

Where:
- start is the argument given to the script (start, stop).
- 99 is the start order of the script (1 = first one, 99= last one)
- 2 3 4 5 are the runlevels to start

It is important NOT to forget the “.” period at the end! More info in /etc/rcS.d/README.

After hitting enter I get this:

Adding system startup for /etc/init.d/pd_start …
/etc/rc2.d/S99pd_start -> ../init.d/pd_start
/etc/rc3.d/S99pd_start -> ../init.d/pd_start
/etc/rc4.d/S99pd_start -> ../init.d/pd_start
/etc/rc5.d/S99pd_start -> ../init.d/pd_start

Then I stop my script at shutdown:

$ sudo update-rc.d -f pd_start reboot 90 0 6 .

It is important NOT to forget the “.” period at the end! After hitting enter I get this:

usage: update-rc.d [-n] [-f] remove
update-rc.d [-n] defaults [NN | sNN kNN]
update-rc.d [-n] start|stop NN runlvl [runlvl] [...] .
-n: not really
-f: force

Then I restart the server to see if it work!

$ sudo shutdown -r now

AND IT DOES!!!

To know which runlevel you are running, simply type
$ runlevel

more info about runlevels here : http://oldfield.wattle.id.au/luv/boot.html#init

This ‘HowTo’ was compiled using a suggestion from ’samyboy’ at:

http://ubuntu.wordpress.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/

and a thread from the ‘pure-data’ list at:

http://lists.puredata.info/pipermail/pd-list/2006-11/043742.html

Share and Enjoy:
  • TwitThis
  • Facebook
  • Digg
  • del.icio.us
  • LinkedIn

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment