On Sat, Apr 10, 2010 at 12:38:25PM +0200, Mats-G?ran Karlsen wrote:
> Hello.
>
> I'm running a headless OpenBSD server.
>
> I'm trying to create a startup script that executes the transmission-daemon as
> a regular user.
>
> Details:
>
> located in /etc/transmission/rc.transmission
>
> permissions
> -rw-r----- 1 root wheel 390 Jul 13 18:30 rc.transmission
>
>
> Script follows:
> -------script start--------
>
> #! /bin/sh
>
> #Provides transmission-daemon
>
> # --- Configuration ---
>
> USERNAME=username
> PASSWD=password
>
> # --- End configuration ---
>
> DESC="bittorrent client"
> NAME=transmission-daemon
> DAEMON=$(which $NAME)
> CONFIGDIR="/home/$USERNAME/.config/$NAME"
>
> #Start daemon
>
> /usr/bin/sudo -u $USERNAME -p $PASSWD $DAEMON -g $CONFIGDIR
>
>
> ------script end---------
>
> The following is appended to /etc/rc.conf
>
> --
> transmission=YES
> --
>
> the following is appended to /etc/rc.local
>
> --
> if [ -f /etc/transmission/rc.transmission]; then
> if [ X"${transmission}" = X"YES" -a -x
> /usr/local/bin/transmission-daemon ]; then
> echo -n ' transmission-daemon'; .
> /etc/transmission/rc.transmission
> fi
> fi
> --
>
> The rc.transmission script runs fine when executed under root, but it isn't
> executed during boot.
>
> Have been roaming around for tips but since i haven't figured out how OpenBSD
> executes
> startup scripts with other owners than root i'm out of ideas.
>
> Hope somebody can give me pointers to what's wrong.
root is allowed to sudo anything.
why not just do:
if [ -x /usr/local/bin/transmission-daemon -a \
X"R{transmission}" = X"YES" ]; then -
echo -n ' transmission-daemon'
sudo -u user /usr/local/bin/transmission-daemon \
-g /home/user/.config/transmission-daemon
fi
-0-
--
I don't think they could put him in a mental hospital. On the other
hand, if he were already in, I don't think they'd let him out.