Solved Soulseek RC script not able to resolve hostname

Why would a command work when run by itself, but not be able to resolve hostname "vps.slsknet.org" when run using an rc script?

I have installed soulseek following these instructions from github (needs allow.mlock=1) inside a jail, and the program works when invoked with su soulseek -c "/opt/slskd/slskd --app-dir=/home/soulseek/.local/share/slskd"
It can connect to the servers needed for downloading and such.

But if I try to run it using a service script, it always fails with "Failed to resolve hostname "vps.slsknet.org"
Literall everything else about the program works. WebUI, login, etc... but it cannot connect to the server.
Why?

Here is the service script
Code:
#!/bin/sh


# PROVIDE: slskd
# REQUIRE: NETWORKING
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable slskd at startup
# slskd_enable (bool): Set to "NO" by default.
#                Set it to "YES" to enable slskd
# slskd_user (str): Set to user running slskd
#                    (default 'soulseek')


. /etc/rc.subr


name="slskd"
rcvar=slskd_enable


load_rc_config $name


: ${slskd_enable="NO"}
: ${slskd_user:="soulseek"}
: ${slskd_config:="/home/${slskd_user}/.local/share/slskd"}


pidfile="${slskd_config}/slskd.pid"
procname="/opt/slskd/slskd"
required_files="${slskd_config}/slskd.yml"
command="/usr/sbin/daemon"
command_args="-f -p ${pidfile} ${procname} --app-dir=${slskd_config}"


run_rc_command "$1"

I have also tried running the script without the daemon part, but no go.
I have also tried running it as "www" and "root" users with no luck.
It just cannot resolve the hostname.

Any ideas?
 
So, it works if I specify the IP associated with "vps.slsknet.org" but not if I specify the DNS name. So DNS is not working when using the rc sript.
 
I don't have a direct solution for the problem, but to investigate I would change the rc script to report on the operational environment.

Comment out run_rc_command "$1".

Direct output to a log file exec >/tmp/mylog 2>&1.
  • See what networks are up.
  • Look at the routing tables.
  • Ping 208.76.170.59 once.
  • Ping vps.slsknet.org once.
Then fine tune what else you look at depending on the outcomes.
 
I don't have a direct solution for the problem, but to investigate I would change the rc script to report on the operational environment.

Comment out run_rc_command "$1".

Direct output to a log file exec >/tmp/mylog 2>&1.
  • See what networks are up.
  • Look at the routing tables.
  • Ping 208.76.170.59 once.
  • Ping vps.slsknet.org once.
Then fine tune what else you look at depending on the outcomes.
I can successfully use the ping command to ping the host, using the rc script.

I think it might have something to do with the way “slskd” is trying to resolve the hostname.
 
Solution is to include slskd_chdir="/root" in the script.

slskd seems to not play well with absolute paths...

Oh well, if anyone is curious,


[CODE]
#!/bin/sh

# PROVIDE: slskd
# REQUIRE: DAEMON NETWORKING
# KEYWORD: shutdown

. /etc/rc.subr

name=slskd
rcvar=slskd_enable

load_rc_config $name

: ${slskd_enable:="NO"}
: ${slskd_appdir:="/usr/local/www/slskd"}
: ${slskd_config:="${slskd_appdir}/${name}.yml"}
: ${slskd_user:="www"}
: ${slskd_group:="www"}

slskd_chdir="/root"
pidfile="/var/run/${name}/${name}.pid"
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -H -o /var/log/${name}/${name}.log ${slskd_appdir}/${name} --app-dir=${slskd_appdir} --config=${slskd_config}"

start_precmd=slskd_startprecmd

slskd_startprecmd()
{
if [ ! -d /var/run/${name} ]; then
install -d -o ${slskd_user} -g ${slskd_group} /var/run/${name};
else
chown -R ${slskd_user}:${slskd_group} /var/run/${name};
fi
if [ ! -d /var/log/${name} ]; then
install -d -o ${slskd_user} -g ${slskd_group} /var/log/${name};
else
chown -R ${slskd_user}:${slskd_group} /var/log/${name};
fi
}

run_rc_command "$1"
[/CODE]
 
Back
Top