Run script at boot after transmission-daemon service starts

i would like to run a script (sh /usr/local/run.sh) at boot but after samba loads transmission-daemon service starts

i tried putting the script in /etc/rc.local directly and after using sleep 60 both seem to execute before samba loads transmission-daemon service starts

im using exroot so that is probably adding to boot time, possibly

https://openwrt.org/docs/techref/block_mount#block-hotplug_binary_package

1 Like

Another approach:

START=98

samba4's init.d script is queued into start position 98. That does not leave many a whole lot of two-digit numbers that are higher, but 99 will do: Write your script as a small init.d script that queues itself with START=99 and it will be executed after samba4's init script:

#!/bin/sh /etc/rc.common
START=99
start() {
   # your script here, or just call /usr/local/run.sh
}
1 Like

neat, will try

is it possible to run the script after the transmission-daemon service starts/is up and running, thanks

Edit: just want to clear completed downloads and send me a discord webhook curl notification of downloads completed

thanks, i wish i knew enough, is it possible to run the script after the transmission-daemon service starts/is up and running, thanks

Edit: just want to clear completed downloads and send me a discord webhook curl notification of downloads completed

how is this related to your samba question ?

1 Like

im going to edit the question, sorry

figured if the samba service is up and running transmission service would be up

thanks

create a new thread, perhaps ?

1 Like

will do next time/be more careful, sorry again

Run a loop in rc.local, using netcat, let it check if whatever port your transmission is using is listening, if/when it is, terminate loop, and send notification.

Like in https://stackoverflow.com/questions/27599839/how-to-wait-for-an-open-port-with-netcat

1 Like

this, unfortunately, did not work

its should, in theory

however, adding this loop script in rc.local prevents the rest of the services from loading and keeps running in a loop, needed a manual restart after commenting out the loop script in rc.local

maybe this behavior is because im using exroot

had to install netcat
opkg update && opkg install netcat

the loop script

#!/bin/sh

echo "waiting for transmission to launch on 9091..."

while ! nc -zv localhost 9091; do   
  sleep 1 
done

echo "transmission launched"
/usr/local/run.sh

added in rc.local

sh /usr/local/loop.sh

loading from where, rc.local ?
you didn't tell us you started anything through it ...

if the script doesn't do anything else but notify, run it in background instead ?
add an &.

1 Like

no. im unable to describe what is happening exactly, but if i run the script, it does not allow services like transmission-daemon to start, for some reason

adding an & to the end in rc.local helped (sh /usr/local/loop.sh &) in the sense that transmission-daemon loaded (in comparison to earlier), however the script did not execute as desired and as it does when i run it manually, nothing happened

if you execute a loop, then yes, everything executed after it, will wait until the looping netcat check completes.

via ssh
stop the transmission service
execute the loop.sh, and keep it running in foreground.
in a parallell ssh session start the transmission service again.

does the script finish ?

yes. it works as expected. nice

wonder why it's not working while running via rc.local as background

replace the echo with logger, so the entry pops up in the system log instead.

now run the same, but execute the loop.sh in background by adding the &.

run logread -f before you start transmission through the 2nd ssh session.

it worked but the script in the background did not exit, yet

is it by any chance becasue /usr/local/run.sh stops it from exiting ?

1 Like

ya. maybe. but then the same effect would happen. i.e. i would get the notification and the torrents completed would get cleared.

however, i will try to exit via the script and test. thanks

nope. clean exit when i run it manually, when i run either loop.sh or run.sh its only when i run loop.sh in background bay adding & that it does not exit

took me some time to understand your question