I need to convert a init.d script that uses ruby to not use ruby. I can use perl or python or something else, but I can't use ruby. My main problem is figuring out how to dynamically get the list of *.jar files in a directory and separate them with ':'. The rest I could easily do with a bash script.
Here is the Ruby code I'm working with:
#!/usr/local/bin/ruby
require 'fileutils'
HOME = '/usr/local/myproject'
JAVA_HOME = '/usr/java/jdk'
JARS = Dir.glob(File.join(HOME, 'lib', '*.jar')).join(':')
PID_FILE = '/var/run/myproject.pid'
OUT_FILE = File.join(HOME, "stdout")
ERR_FILE = File.join(HOME, "stderr")
case ARGV.first
when 'start'
exec "/usr/local/bin/jsvc -home #{JAVA_HOME} -cp #{JARS} -pidfile #{PID_FILE} -DHOME=#{HOME} -user me -outfile #{OUT_FILE} -errfile #{ERR_FILE} mypackage.MyProject"
when 'stop'
exec "/usr/local/bin/jsvc -home #{JAVA_HOME} -cp #{JARS} -pidfile #{PID_FILE} -stop mypackage.MyProject"
end