Please, please FreeBSD gurus, I need your help! šŸ™

heh! I just noticed an article from the other day with almost the exact same title as what I just said (my eyes initially caught the last part of the title, and it startled me for a second). lol

Switching customers from Linux to BSD because boring is good ā€¢ The Register

I remember reading that post ā€œThat Old NetBSD Server,ā€¦ā€ (a link in the above article) which is worth the read if you get to it as well.

Notable quote:

Nine years of uptime for a server set up in a few hours, on consumer-grade hardware, and left largely unattended for years.
I now understand why Iā€™m not ā€“ and will never be ā€“ rich. My first (and last) employer complained about my preference for stable and reliable solutions, equating it with lesser profits. According to him, unstable solutions requiring frequent maintenance meant more revenue. To me, a job is well-done when it works consistently, not when it demands constant fixes.

3 Likes

@winnielinnie

Can you try adding soulseek_env=ā€œHOME=/home/soulseek DNS_SERVERS=1.1.1.1 GATEWAY=192.168.x.xā€ to your rc script?

Like that? Did you mean slskd_env instead?

Iā€™m thinking itā€™s the user environment, not the script name.

Try both.

Same result on both counts.

Service starts. Web UI fully functional. No internet connection.

EDIT: I bet something in slskdā€™s code itself is the culprit. After all, local network connectivity works fine, no matter what. (Otherwise, I wouldnā€™t be able to login to the web UI.)

Okay, so weā€™re getting somewhereā€¦

This looks to be a ā€œDNS issueā€.[1]

In my slskd.yml config file, I uncommented and changed this line:

#   address: vps.slsknet.org

To this:

   address: 208.76.170.59

Now when I run it as a ā€œserviceā€, it connects to the Soulseek Network.

The above is without the ā€œenvā€ line added to the rc.d script.


  1. Maybe DNS + FreeBSD + something in the softwareā€™s code? ā†©ļøŽ

I asked on the forums at FreeBSD, and one response was something about an ENV file not being passed when the rc script runs, but is already present when running the command by itself.

What that would be I donā€™t know.

But at least we have confirmed internet works with the script itself.

1 Like

Agreed. Internet, but not DNS.

Another reason why I think this is specific to slskd itself is that other ā€œproperlyā€ ported applications, such as qBittorrent, Jellyfin, and aMule, do not need any such ā€œENVā€ variable passed in their respective rc.d scripts.

Thatā€™s cool. In regards to resources, I run the DebianVM with Portainer, with 20 containers running, using just 1GB RAM. The host Scale server has 32GB with 7GB free and thatā€™s with this Portainer VM, another Debian VM, and a Windows VM with 5GB alotted to it. The last upgrade to Scale really improved memory management as I never had that much RAM free on this machine before. Hell may indeed freeze over!

Good luck and thanks for all the helpful posts youā€™ve made!

1 Like

@winnielinnie I have pinpointed the issue.

Add this line to your rc script.

${name}_chdir=/root

This works for me.

1 Like

And if you want a cool streamlined, rc file, here you go. You can edit as needed.

#!/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"

You can also just create a user called ā€œslskdā€ for it, I tried both. Just make sure the ā€œslskd_appdirā€ is owned by that user.

Have fun!

3 Likes

And I have now added it to my repo. README coming soon, but the script works out of the box.

1 Like

That works! Incredible! :partying_face: Itā€™s the only line I added to my rc script (nothing else), and it works! (I am using the default setting of vps.slsknet.org for the Soulseek Network address to confirm that it truly does work.)

Now the question is: Why?

Why does this thing need you to chdir into the root userā€™s home directory if itā€™s run as a service? (Whereas, if you donā€™t run it as a service, this isnā€™t necessary.)


You are just the best, @victor!

As I understand it, slskd doesnā€™t play well with absolute paths. Iā€™m not sure why. Maybe itā€™s because of dotnet or something.

1 Like

Also the chdir doesnā€™t change to the users home root. I believe itā€™s just the base root of the jail. Could be wrong though.

While not mandatory, I think you should add helpful comments at the top of the script, such as informing the user to add the relevant lines to rc.conf to enable the service, as well as override the user to run it as (and to override the ā€œappdirā€ if they want to specify it in a custom location).

Those nice little comments at the top of most scripts. :slightly_smiling_face:

Itā€™s not the base root (/) of the jail. Itā€™s the root userā€™s home directory (/root).

I know. I just havenā€™t gotten to that part yet.

1 Like

Great job tracking that down, victor.


EDIT: This post was made because I thought a file was being copied into directories, not directories created so the code below is incorrect.


Programming question:
Why use the IF-ELSE? I mean to say since you are still running a chown on the file anyways, why not eliminate the check altogether?

slskd_startprecmd() {
   install -d -o ${slskd_user} -g ${slskd_group} /var/run/${name};
   install -d -o ${slskd_user} -g ${slskd_group} /var/log/${name};
}