termux / termux-services

Scripts to handle services in termux.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to get the sshd service up

guihkx opened this issue · comments

Hello,

I've followed the installation/setup guide from both the Wiki and the README from this repository, but I'm getting this error whenever I try to run/enable the sshd service:

$ sv up sshd
warning: sshd: can't open supervise/ok: No such file or directory

And yes, I did a complete restart of Termux after I installed termux-services. Not sure if this is relevant or not, but I'm not using bash as my default shell, I'm using fish.

There's no sv directory in my $PREFIX/var/log/ as well:

$ ls -la $PREFIX/var/log/
total 32
drwx------ 3 u0_a139 u0_a139 4096 Dec 29 11:49 .
drwx------ 9 u0_a139 u0_a139 4096 Dec 29 13:47 ..
-rw-r--r-- 1 u0_a139 u0_a139  853 Jan  1 10:03 alternatives.log
drwx------ 2 u0_a139 u0_a139 4096 Jan  3 10:34 apt

Can you guys help?
Thanks!

Also this:

$ service-daemon restart
Restarting daemon: service-daemonno process in pidfile '/data/data/com.termux/files/usr/var/run/service-daemon.pid' found; none killed
cat: /data/data/com.termux/files/usr/var/run/service-daemon.pid: No such file or directory
tail: invalid PID: ‘’

Yep, it doesn't work because fish is my default shell.

Reason: The termux-services package installs a script named start-services.sh to $PREFIX/etc/profile.d, which, if you have a POSIX-compliant shell, will always run once you open the Termux app. The problem is that Fish is not POSIX-compliant, so it won't read anything from the profile.d directory.

Instead, Fish reads its files (a.k.a. *.fish scripts) from a different directory, which is the output of: pkg-config --variable confdir fish, which is set at compile time and it currently points to: $PREFIX/share/fish/vendor_conf.d (here's the documentation).

So a proper fix to this, would be creating a start-services.fish script and placing it on: $PREFIX/share/fish/vendor_conf.d.

Doing it manually:

# open a temporary bash session
$ bash
# create the vendor_conf.d directory
$ mkdir -p $PREFIX/share/fish/vendor_conf.d
# create the start-services.fish script
$ cat << EOF > $PREFIX/share/fish/vendor_conf.d/start-services.fish
if status --is-login
    # For more details, see set(1)
    set -gx SVDIR $PREFIX/var/service
    set -gx LOGDIR $PREFIX/var/log
    service-daemon start >/dev/null 2>&1 &
end
EOF

Restart Termux, so that start-services.fish is loaded. Then, try starting/enabling any service (for example, sshd):

$ sv up sshd
# now check its status:
$ sv status sshd
run: sshd: (pid 7023) 10s, normally down; down: log: 0s, normally up, want up

It works now. That's it.

Now, it's up to the maintainers of termux-services to include this Fish script by default, so I'll leave this issue open until they decide it, but feel free to close it whenever you want.

Thanks!

Hi, thanks for investigating and posting the fish script here!

I added it in 43bc206. I'm not a fish user myself so this was greatly appreciated!

Hey, thanks for including the script!

However, I noticed that the script was installed to $(PREFIX)/etc/fish/conf.d, and even though the official documentation does say scripts will be loaded from there at startup as well, mine didn't when I placed it there. It could be something misconfigured on my end, but could you please make sure the script loads at least with vanilla Fish? Thanks.

Never mind. I was actually putting the script on $(PREFIX)/etc/fish/ instead. 🤦‍♂

It works, thanks.