PDA

View Full Version : Start script with particular user


sniper007
January 11th, 2009, 14:36
Hi !

I would like to start script at boot time with particular regular user. Which is the best way to do that ? mybe rc.local and su - username... ?

This script set mixer lever, start shoutcast and darkice:

#!/usr/local/bin/bash
mixer vol 85:85
mixer pcm 0:0
mixer speaker 0:0
mixer line 85:85
mixer mic 0:0
mixer cd 0:0
mixer rec 85:85
mixer igain 0:0
mixer ogain 0:0
mixer phin 0:0
mixer phout 0:0
mixer video 0:0
mixer =rec line
/usr/local/bin/sc_serv /usr/local/etc/sc_serv.conf &
/usr/local/bin/darkice -c /usr/local/etc/darkice.cfg &

vermaden
January 11th, 2009, 15:26
Use #! /bin/sh for scripting.

... and yes, /etc/rc.local with su - user -c /path/to/script.sh is a good idea, you cal aslo wrote your script and put it under /usr/local/etc/rc.d/*

You will find more info about FreeBSD scripting here:
http://www.freebsd.org/doc/en_US.ISO8859-1/articles/rc-scripting/index.html

Lowell
January 11th, 2009, 17:53
Another option is using cron, with the "@reboot" keyword.

sniper007
January 12th, 2009, 16:22
OK, thanks guys

SirDice
January 12th, 2009, 16:38
Shoutcast already runs as a 'regular' user (shoutcast). Check the startup script /usr/local/etc/rc.d/shoutcast.sh.

sniper007
January 13th, 2009, 21:24
I didn't install shoutcast from ports.