Hello, I am trying to set up a daemon for
However,
does not do the trick. I see that the script as such works, and
This is my script:
What am I doing wrong? I read the article on Practical Rc.d Scripting, and I studied the manuals for rc.conf and rc.subr, but none of these resources pay much attention to running scripts as specific users.
And is my approach correct? I mean, should a daemon for a specific user be started through rc.d at all? But where else should I start it? If I do it through .zshrc, it will try to start every time I open a terminal window in X. If I do it through .xinitrc, it will not be active in console.
onedrive
. It needs to be run as a specific user, because onedrive
has to read the authentication token from the user home directory, and then synchronize into that directory.However,
Code:
${onedrived_user="borysj"}
onedrive
works in itself, but if I try to start it through my daemon it cannot find the authentication token. I guess it looks for it in /root.This is my script:
Code:
~ $more /usr/local/etc/rc.d/onedrived
#!/bin/sh
# PROVIDE: onedrived
# REQUIRE: DAEMON
# KEYWORD: nojail shutdown
. /etc/rc.subr
name="onedrived"
rcvar="onedrived_enable"
command="/usr/local/bin/onedrive"
start_precmd="${name}_prestart"
stop_postcmd="${name}_poststop"
onedrived_prestart()
{
su borysj -c '/usr/local/bin/onedrive --synchronize'
}
onedrived_poststop()
{
su borysj -c '/usr/local/bin/onedrive --synchronize'
}
load_rc_config $name
: ${onedrived_enable="YES"}
: ${onedrived_user="borysj"}
: ${onedrived_flags="--monitor"}
run_rc_command "$1"
What am I doing wrong? I read the article on Practical Rc.d Scripting, and I studied the manuals for rc.conf and rc.subr, but none of these resources pay much attention to running scripts as specific users.
And is my approach correct? I mean, should a daemon for a specific user be started through rc.d at all? But where else should I start it? If I do it through .zshrc, it will try to start every time I open a terminal window in X. If I do it through .xinitrc, it will not be active in console.