trinidad_init_services 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +3 -0
- data/History.txt +6 -0
- data/README.md +95 -0
- data/Rakefile +9 -58
- data/bin/trinidad_init_service +3 -4
- data/init.d/trinidad.erb +33 -12
- data/jsvc-unix-src/CHANGES.txt +62 -0
- data/jsvc-unix-src/INSTALL.txt +81 -0
- data/jsvc-unix-src/Makedefs.in +32 -0
- data/jsvc-unix-src/Makefile.in +42 -0
- data/jsvc-unix-src/configure +4417 -0
- data/jsvc-unix-src/configure.in +141 -0
- data/jsvc-unix-src/man/README +20 -0
- data/jsvc-unix-src/man/fetch.sh +36 -0
- data/jsvc-unix-src/man/jsvc.1.xml +214 -0
- data/jsvc-unix-src/native/.indent.pro +7 -0
- data/jsvc-unix-src/native/Makefile.in +46 -0
- data/jsvc-unix-src/native/arguments.c +476 -0
- data/jsvc-unix-src/native/arguments.h +94 -0
- data/jsvc-unix-src/native/debug.c +87 -0
- data/jsvc-unix-src/native/debug.h +65 -0
- data/jsvc-unix-src/native/dso-dlfcn.c +62 -0
- data/jsvc-unix-src/native/dso-dyld.c +153 -0
- data/jsvc-unix-src/native/dso.h +38 -0
- data/jsvc-unix-src/native/help.c +106 -0
- data/jsvc-unix-src/native/help.h +24 -0
- data/jsvc-unix-src/native/home.c +265 -0
- data/jsvc-unix-src/native/home.h +47 -0
- data/jsvc-unix-src/native/java.c +608 -0
- data/jsvc-unix-src/native/java.h +35 -0
- data/jsvc-unix-src/native/jsvc-unix.c +1267 -0
- data/jsvc-unix-src/native/jsvc.h +55 -0
- data/jsvc-unix-src/native/location.c +151 -0
- data/jsvc-unix-src/native/location.h +29 -0
- data/jsvc-unix-src/native/locks.c +52 -0
- data/jsvc-unix-src/native/locks.h +40 -0
- data/jsvc-unix-src/native/replace.c +121 -0
- data/jsvc-unix-src/native/replace.h +39 -0
- data/jsvc-unix-src/native/signals.c +105 -0
- data/jsvc-unix-src/native/signals.h +34 -0
- data/jsvc-unix-src/native/version.h +63 -0
- data/jsvc-unix-src/support/apfunctions.m4 +110 -0
- data/jsvc-unix-src/support/apjava.m4 +94 -0
- data/jsvc-unix-src/support/apsupport.m4 +155 -0
- data/jsvc-unix-src/support/buildconf.sh +33 -0
- data/jsvc-unix-src/support/config.guess +1371 -0
- data/jsvc-unix-src/support/config.sub +1760 -0
- data/jsvc-unix-src/support/install.sh +128 -0
- data/jsvc-unix-src/support/mkdist.sh +104 -0
- data/lib/trinidad/daemon.rb +31 -0
- data/lib/trinidad_init_services.rb +2 -30
- data/lib/trinidad_init_services/configuration.rb +91 -14
- data/lib/trinidad_init_services/version.rb +5 -0
- data/spec/spec_helper.rb +5 -6
- data/spec/trinidad_daemon_spec.rb +0 -1
- data/spec/trinidad_init_services/configuration_spec.rb +34 -1
- data/trinidad_init_services.gemspec +14 -51
- metadata +146 -87
- data/README +0 -63
- data/trinidad-libs/jsvc_linux +0 -0
@@ -0,0 +1,128 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
# contributor license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright ownership.
|
6
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
# (the "License"); you may not use this file except in compliance with
|
8
|
+
# the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
##
|
19
|
+
## install.sh -- install a program, script or datafile
|
20
|
+
##
|
21
|
+
## Based on `install-sh' from the X Consortium's X11R5 distribution
|
22
|
+
## as of 89/12/18 which is freely available.
|
23
|
+
## Cleaned up for Apache's Autoconf-style Interface (APACI)
|
24
|
+
## by Ralf S. Engelschall <rse@apache.org>
|
25
|
+
##
|
26
|
+
#
|
27
|
+
# This script falls under the Apache License.
|
28
|
+
# See http://www.apache.org/docs/LICENSE
|
29
|
+
|
30
|
+
|
31
|
+
#
|
32
|
+
# put in absolute paths if you don't have them in your path;
|
33
|
+
# or use env. vars.
|
34
|
+
#
|
35
|
+
mvprog="${MVPROG-mv}"
|
36
|
+
cpprog="${CPPROG-cp}"
|
37
|
+
chmodprog="${CHMODPROG-chmod}"
|
38
|
+
chownprog="${CHOWNPROG-chown}"
|
39
|
+
chgrpprog="${CHGRPPROG-chgrp}"
|
40
|
+
stripprog="${STRIPPROG-strip}"
|
41
|
+
rmprog="${RMPROG-rm}"
|
42
|
+
|
43
|
+
#
|
44
|
+
# parse argument line
|
45
|
+
#
|
46
|
+
instcmd="$mvprog"
|
47
|
+
chmodcmd=""
|
48
|
+
chowncmd=""
|
49
|
+
chgrpcmd=""
|
50
|
+
stripcmd=""
|
51
|
+
rmcmd="$rmprog -f"
|
52
|
+
mvcmd="$mvprog"
|
53
|
+
ext=""
|
54
|
+
src=""
|
55
|
+
dst=""
|
56
|
+
while [ "x$1" != "x" ]; do
|
57
|
+
case $1 in
|
58
|
+
-c) instcmd="$cpprog"
|
59
|
+
shift; continue
|
60
|
+
;;
|
61
|
+
-m) chmodcmd="$chmodprog $2"
|
62
|
+
shift; shift; continue
|
63
|
+
;;
|
64
|
+
-o) chowncmd="$chownprog $2"
|
65
|
+
shift; shift; continue
|
66
|
+
;;
|
67
|
+
-g) chgrpcmd="$chgrpprog $2"
|
68
|
+
shift; shift; continue
|
69
|
+
;;
|
70
|
+
-s) stripcmd="$stripprog"
|
71
|
+
shift; continue
|
72
|
+
;;
|
73
|
+
-S) stripcmd="$stripprog $2"
|
74
|
+
shift; shift; continue
|
75
|
+
;;
|
76
|
+
-e) ext="$2"
|
77
|
+
shift; shift; continue
|
78
|
+
;;
|
79
|
+
*) if [ "x$src" = "x" ]; then
|
80
|
+
src=$1
|
81
|
+
else
|
82
|
+
dst=$1
|
83
|
+
fi
|
84
|
+
shift; continue
|
85
|
+
;;
|
86
|
+
esac
|
87
|
+
done
|
88
|
+
if [ "x$src" = "x" ]; then
|
89
|
+
echo "install.sh: no input file specified"
|
90
|
+
exit 1
|
91
|
+
fi
|
92
|
+
if [ "x$dst" = "x" ]; then
|
93
|
+
echo "install.sh: no destination specified"
|
94
|
+
exit 1
|
95
|
+
fi
|
96
|
+
|
97
|
+
#
|
98
|
+
# If destination is a directory, append the input filename; if
|
99
|
+
# your system does not like double slashes in filenames, you may
|
100
|
+
# need to add some logic
|
101
|
+
#
|
102
|
+
if [ -d $dst ]; then
|
103
|
+
dst="$dst/`basename $src`"
|
104
|
+
fi
|
105
|
+
|
106
|
+
# Add a possible extension (such as ".exe") to src and dst
|
107
|
+
src="$src$ext"
|
108
|
+
dst="$dst$ext"
|
109
|
+
|
110
|
+
# Make a temp file name in the proper directory.
|
111
|
+
dstdir=`dirname $dst`
|
112
|
+
dsttmp=$dstdir/#inst.$$#
|
113
|
+
|
114
|
+
# Move or copy the file name to the temp name
|
115
|
+
$instcmd $src $dsttmp
|
116
|
+
|
117
|
+
# And set any options; do chmod last to preserve setuid bits
|
118
|
+
if [ "x$chowncmd" != "x" ]; then $chowncmd $dsttmp; fi
|
119
|
+
if [ "x$chgrpcmd" != "x" ]; then $chgrpcmd $dsttmp; fi
|
120
|
+
if [ "x$stripcmd" != "x" ]; then $stripcmd $dsttmp; fi
|
121
|
+
if [ "x$chmodcmd" != "x" ]; then $chmodcmd $dsttmp; fi
|
122
|
+
|
123
|
+
# Now rename the file to the real destination.
|
124
|
+
$rmcmd $dst
|
125
|
+
$mvcmd $dsttmp $dst
|
126
|
+
|
127
|
+
exit 0
|
128
|
+
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
# contributor license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright ownership.
|
6
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
# (the "License"); you may not use this file except in compliance with
|
8
|
+
# the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
# Create Commons Daemon native package distribution on UNIX systems.
|
19
|
+
# You should execute this script from the src/native/unix directory
|
20
|
+
#
|
21
|
+
# support/mkdist.sh <arch> [os]
|
22
|
+
#
|
23
|
+
# This will create something like commons-daemon-1.2.3-bin-os-arch.tar.gz
|
24
|
+
# The version numbers are parsed from the native/version.h file.
|
25
|
+
# If the os argument is not provided current os name will be used.
|
26
|
+
#
|
27
|
+
#
|
28
|
+
gpgopts="-ba"
|
29
|
+
arch=""
|
30
|
+
for o
|
31
|
+
do
|
32
|
+
case "$o" in
|
33
|
+
*=*) a=`echo "$o" | sed 's/^[-_a-zA-Z0-9]*=//'`
|
34
|
+
;;
|
35
|
+
*) a=''
|
36
|
+
;;
|
37
|
+
esac
|
38
|
+
case "$o" in
|
39
|
+
--passphrase=* )
|
40
|
+
gpgopts="$gpgopts --passphrase $a"
|
41
|
+
shift
|
42
|
+
;;
|
43
|
+
--arch=* )
|
44
|
+
arch="$a"
|
45
|
+
shift
|
46
|
+
;;
|
47
|
+
--os=* )
|
48
|
+
osname="$a"
|
49
|
+
shift
|
50
|
+
;;
|
51
|
+
* )
|
52
|
+
break
|
53
|
+
;;
|
54
|
+
esac
|
55
|
+
done
|
56
|
+
|
57
|
+
|
58
|
+
if [ ".$arch" = . ];then
|
59
|
+
arch=`uname -m 2>/dev/null | tr '[A-Z]' '[a-z]'` || arch="unknown"
|
60
|
+
echo "No architecture provided. Using $arch"
|
61
|
+
fi
|
62
|
+
if [ ".$osname" = . ];then
|
63
|
+
osname=`uname -s 2>/dev/null | tr '[A-Z]' '[a-z]'` || osname="unknown"
|
64
|
+
echo "No OS name provided. Using $osname"
|
65
|
+
fi
|
66
|
+
topdir=.
|
67
|
+
major_sed='/#define.*JSVC_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p'
|
68
|
+
minor_sed='/#define.*JSVC_MINOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p'
|
69
|
+
patch_sed='/#define.*JSVC_PATCH_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p'
|
70
|
+
vmajor="`sed -n $major_sed $topdir/native/version.h`"
|
71
|
+
vminor="`sed -n $minor_sed $topdir/native/version.h`"
|
72
|
+
vpatch="`sed -n $patch_sed $topdir/native/version.h`"
|
73
|
+
verdst="commons-daemon-$vmajor.$vminor.$vpatch-bin-$osname-$arch"
|
74
|
+
extfiles="LICENSE.txt NOTICE.txt RELEASE-NOTES.txt"
|
75
|
+
for i in $extfiles
|
76
|
+
do
|
77
|
+
cp ../../../$i .
|
78
|
+
done
|
79
|
+
# Try to locate a MD5 binary
|
80
|
+
md5_bin="`which md5sum 2>/dev/null || type md5sum 2>&1`"
|
81
|
+
if [ -x "$md5_bin" ]; then
|
82
|
+
MD5SUM="$md5_bin --binary "
|
83
|
+
else
|
84
|
+
MD5SUM="echo 00000000000000000000000000000000 "
|
85
|
+
fi
|
86
|
+
# Try to locate a SHA1 binary
|
87
|
+
sha1_bin="`which sha1sum 2>/dev/null || type sha1sum 2>&1`"
|
88
|
+
if [ -x "$sha1_bin" ]; then
|
89
|
+
SHA1SUM="$sha1_bin --binary "
|
90
|
+
else
|
91
|
+
SHA1SUM="echo 0000000000000000000000000000000000000000 "
|
92
|
+
fi
|
93
|
+
dstfile=$verdst.tar.gz
|
94
|
+
echo "Creating $dstfile ..."
|
95
|
+
tar cfz $dstfile jsvc $extfiles
|
96
|
+
if [ ".$?" = .0 ]; then
|
97
|
+
echo "Signing $dstfile"
|
98
|
+
gpg $gpgopts $dstfile
|
99
|
+
$MD5SUM $dstfile > $dstfile.md5
|
100
|
+
$SHA1SUM $dstfile > $dstfile.sha1
|
101
|
+
else
|
102
|
+
rm $verdst.tar.gz >/dev/null 2>&1
|
103
|
+
fi
|
104
|
+
rm $extfiles
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'trinidad'
|
3
|
+
|
4
|
+
module Trinidad
|
5
|
+
module Daemon
|
6
|
+
require 'trinidad_init_services/version'
|
7
|
+
VERSION = Trinidad::InitServices::VERSION
|
8
|
+
|
9
|
+
def init
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
def start(args = ARGV)
|
17
|
+
Trinidad::CommandLineParser.parse(args)
|
18
|
+
Trinidad.configuration.trap = false
|
19
|
+
@server = Trinidad::Server.new
|
20
|
+
@server.start
|
21
|
+
end
|
22
|
+
|
23
|
+
def stop
|
24
|
+
@server.stop
|
25
|
+
end
|
26
|
+
|
27
|
+
extend self
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Trinidad::Daemon.init
|
@@ -1,30 +1,2 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
|
4
|
-
module Trinidad
|
5
|
-
module Daemon
|
6
|
-
VERSION = '1.1.3'
|
7
|
-
|
8
|
-
def init
|
9
|
-
end
|
10
|
-
|
11
|
-
def setup?
|
12
|
-
true
|
13
|
-
end
|
14
|
-
|
15
|
-
def start(args = ARGV)
|
16
|
-
Trinidad::CommandLineParser.parse(args)
|
17
|
-
Trinidad.configuration.trap = false
|
18
|
-
@server = Trinidad::Server.new
|
19
|
-
@server.start
|
20
|
-
end
|
21
|
-
|
22
|
-
def stop
|
23
|
-
@server.stop
|
24
|
-
end
|
25
|
-
|
26
|
-
extend self
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
Trinidad::Daemon.init
|
1
|
+
require 'trinidad_init_services/version'
|
2
|
+
require 'trinidad_init_services/configuration'
|
@@ -1,9 +1,11 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'java'
|
3
|
+
require 'jruby'
|
4
|
+
require 'rbconfig'
|
5
|
+
require 'fileutils'
|
6
|
+
|
1
7
|
module Trinidad
|
2
8
|
module InitServices
|
3
|
-
require 'erb'
|
4
|
-
require 'java'
|
5
|
-
require 'rbconfig'
|
6
|
-
require 'fileutils'
|
7
9
|
|
8
10
|
class Configuration
|
9
11
|
def initialize(stdin = STDIN, stdout = STDOUT)
|
@@ -12,7 +14,7 @@ module Trinidad
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def initialize_paths
|
15
|
-
@trinidad_daemon_path = File.expand_path('../../
|
17
|
+
@trinidad_daemon_path = File.expand_path('../../trinidad/daemon.rb', __FILE__)
|
16
18
|
@jars_path = File.expand_path('../../../trinidad-libs', __FILE__)
|
17
19
|
|
18
20
|
@classpath = ['jruby-jsvc.jar', 'commons-daemon.jar'].map { |jar| File.join(@jars_path, jar) }
|
@@ -54,8 +56,16 @@ module Trinidad
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def configure_unix_daemon(defaults)
|
57
|
-
@jsvc = defaults["jsvc_path"] || jsvc_path
|
58
59
|
@java_home = defaults["java_home"] || ask_path('Java home?', default_java_home)
|
60
|
+
unless @jsvc = defaults["jsvc_path"] || detect_jsvc_path
|
61
|
+
@jsvc = ask_path("path to jsvc binary (leave blank and we'll try to compile)?", '')
|
62
|
+
if @jsvc.empty? # unpack and compile :
|
63
|
+
jsvc_unpack_dir = defaults["jsvc_unpack_dir"] || ask_path("dir where jsvc dist should be unpacked?", '/usr/local/src')
|
64
|
+
@jsvc = compile_jsvc(jsvc_unpack_dir, @java_home)
|
65
|
+
puts "jsvc binary available at: #{@jsvc} " +
|
66
|
+
"(consider adding it to $PATH if you plan to re-run trinidad_init_service)"
|
67
|
+
end
|
68
|
+
end
|
59
69
|
@output_path = defaults["output_path"] || ask_path('init.d output path?', '/etc/init.d')
|
60
70
|
@pid_file = defaults["pid_file"] || ask_path('pid file?', '/var/run/trinidad/trinidad.pid')
|
61
71
|
@log_file = defaults["log_file"] || ask_path('log file?', '/var/log/trinidad/trinidad.log')
|
@@ -65,7 +75,9 @@ module Trinidad
|
|
65
75
|
raise ArgumentError, "user '#{@run_user}' does not exist (leave blank if you're planning to `useradd' later)"
|
66
76
|
end
|
67
77
|
|
78
|
+
@pid_file = File.join(@pid_file, 'trinidad.pid') if File.exist?(@pid_file) && File.directory?(@pid_file)
|
68
79
|
make_path_dir(@pid_file, "could not create dir for '#{@pid_file}', make sure dir exists before running daemon")
|
80
|
+
@log_file = File.join(@log_file, 'trinidad.log') if File.exist?(@log_file) && File.directory?(@log_file)
|
69
81
|
make_path_dir(@log_file, "could not create dir for '#{@log_file}', make sure dir exists before running daemon")
|
70
82
|
|
71
83
|
daemon = ERB.new(
|
@@ -81,7 +93,7 @@ module Trinidad
|
|
81
93
|
end
|
82
94
|
|
83
95
|
def configure_windows_service
|
84
|
-
srv_path =
|
96
|
+
srv_path = bundled_prunsrv_path
|
85
97
|
trinidad_service_id = @trinidad_name.gsub(/\W/, '')
|
86
98
|
|
87
99
|
command = %Q{//IS//#{trinidad_service_id} --DisplayName="#{@trinidad_name}" \
|
@@ -111,11 +123,11 @@ module Trinidad
|
|
111
123
|
end
|
112
124
|
|
113
125
|
def default_java_home
|
114
|
-
Java::JavaLang::System.get_property("java.home")
|
126
|
+
ENV['JAVA_HOME'] || Java::JavaLang::System.get_property("java.home")
|
115
127
|
end
|
116
|
-
|
128
|
+
|
117
129
|
def default_ruby_compat_version
|
118
|
-
"RUBY1_8"
|
130
|
+
JRuby.runtime.is1_9 ? "RUBY1_9" : "RUBY1_8"
|
119
131
|
end
|
120
132
|
|
121
133
|
def windows?
|
@@ -130,12 +142,75 @@ module Trinidad
|
|
130
142
|
RbConfig::CONFIG['arch'] =~ /i686|ia64/i
|
131
143
|
end
|
132
144
|
|
133
|
-
def
|
145
|
+
def bundled_jsvc_path
|
134
146
|
jsvc = 'jsvc_' + (macosx? ? 'darwin' : 'linux')
|
135
|
-
File.join(@jars_path, jsvc)
|
147
|
+
jsvc_path = File.join(@jars_path, jsvc)
|
148
|
+
# linux version is no longer bundled - as long as it is not present jsvc
|
149
|
+
# will be compiled from src (if not installed already #detect_jsvc_path)
|
150
|
+
File.exist?(jsvc_path) ? jsvc_path : nil
|
136
151
|
end
|
137
152
|
|
138
|
-
def
|
153
|
+
def detect_jsvc_path
|
154
|
+
jsvc_path = `which jsvc` # "/usr/bin/jsvc\n"
|
155
|
+
jsvc_path.chomp!
|
156
|
+
jsvc_path.empty? ? bundled_jsvc_path : jsvc_path
|
157
|
+
end
|
158
|
+
|
159
|
+
def compile_jsvc(jsvc_unpack_dir, java_home = default_java_home)
|
160
|
+
unless File.exist?(jsvc_unpack_dir)
|
161
|
+
raise "specified path does not exist: #{jsvc_unpack_dir.inspect}"
|
162
|
+
end
|
163
|
+
unless File.directory?(jsvc_unpack_dir)
|
164
|
+
raise "specified path: #{jsvc_unpack_dir.inspect} is not a directory"
|
165
|
+
end
|
166
|
+
unless File.writable?(jsvc_unpack_dir)
|
167
|
+
raise "specified path: #{jsvc_unpack_dir.inspect} is not writable"
|
168
|
+
end
|
169
|
+
|
170
|
+
jsvc_unix_src = File.expand_path('../../jsvc-unix-src', File.dirname(__FILE__))
|
171
|
+
FileUtils.cp_r(jsvc_unix_src, jsvc_unpack_dir)
|
172
|
+
|
173
|
+
jsvc_dir = File.expand_path('jsvc-unix-src', jsvc_unpack_dir)
|
174
|
+
File.chmod(0755, File.join(jsvc_dir, "configure"))
|
175
|
+
# ./configure
|
176
|
+
unless jdk_home = detect_jdk_home(java_home)
|
177
|
+
warn "seems you only have a JRE installed, a JDK is needed to compile jsvc"
|
178
|
+
jdk_home = java_home # it's still worth trying
|
179
|
+
end
|
180
|
+
command = "cd #{jsvc_dir} && ./configure --with-java=#{jdk_home}"
|
181
|
+
puts "configuring jsvc ..."
|
182
|
+
command_output = `#{command}`
|
183
|
+
if $?.exitstatus != 0
|
184
|
+
puts command_output
|
185
|
+
raise "`#{command}` failed with status: #{$?.exitstatus}"
|
186
|
+
end
|
187
|
+
|
188
|
+
# make
|
189
|
+
command = "cd #{jsvc_dir} && make"
|
190
|
+
puts "compiling jsvc ..."
|
191
|
+
command_output = `#{command}`
|
192
|
+
if $?.exitstatus != 0
|
193
|
+
puts command_output
|
194
|
+
raise "`#{command}` failed with status: #{$?.exitstatus}"
|
195
|
+
end
|
196
|
+
|
197
|
+
File.expand_path('jsvc', jsvc_dir) # return path to compiled jsvc binary
|
198
|
+
end
|
199
|
+
|
200
|
+
def detect_jdk_home(java_home = default_java_home)
|
201
|
+
# JDK has an include directory with headers :
|
202
|
+
if File.directory?(File.join(java_home, 'include'))
|
203
|
+
return java_home
|
204
|
+
end
|
205
|
+
# java_home might be a nested JDK path e.g. /opt/java/jdk/jre
|
206
|
+
jdk_home = File.dirname(java_home) # /opt/jdk/jre -> /opt/jdk
|
207
|
+
if File.exist?(File.join(jdk_home, 'bin/java'))
|
208
|
+
return jdk_home
|
209
|
+
end
|
210
|
+
nil
|
211
|
+
end
|
212
|
+
|
213
|
+
def bundled_prunsrv_path
|
139
214
|
prunsrv = 'prunsrv_' + (ia64? ? 'ia64' : 'amd64') + '.exe'
|
140
215
|
File.join(@jars_path, prunsrv)
|
141
216
|
end
|
@@ -152,7 +227,8 @@ module Trinidad
|
|
152
227
|
end
|
153
228
|
|
154
229
|
def ask_path(question, default = nil)
|
155
|
-
|
230
|
+
path = ask(question, default)
|
231
|
+
path.empty? ? path : File.expand_path(path)
|
156
232
|
end
|
157
233
|
|
158
234
|
def ask(question, default = nil)
|
@@ -181,6 +257,7 @@ module Trinidad
|
|
181
257
|
end
|
182
258
|
return result
|
183
259
|
end
|
260
|
+
|
184
261
|
end
|
185
262
|
end
|
186
263
|
end
|