RC Script Initial Call

Status
Not open for further replies.

Sillyus Sodus

Dabbler
Joined
Feb 9, 2016
Messages
14
I am trying to start and stop the Transmission service from another RC script (OpenVPN).

I can get this to work when I use service openvpn start||stop||restart by using the following in the OpenVPN script:
Code:
if [ "$1" = "start||stop||restart" ]; then

However, it doesn't work on the initial system startup of the OpenVPN servce, which I have enabled in /etc/rc.conf.

Is there an initial start (and possibly even an initial stop) value I can use in the if statement to cover this situation so the system will start OpenVPN and Transmission will be started from OpenVPN's RC script?
 
Last edited by a moderator:

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I'm not sure if this is exactly what you are trying to do but you can always have transmission start after openvpn.
edit /usr/local/etc/rc.d/transmission and change "# REQUIRE: DAEMON" to "# REQUIRE: openvpn"
 

Sillyus Sodus

Dabbler
Joined
Feb 9, 2016
Messages
14
Thanks, this is of quite some help. I'll see if I can get it to work this way.

The trouble I have is that there are certain scripts I'd like to run on startup of these services. I can put them in at the end of the RCs script without the if statement and they will run on both initial system and manual startup, as I'd like, but then they also run on shutdown as well, which I don't really want.

I'm not sure if this is exactly what you are trying to do but you can always have transmission start after openvpn.
edit /usr/local/etc/rc.d/transmission and change "# REQUIRE: DAEMON" to "# REQUIRE: openvpn"
 

Sillyus Sodus

Dabbler
Joined
Feb 9, 2016
Messages
14
I'd like OpenVPN to start with the jail, then have my ipfw rules run after that (the script throws a wobbly if the tunnel isn't present). I'd also like Transmission to start with the jail, but only once the rules are in place, and I'd like to run a port forwarding script for my VPN to run after transmission is running (again this script doesn't work unless Transmission is running).

I can get it to work with a couple of wait commands but it's not quite perfect. The # REQUIRE should at least allow me to set transmission_enable in rc.conf and have them start in the right order so I don't need to start Transmission from the OpenVPN rc script any more. This is great because It will let me enable and disable Transmission from the GUI again.

Regarding the if statement, I only need special cases for stop (don't run any script) and restart (longer delay) so I'll try to use "if not stop" nested with "if not restart" as the test and hopefully that will work. I don't know if the system "stop" command behaves any differently from the normal CLI "service XXXX stop" so it might not quite work perfectly on shutdown.
 
Status
Not open for further replies.
Top