Flood UI (rtorrent) rc.d Startup Script

Status
Not open for further replies.

Struckmonger

Cadet
Joined
Jan 1, 2018
Messages
8
I'm trying to make a startup script for my Flood UI for rtorrent, but I am new to rc.d scripts. The command I created in flood_start() seems to work well for daemonizing flood if executed through shell, but for some reason this command won't execute at all (flood won't start, nothing occurs) if ran by calling service flood start. The stop command does work fine though. The script is located at /usr/local/etc/rc.d/flood.

TLDR: Why doesn't /usr/local/bin/sudo /usr/local/bin/screen -d -m -fa -S flood /usr/local/bin/npm start --prefix /srv/torrent/flood work at all when called through rc.d?

Here's the full script:
Code:
#!/bin/sh
#
# PROVIDE: flood
# REQUIRE: NETWORK
# KEYWORD: shutdown

. /etc/rc.subr

name="flood"
rcvar=flood_enable
start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name
: ${flood_enable:=no}
: ${pid:=$(/usr/local/bin/pidof node)}

flood_start() {
		/usr/local/bin/sudo /usr/local/bin/screen -d -m -fa -S flood /usr/local/bin/npm start --prefix /srv/torrent/flood
}

flood_stop() {
		echo Killing $pid
		kill $pid
}

run_rc_command "$1"
 
Last edited:

Struckmonger

Cadet
Joined
Jan 1, 2018
Messages
8
This may prove as useful information: If I remove /usr/local/bin/screen -d -m -fa -S flood from the start command, i get faced with the error env: node: No such file or directory.
 

Struckmonger

Cadet
Joined
Jan 1, 2018
Messages
8
I could've swore I made a post with the answer in it. Maybe I'm just crazy. After a bunch of thinking I figured it out. NPM was calling "node" but rc.d doesn't like that, it wants the full path to node. So all I did was find NPM's execution script and replace it with npm start.
Code:
#!/bin/sh
#
# PROVIDE: flood
# REQUIRE: NETWORK
# KEYWORD: shutdown

. /etc/rc.subr

name="flood"
rcvar=flood_enable
start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name
: ${flood_enable:=no}
: ${pid:=$(/usr/local/bin/pidof node)}

flood_start() {
		cd /srv/torrent/flood
		/usr/local/bin/sudo /usr/local/bin/screen -d -m -fa -S flood /usr/local/bin/node /srv/torrent/flood/server/bin/start.js
}

flood_stop() {
		echo Killing $pid
		kill $pid
}

run_rc_command "$1"


Hope this helps anyone on Google with a similar question.
 

Kennyvb8

Contributor
Joined
Mar 18, 2017
Messages
112
I just use pm2 to autostart both irssi (autodl) tTorrent and flood


Sent from my iPhone using Tapatalk
 
Status
Not open for further replies.
Top