Merge lp:~kwmonroe/charms/trusty/ibm-java/may-2016 into lp:~ibmcharmers/charms/trusty/ibm-java/source
- Trusty Tahr (14.04)
- may-2016
- Merge into source
Proposed by
Kevin W Monroe
Status: | Merged |
---|---|
Merged at revision: | 4 |
Proposed branch: | lp:~kwmonroe/charms/trusty/ibm-java/may-2016 |
Merge into: | lp:~ibmcharmers/charms/trusty/ibm-java/source |
Diff against target: |
524 lines (+153/-190) 4 files modified
README.md (+87/-106) config.yaml (+0/-8) files/sftp_get.sh (+21/-6) reactive/ibm-java (+45/-70) |
To merge this branch: | bzr merge lp:~kwmonroe/charms/trusty/ibm-java/may-2016 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matt Bruzek (community) | Approve | ||
Review via email: mp+294984@code.launchpad.net |
Commit message
Description of the change
Updates from May 17 review:
- reduce verbosity (charms.reactive is too verbose with set +x)
- better checks to determine if sdk or jre is installed
- safer removal of ibm java
- manage javac alternative when the sdk is installed
- update expect script in case our sftp host does not require a password
- remove unneeded install-type logic since the user configures a specific package which does not necessarily match any configured install-type.
- update readme to reflect above changes
To post a comment you must log in.
- 9. By Kevin W Monroe
-
use correct path in /etc/profile
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'README.md' |
2 | --- README.md 2016-02-29 18:53:01 +0000 |
3 | +++ README.md 2016-05-18 02:37:35 +0000 |
4 | @@ -1,14 +1,11 @@ |
5 | - |
6 | -# Charm for IBM Java 1.8.0 |
7 | - |
8 | -### Overview |
9 | - |
10 | -IBM Java |
11 | +# IBM Java 1.8.0 |
12 | + |
13 | +## Overview |
14 | |
15 | The IBM implementation of the Java platform provides a development toolkit and |
16 | an application runtime environment. |
17 | |
18 | -IBM supply two installable packages depending on platform: The Software |
19 | +IBM supplies two installable packages depending on platform: The Software |
20 | Developers Kit (SDK) and the Java Runtime Environment (JRE). The key components |
21 | in this charm are |
22 | |
23 | @@ -19,136 +16,120 @@ |
24 | - J9 Virtual Machine (JVM) - The IBM J9 virtual machine (JVM) is the |
25 | platform-specific component that runs a Java program. |
26 | |
27 | -User guides and security guides to support this release are available for |
28 | -Online viewing [User Guide](http://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/welcome/welcome_javasdk_version.html) |
29 | - |
30 | -Any late breaking news can be found in the following |
31 | -[IBM support technote](http://www.ibm.com/support/docview.wss?uid=swg21672834) |
32 | - |
33 | -### Download of Product Binaries |
34 | - |
35 | -Download your licensed IBM Java 1.8.0 software for Ubuntu. |
36 | - |
37 | -You can download product binaries from |
38 | -[IBM developerWorks](https://www.ibm.com/developerworks/java/jdk/index.html) |
39 | - |
40 | - |
41 | -#### Usage |
42 | - |
43 | -To install the downloaded binaries you must agree to the IBM license. |
44 | +User and security guides to support this release are available for in the [User Guide](http://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/welcome/welcome_javasdk_version.html). |
45 | + |
46 | +Late breaking news can be found in the [IBM support technote](http://www.ibm.com/support/docview.wss?uid=swg21672834). |
47 | + |
48 | + |
49 | +## Download of Product Binaries |
50 | + |
51 | +Download your licensed IBM Java 1.8.0 software for Ubuntu from |
52 | +[IBM developerWorks](https://www.ibm.com/developerworks/java/jdk/index.html). |
53 | + |
54 | + |
55 | +## Usage |
56 | + |
57 | +To install the downloaded binaries, you must agree to the IBM license. |
58 | |
59 | IBM Java is a subordinate charm that can be related to any existing services |
60 | -which consumes IBM Java as this charm relates via java interface. |
61 | +which require a java interface. |
62 | |
63 | Run the following to deploy this charm: |
64 | |
65 | juju deploy ibm-java |
66 | |
67 | -Here is the simple deployment scenario wherein IBM Java being installed on the ubuntu-devenv unit: |
68 | +Here is a simple deployment scenario where IBM Java is installed on the |
69 | +`ubuntu-devenv` unit: |
70 | |
71 | - juju deploy cs:~kwmonroe/trusty/ubuntu-devenv |
72 | + juju deploy cs:trusty/ubuntu-devenv |
73 | juju add-relation ubuntu-devenv ibm-java |
74 | |
75 | -In the above deployment scenario ubuntu-devenv and ibm-java charms are related via java interface. |
76 | - |
77 | -At this point the charm will wait until the user accepts the license. If you |
78 | -agree to the license, run the following command: |
79 | - |
80 | -Set all required config values like the SFTP server, package name, directory |
81 | -in SFTP server where package is kept, username and password to connect to |
82 | -SFTP host and checksum value to proceed with installation, by using |
83 | -juju set command. To provide these run the following command: |
84 | - |
85 | - juju set ibm-java accept-ibm-java-license=True |
86 | - |
87 | -If not, |
88 | +In the above deployment scenario, ubuntu-devenv and ibm-java charms are related |
89 | +via the java interface. At this point, the charm will wait until the user |
90 | +accepts the license and provides required configuration. |
91 | + |
92 | +Set all required config values such as the SFTP server, package name, remote |
93 | +directory where the installable package is hosted, username and password to |
94 | +connect to the SFTP host, and checksum value to proceed with installation. To |
95 | +provide these run the following command: |
96 | |
97 | juju set ibm-java accept-ibm-java-license=True \ |
98 | - host=<Web server host name> \ |
99 | - package_dir=<Fully qualified Package path, do not add the package name > \ |
100 | - username=<User name of the repository host> \ |
101 | - password=<Password of the repository host> \ |
102 | - javasdk_file_name=<IBM Java Package name> \ |
103 | - javasdk_path_name=<IBM Java target Installation Directory> \ |
104 | - java-major=<IBM Java Major version of java> \ |
105 | - install-type=<IBM Java type of install to perform. Valid options are 'jre' or 'full'> |
106 | - |
107 | - |
108 | -Once deployed, you can use IBM Java to run any Java workloads. To verify java is installed or not |
109 | -get into the containter where IBM Java is installed and run the below command. |
110 | - |
111 | - java -version |
112 | - |
113 | -To get into the container run the below commmand. |
114 | - |
115 | - juju ssh <machine-id where IBM Java is installed> |
116 | - |
117 | - |
118 | -### Uninstallation of ibm-java |
119 | - |
120 | -Setting the accept-ibm-java-license to False will uninstall the product. |
121 | + host=<sftp server host name> \ |
122 | + package_dir=<remote package path, do not add the package name> \ |
123 | + java_file_name=<java installer file name> \ |
124 | + username=<User name for the sftp host> \ |
125 | + password=<Password for the sftp host> \ |
126 | + java_path_name=<target installation directory (defaults to /opt/ibm/java)> |
127 | + |
128 | + |
129 | +Once deployed, you can use IBM Java to run any Java workloads. Verify that |
130 | +java is installed correctly with: |
131 | + |
132 | + juju run --service=ibm-java 'java -version' |
133 | + |
134 | +Access the machine running IBM Java with: |
135 | + |
136 | + juju ssh ibm-java/0 |
137 | + |
138 | + |
139 | +## Uninstalling IBM Java |
140 | + |
141 | +Setting the `accept-ibm-java-license` to `False` will uninstall the product: |
142 | |
143 | juju set ibm-java accept-ibm-java-license=False |
144 | |
145 | |
146 | -### Configuration |
147 | +## Configuration |
148 | |
149 | - **accept-ibm-java-license** Before you can use or install IBM Java, |
150 | - you must accept the terms of International License |
151 | + you must accept the terms of the International License |
152 | Agreement for Non-Warranted Programs and additional license information. |
153 | Please read the license agreement carefully |
154 | - [IBM Java SDK License](http://www-03.ibm.com/software/sla/sladb.nsf/displaylis/B0D11A46C1BE8BB585257E3B00660B2C?OpenDocument). Set the value of accept-ibm-java-license to True if you agree to IBM Java license. |
155 | - |
156 | -**The IBM Java software cannot be installed until the terms and |
157 | -conditions are accepted. The charm will not function correctly until the |
158 | -this configuration option is set to True.** |
159 | - |
160 | -- **host** The web server host name from which IBM Java SDK installation packages |
161 | + [IBM Java SDK License](http://www-03.ibm.com/software/sla/sladb.nsf/displaylis/B0D11A46C1BE8BB585257E3B00660B2C?OpenDocument). Set the value of accept-ibm-java-license to True if you agree |
162 | + to the IBM Java license. |
163 | + |
164 | + **IBM Java software cannot be installed until the terms and conditions are |
165 | + accepted. The charm will not function correctly until the this configuration |
166 | + option is set to True.** |
167 | + |
168 | +- **host** The sftp server host name from which IBM Java installation packages |
169 | can be downloaded. |
170 | |
171 | -- **package_dir** The package directory path in the web server. |
172 | - |
173 | -- **username** User name of the webserver host. |
174 | - |
175 | -- **password** Password of the webserver host. |
176 | +- **package_dir** The remote directory containing the IBM Java installation package. |
177 | |
178 | - **java_file_name** The IBM Java Package name. If not set, it is |
179 | - assigned to the default package name for power or x86_64 based machine. |
180 | - |
181 | -- **java_path_name** The IBM Java SDK target installation directory. If not |
182 | - set, it will be assigned to the default value "/opt/ibm/java". |
183 | - |
184 | -- **sha** Checksum value to check integrity of IBM Java package. The Charm |
185 | - uses sha1sum to check the integrity. If empty, it does not carry out the |
186 | - integrity check. Use `sha1sum <Package Location/Package Name> | cut -d" " -f1` |
187 | - to find out Checksum value for downloaded package. Cryptographic value |
188 | - should be altered by the user only when the package name is change. Else it |
189 | - should not be altered. |
190 | - |
191 | -- **install-type** Type of install to perform. Valid options are 'jre' or 'full'. |
192 | - The default is 'jre', which will install the IBM Java Runtime Environment (JRE). |
193 | - Setting this to 'full' will install the IBM Java Development Kit in addition to the JRE. |
194 | - |
195 | -### IBM Java Information |
196 | + assigned to the default package name for power or x86_64 based machines. |
197 | + |
198 | +- **username** User name of the sftp host. |
199 | + |
200 | +- **password** Password of the sftp host. |
201 | + |
202 | +- **java_path_name** The IBM Java target installation directory. If not |
203 | + set, it will be assigned to the default value `/opt/ibm/java`. |
204 | + |
205 | +- **sha** Checksum value to check integrity of the downloaded IBM Java |
206 | + installaer package. This charm uses sha1sum to verify the integrity. |
207 | + |
208 | +## IBM Java Information |
209 | |
210 | ### General Information |
211 | |
212 | -Details about IBM Java available [Here](http://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/welcome/welcome_javasdk_version.html) |
213 | +Details about IBM Java available [Here](http://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/welcome/welcome_javasdk_version.html). |
214 | |
215 | ### Download Information |
216 | |
217 | -Information on procuring IBM Java product is available at the [Product Page](http://www.ibm.com/developerworks/java/jdk/linux/download.html) |
218 | +Information on procuring IBM Java is available at the [Product Page](http://www.ibm.com/developerworks/java/jdk/linux/download.html). |
219 | |
220 | -A development version IBM Java is available [Here](http://www.ibm.com/software/products/en/mobilefirstfoundation) |
221 | +A development version of IBM Java is available [Here](http://www.ibm.com/software/products/en/mobilefirstfoundation). |
222 | |
223 | ### License Information |
224 | |
225 | -License information for IBM Java can be viewed [Here](http://www-03.ibm.com/software/sla/sladb.nsf/displaylis/B0D11A46C1BE8BB585257E3B00660B2C?OpenDocument) |
226 | - |
227 | -### Known Limitations |
228 | - |
229 | -This charm makes use of Juju Status commands, and requires juju 1.24 or greater |
230 | - |
231 | -### Contact Information |
232 | - |
233 | -For issues with this charm, please contact [IBM Juju Support Team](mailto:jujusupp@us.ibm.com) |
234 | +License information for IBM Java can be viewed [Here](http://www-03.ibm.com/software/sla/sladb.nsf/displaylis/B0D11A46C1BE8BB585257E3B00660B2C?OpenDocument). |
235 | + |
236 | +## Known Limitations |
237 | + |
238 | +This charm makes use of Juju status commands, and requires juju 1.25 or greater. |
239 | + |
240 | +## Contact Information |
241 | + |
242 | +For issues with this charm, please contact the [IBM Juju Support Team](mailto:jujusupp@us.ibm.com). |
243 | |
244 | === modified file 'config.yaml' |
245 | --- config.yaml 2016-02-29 18:53:01 +0000 |
246 | +++ config.yaml 2016-05-18 02:37:35 +0000 |
247 | @@ -55,11 +55,3 @@ |
248 | the integrity check. Refer README file to find out Checksum value for |
249 | downloaded package. Cryptographic value should be altered by the user |
250 | only when the package name is change. Else it should not be altered. |
251 | - install-type: |
252 | - type: string |
253 | - default: jre |
254 | - description: | |
255 | - Type of install to perform. Valid options are 'jre' or 'full'. The |
256 | - default is 'jre', which will install the IBM Java Runtime Environment |
257 | - (JRE). Setting this to 'full' will install the IBM Java Development |
258 | - Kit in addition to the JRE. |
259 | |
260 | === modified file 'files/sftp_get.sh' |
261 | --- files/sftp_get.sh 2016-02-29 18:17:24 +0000 |
262 | +++ files/sftp_get.sh 2016-05-18 02:37:35 +0000 |
263 | @@ -9,10 +9,25 @@ |
264 | set r_dir [lindex $argv 3] |
265 | set localpath [lindex $argv 4] |
266 | |
267 | -set timeout 90 |
268 | +set timeout 600 |
269 | spawn sftp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $user@$host:$r_dir $localpath |
270 | -expect "password:" |
271 | -send "$password\n" |
272 | -set timeout 3000 |
273 | -catch wait result |
274 | -exit [lindex $result 3] |
275 | +expect { |
276 | + timeout { |
277 | + send_user "\nFailed to execute sftp\n" |
278 | + exit 1 |
279 | + } |
280 | + eof { |
281 | + exit 0 |
282 | + } |
283 | + "*assword:" |
284 | +} |
285 | +send "$password\r" |
286 | +expect { |
287 | + timeout { |
288 | + send_user "\nFailed to download in time\n" |
289 | + exit 1 |
290 | + } |
291 | + eof { |
292 | + exit 0 |
293 | + } |
294 | +} |
295 | |
296 | === modified file 'reactive/ibm-java' |
297 | --- reactive/ibm-java 2016-05-12 06:49:51 +0000 |
298 | +++ reactive/ibm-java 2016-05-18 02:37:35 +0000 |
299 | @@ -1,8 +1,6 @@ |
300 | #!/bin/bash |
301 | - |
302 | -set -ex |
303 | - |
304 | source charms.reactive.sh |
305 | +set -e |
306 | |
307 | ARCHIVE_DIR=$CHARM_DIR/files/archives |
308 | |
309 | @@ -18,14 +16,10 @@ |
310 | DEFAULT_INSTALLER_SDK_SHA="" |
311 | if [ "$ARCHITECTURE" = "x86_64" ]; then |
312 | DEFAULT_INSTALLER_FILE_SDK="ibm-java-x86_64-sdk-8.0-2.0.bin" |
313 | - DEFAULT_INSTALLER_FILE_JRE="ibm-java-x86_64-jre-8.0-2.0.bin" |
314 | DEFAULT_INSTALLER_SDK_SHA="71b3bf11ac6e04d8d697cca80ea00ab841f3ea57" |
315 | - DEFAULT_INSTALLER_JRE_SHA="ef0845dd42704b3ae956efdd113ff0d317582baf" |
316 | elif [ "$ARCHITECTURE" = "ppc64le" ]; then |
317 | DEFAULT_INSTALLER_FILE_SDK="ibm-java-ppc64le-sdk-8.0-2.0.bin" |
318 | - DEFAULT_INSTALLER_FILE_JRE="ibm-java-ppc64le-jre-8.0-2.0.bin" |
319 | DEFAULT_INSTALLER_SDK_SHA="73a12fd8491d8d18d2ad809a77d8bfde747cb899" |
320 | - DEFAULT_INSTALLER_JRE_SHA="0211e889166d4eee871cbb2d36e17d5cd5c9271f" |
321 | else |
322 | status-set blocked "IBM Java: Platform not supported" |
323 | fi |
324 | @@ -37,24 +31,20 @@ |
325 | # Check whether IBM Java is installed |
326 | function is_javasdk_installed() |
327 | { |
328 | - |
329 | - if [ -d $JAVA_INSTALL_PATH/bin ]; then |
330 | + if [ -f "$JAVA_INSTALL_PATH/bin/javac" ]; then |
331 | echo "True" |
332 | else |
333 | echo "False" |
334 | fi |
335 | - |
336 | } |
337 | |
338 | function is_jre_installed() |
339 | { |
340 | - |
341 | - if [ -d $JAVA_INSTALL_PATH/jre/bin ]; then |
342 | + if [ -f "$JAVA_INSTALL_PATH/jre/bin/java" ]; then |
343 | echo "True" |
344 | else |
345 | echo "False" |
346 | fi |
347 | - |
348 | } |
349 | |
350 | |
351 | @@ -64,19 +54,20 @@ |
352 | # function is called. |
353 | function remove_java_software() |
354 | { |
355 | - |
356 | javasdk_installed=`is_javasdk_installed` |
357 | jre_installed=`is_jre_installed` |
358 | - if [ $javasdk_installed == "True" ]; then |
359 | - $JAVA_INSTALL_PATH/_uninstall/uninstall |
360 | - rm -rf $JAVA_INSTALL_PATH |
361 | - sed --in-place "\|$JAVA_INSTALL_PATH|d" /etc/profile |
362 | - update-alternatives --remove "java" "$JAVA_INSTALL_PATH/bin/java" |
363 | - elif [ $jre_installed == "True" ]; then |
364 | - $JAVA_INSTALL_PATH/_uninstall/uninstall |
365 | - rm -rf $JAVA_INSTALL_PATH |
366 | - sed --in-place "\|$JAVA_INSTALL_PATH|d" /etc/profile |
367 | - update-alternatives --remove "java" "$JAVA_INSTALL_PATH/jre/bin/java" |
368 | + if [ -d "$JAVA_INSTALL_PATH" ]; then |
369 | + $JAVA_INSTALL_PATH/_uninstall/uninstall |
370 | + rm -rf $JAVA_INSTALL_PATH |
371 | + if [ $javasdk_installed == "True" ]; then |
372 | + sed --in-place "s|$JAVA_INSTALL_PATH/bin:||" /etc/profile |
373 | + update-alternatives --remove "javac" "$JAVA_INSTALL_PATH/bin/javac" |
374 | + if [ $jre_installed == "True" ]; then |
375 | + sed --in-place "s|$JAVA_INSTALL_PATH/jre/bin:||" /etc/profile |
376 | + update-alternatives --remove "java" "$JAVA_INSTALL_PATH/jre/bin/java" |
377 | + fi |
378 | + else |
379 | + juju-log "JAVA_INSTALL_PATH not found; could not remove java software" |
380 | fi |
381 | } |
382 | |
383 | @@ -86,7 +77,7 @@ |
384 | { |
385 | #Exit if URL to download package is null |
386 | if [ "$USERNAME" == "" -o "$PASSWORD" == "" -o "$HOST" == "" -o "$PACKAGE_DIR" == "" ]; then |
387 | - status-set blocked "IBM Java: Failed to download files from repository. Please provide vales for host,package_dir,username and password in config.yaml" |
388 | + status-set blocked "IBM Java: Failed to download files from repository. Please provide values for host,package_dir,username and password in config.yaml" |
389 | exit 0 |
390 | fi |
391 | |
392 | @@ -100,15 +91,10 @@ |
393 | |
394 | # Get the package name to check whether the user wants to install a different package |
395 | cfg_pkg_name=`config-get java_file_name` |
396 | - install_type=$(config-get 'install-type') |
397 | |
398 | # Set package name to a predefined value if the user has not provided a package name |
399 | if [ "$cfg_pkg_name" == "" ]; then |
400 | - if [[ ${install_type} == "full" ]]; then |
401 | - cfg_pkg_name=${DEFAULT_INSTALLER_FILE_SDK} |
402 | - else |
403 | - cfg_pkg_name=${DEFAULT_INSTALLER_FILE_JRE} |
404 | - fi |
405 | + cfg_pkg_name=${DEFAULT_INSTALLER_FILE_SDK} |
406 | fi |
407 | |
408 | # The user has configured a different package name |
409 | @@ -116,7 +102,7 @@ |
410 | #Download the new IBM Java package |
411 | status-set maintenance "Downloading IBM Java installer" |
412 | $CHARM_DIR/files/sftp_get.sh $USERNAME $PASSWORD $HOST $PACKAGE_DIR/$cfg_pkg_name $ARCHIVE_DIR |
413 | - if [ $? == 0 ]; then |
414 | + if [ $? -eq 0 ]; then |
415 | status-set maintenance "IBM Java: Downloaded IBM Java package." |
416 | chmod -R 777 $ARCHIVE_DIR/* |
417 | # Remove previously downloaded and installed IBM Java software |
418 | @@ -134,11 +120,7 @@ |
419 | # Check integrity of downloaded package |
420 | SHA=`config-get sha` |
421 | if [ "$SHA" == "" ]; then |
422 | - if [[ ${install_type} == "full" ]]; then |
423 | - SHA=${DEFAULT_INSTALLER_SDK_SHA} |
424 | - else |
425 | - SHA=${DEFAULT_INSTALLER_JRE_SHA} |
426 | - fi |
427 | + SHA=${DEFAULT_INSTALLER_SDK_SHA} |
428 | fi |
429 | if [ "$SHA" != "`sha1sum $ARCHIVE_DIR/$cfg_pkg_name | cut -d" " -f1`" ]; then |
430 | status-set blocked "SHA mismatch; set 'sha' to the sha1sum of ${cfg_pkg_name}" |
431 | @@ -150,8 +132,7 @@ |
432 | # Check Environment Variables for IBM Java |
433 | function check_javapath() |
434 | { |
435 | - cd /etc |
436 | - if grep -q "$JAVA_INSTALL_PATH" profile |
437 | + if grep -q "$JAVA_INSTALL_PATH" /etc/profile |
438 | then |
439 | echo "True" |
440 | else |
441 | @@ -179,7 +160,6 @@ |
442 | @when 'java.connected' 'license.accepted' |
443 | @when_not 'java.installed' |
444 | function install() { |
445 | - install_type=$(config-get 'install-type') |
446 | if [[ ! -d $ARCHIVE_DIR ]]; then |
447 | mkdir $ARCHIVE_DIR |
448 | fi |
449 | @@ -191,42 +171,38 @@ |
450 | set_java_path=`check_javapath` |
451 | if [ $set_java_path == "False" ]; then |
452 | cd /etc |
453 | - echo "export PATH=$JAVA_INSTALL_PATH/bin:$JAVASDK_INSTALL_PATH/jre/bin:$PATH" >> profile |
454 | - source /etc/profile |
455 | - else |
456 | - source /etc/profile |
457 | - fi |
458 | - |
459 | - if [[ ${install_type} == "full" ]]; then |
460 | - update-alternatives --install "/usr/bin/java" "java" "$JAVA_INSTALL_PATH/bin/java" 1 |
461 | - update-alternatives --set "java" "$JAVA_INSTALL_PATH/bin/java" |
462 | - else |
463 | - update-alternatives --install "/usr/bin/java" "java" "$JAVA_INSTALL_PATH/jre/bin/java" 1 |
464 | - update-alternatives --set "java" "$JAVA_INSTALL_PATH/jre/bin/java" |
465 | - fi |
466 | - |
467 | - # Send relation data |
468 | - java_home=$(readlink -f /usr/bin/java | sed "s:/bin/java::") |
469 | - java_version=$(java -version 2>&1 | grep -i version | head -1 | awk -F '"' {'print $2'}) |
470 | - relation_call --state=java.connected set_ready $java_home $java_version |
471 | - |
472 | - set_state 'java.installed' |
473 | - status-set active "IBM Java ${java_version} installed" |
474 | + echo "export PATH=$JAVA_INSTALL_PATH/bin:$JAVA_INSTALL_PATH/jre/bin:$PATH" >> profile |
475 | + source /etc/profile |
476 | + else |
477 | + source /etc/profile |
478 | + fi |
479 | + |
480 | + update-alternatives --install "/usr/bin/java" "java" "$JAVA_INSTALL_PATH/jre/bin/java" 1 |
481 | + update-alternatives --set "java" "$JAVA_INSTALL_PATH/jre/bin/java" |
482 | + if [ $javasdk_installed == "True" ]; then |
483 | + update-alternatives --install "/usr/bin/javac" "javac" "$JAVA_INSTALL_PATH/bin/javac" 1 |
484 | + update-alternatives --set "javac" "$JAVA_INSTALL_PATH/bin/javac" |
485 | + fi |
486 | + |
487 | java -version |
488 | - if [ $? == 0 ]; then |
489 | - if [[ ${install_type} == "full" ]]; then |
490 | + if [ $? -eq 0 ]; then |
491 | + # Send relation data |
492 | + java_home=$(readlink -f /usr/bin/java | sed "s:/bin/java::") |
493 | + java_version=$(java -version 2>&1 | grep -i version | head -1 | awk -F '"' {'print $2'}) |
494 | + relation_call --state=java.connected set_ready $java_home $java_version |
495 | + |
496 | + set_state 'java.installed' |
497 | + if [ $javasdk_installed == "True" ]; then |
498 | status-set active "Ready: IBM Java SDK $java_version" |
499 | else |
500 | status-set active "Ready: IBM Java Runtime Environment $java_version" |
501 | fi |
502 | else |
503 | - if [[ ${install_type} == "full" ]]; then |
504 | - update-alternatives --remove "java" "$JAVA_INSTALL_PATH/bin/java" |
505 | - status-set blocked "IBM Java: Error while installing IBM Java SDK" |
506 | - else |
507 | - update-alternatives --remove "java" "$JAVA_INSTALL_PATH/jre/bin/java" |
508 | - status-set blocked "IBM Java: Error while installing IBM Java Runtime Environment" |
509 | + update-alternatives --remove "java" "$JAVA_INSTALL_PATH/jre/bin/java" |
510 | + if [ $javasdk_installed == "True" ]; then |
511 | + update-alternatives --remove "javac" "$JAVA_INSTALL_PATH/bin/javac" |
512 | fi |
513 | + status-set blocked "IBM Java: Error while installing IBM Java" |
514 | fi |
515 | } |
516 | |
517 | @@ -234,7 +210,6 @@ |
518 | @when 'config.changed' |
519 | function check_version() { |
520 | if charms.reactive is_state 'config.changed.java_path_name' || \ |
521 | - charms.reactive is_state 'config.changed.install-type' || \ |
522 | charms.reactive is_state 'config.changed.java_file_name' || \ |
523 | charms.reactive is_state 'config.changed.sha'; then |
524 | status-set maintenance "Uninstalling all IBM Java versions before installing new one" |
I have not run this code, but this change looks good to me. +1 from my side!
The IBM charming team should review this proposal and if they agree, merge it into the ibm-java layer source.