Help with Startup Script

Hi, I am new to FreeBSD and would like some help getting a script to run on startup.

The script is /var/subsonic/subsonic.sh

I would like this to run on startup, this is running in a jail but I presume the process would be the same either way.

I am able to run the command manually and the application runs however trying to run on startup seems to be a problem.

I created a symbolic link to the /var/subsonic/subsonic.sh in rc.d and added subsonic_enable="YES" to my rc.conf file however this does not provide the desired results.

Thanks in advance for any ideas.
 
FreeBSD's rc(8) scripts have a specific function and I seriously doubt this script follows it. You will need to write your own based on the information of the existing script.
 
First of all: don't mess with the base system like that, it's only going to haunt you in the longer run. So leave /etc/rc.d alone and instead use /usr/local/etc/rc.d, which is intended to be used by 3rd parties.

Another thing: why mess with this in the first place though? From what I can tell Subsonic is available in the ports collection (www/subsonic-standalone) so I would assume that it also provides an rc.d script if necessary. Of course I don't know if this is the same software you're trying to use, but if it is then I would use that instead of (what I assume to be) a manually set up installation.

Anyway, I can't really answer your question without knowing what subsonic.sh contains. As you discovered it takes more than just dumping a script somewhere; the script also needs to follow specific standards. See the other scripts for an example of that.
 
Here is the script. The version in the ports is an older version than what I require.
Code:
#!/bin/sh
#
# PROVIDE: subsonic
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# subsonic_enable (bool):   Set to NO by default.
#            Set it to YES to enable it.

. /etc/rc.subr

name="subsonic"
rcvar=${name}_enable
subsonic_enable=${subsonic_enable-"NO"}
pidfile="/var/run/${name}.pid"
procname="/usr/local/openjdk7/bin/java"

start_cmd="subsonic_start"

start_precmd="rm -f $pidfile"
stop_postcmd=$start_precmd

subsonic_start()
{
   echo "Starting Subsonic"
   export PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin
   cd /var/subsonic/standalone
   sh subsonic.sh
}


load_rc_config $name
run_rc_command "$1"
 
Just a suggestion: install the port and adapt *its* rc script to meet your needs. (Or a copy of the rc script it installs.) Like folks mention above, it's best not to mess with /etc/rc.d...stick to /usr/local/etc/rc.d.
 
Back
Top