Solved FreeBSD and RC scripts.....newbie (scripting and FreeBSD)

I’m faced with the uphill task of getting an app running on FreeBSD, works on CentOS7 currently.


I have found manually entering the below lines individually will get it up and running :at a prompt ;)


Code:
set CATALINA_HOME=/srv/site/tomcat/apache-tomcat-8.5.6

set CATALINA_BASE=/srv/site/sites/site1

set JAVA_HOME=/usr/local/openjdk8

set CATALINA_USER=site1

set APP_NAME=site1

set CATALINA_OPTS="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.io.tmpdir=$CATALINA_BASE/temp -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties -Xmx512m -Djava.awt.headless=true"

/usr/local/bin/jsvc -user $CATALINA_USER -home $JAVA_HOME -jvm server -Dcatalina.home=$CATALINA_HOME -Dcatalina.base=$CATALINA_BASE -wait 120 -pidfile /var/run/$APP_NAME.pid $CATALINA_OPTS -cp /srv/site/lib/java-logging/slf4j-api-1.7.12.jar:/srv/site/lib/java-logging/slf4j-jdk14-1.7.12.jar:/srv/site/lib/java-logging/log4j-over-slf4j-1.7.12.jar:/srv/site/lib/java-logging/jcl-over-slf4j-1.7.12.jar:$CATALINA_HOME/bin/tomcat-juli.jar:$CATALINA_HOME/bin/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar org.apache.catalina.startup.Bootstrap

problem now is getting it to work in an rc script, which for someone who has zero programming skills (not that I haven’t tried learning various languages at various times, it’s never really clicked)


in my rc file I have

Code:
#!/bin/sh


# PROVIDE: tomcat

# KEYWORD: shutdown


#

# Add the following line to /etc/rc.conf to enable tomcat:

# tomcat_enable="YES"

#


. /etc/rc.subr


name="tomcat"

rcvar=tomcat_enable

export JAVA_HOME="/usr/local"

CATALINA_HOME=/srv/site/tomcat/apache-tomcat-8.5.6

CATALINA_BASE=/srv/site/sites/site1

AVA_HOME=/usr/local/openjdk8

CATALINA_USER=site1

APP_NAME=site1

CATALINA_OPTS="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.io.tmpdir=$CATALINA_BASE/temp -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties -Xmx512m -Djava.awt.headless=true"

command="/usr/local/bin/jsvc -user $CATALINA_USER -home $JAVA_HOME -jvm server -Dcatalina.home=$CATALINA_HOME -Dcatalina.base=$CATALINA_BASE -wait 120 -pidfile /var/run/$APP_NAME.pid $CATALINA_OPTS -cp \ /srv/site/lib/java-logging/slf4j-api-1.7.12.jar:/srv/site/lib/java-logging/slf4j-jdk14-1.7.12.jar:/srv/site/lib/java-logging/log4j-over-slf4j-1.7.12.jar:/srv/site/lib/java-logging/jcl-over-slf4j-1.7.12.jar:$CATALINA_HOME/bin/tomcat-juli.jar:$CATALINA_HOME/bin/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar org.apache.catalina.startup.bootstrap"


start_cmd="usr/sbin/daemon -u $CATALINA_USER $command"


load_rc_config $name
run_rc_command "S1"
Which is failing, I’ve read through https://www.freebsd.org/doc/en/articles/rc-scripting/article.html#rc-flagswhich soon makes no sense to me whatsoever.

the errors I'm getting are :-


./tomcat: WARNING: no shebang line in /usr/local/bin/jsvc
./tomcat: unknown directive 'S1'.
Usage: ./tomcat [fast|force|one|quiet](start|stop|restart|rcvar|enabled|status|poll)


Just after pointers to basic sites/resources/videos so at least I can create a rc script that will work.


Thanks!
 
Back
Top