# Start script with particular user



## sniper007 (Jan 11, 2009)

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 (Jan 11, 2009)

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 (Jan 11, 2009)

Another option is using cron(), with the "@reboot" keyword.


----------



## sniper007 (Jan 12, 2009)

OK, thanks guys


----------



## SirDice (Jan 12, 2009)

Shoutcast already runs as a 'regular' user (shoutcast). Check the startup script /usr/local/etc/rc.d/shoutcast.sh.


----------



## sniper007 (Jan 13, 2009)

I didn't install shoutcast from ports.


----------

