Committed by
Gerrit Code Review
Set -u and -e, and respect ONOS_HOME
If errors or undefined variables are introduced into this script, we should exit with an error. In particular, we should exit with an error if KARAF_VERSION is not defined rather than failing semi-silently. If ONOS_HOME is set, we should respect (and use) its value. If ONOS_HOME is not set (as it will not be in the init or service environment), intuit its value based on the path to this script. Change-Id: I91c733fddcb2241a95466667e4b57ce0f74a8194
Showing
1 changed file
with
9 additions
and
11 deletions
| ... | @@ -10,20 +10,18 @@ | ... | @@ -10,20 +10,18 @@ |
| 10 | # Do modify the keystore location/password and truststore location/password accordingly | 10 | # Do modify the keystore location/password and truststore location/password accordingly |
| 11 | #export JAVA_OPTS="${JAVA_OPTS:--DenableNettyTLS=true -Djavax.net.ssl.keyStore=/home/ubuntu/onos.jks -Djavax.net.ssl.keyStorePassword=222222 -Djavax.net.ssl.trustStore=/home/ubuntu/onos.jks -Djavax.net.ssl.trustStorePassword=222222}" | 11 | #export JAVA_OPTS="${JAVA_OPTS:--DenableNettyTLS=true -Djavax.net.ssl.keyStore=/home/ubuntu/onos.jks -Djavax.net.ssl.keyStorePassword=222222 -Djavax.net.ssl.trustStore=/home/ubuntu/onos.jks -Djavax.net.ssl.trustStorePassword=222222}" |
| 12 | 12 | ||
| 13 | -ONOS_HOME=/opt/onos | 13 | +set -e # exit on error |
| 14 | +set -u # exit on undefined variable | ||
| 15 | + | ||
| 16 | +# If ONOS_HOME is set, respect its value. | ||
| 17 | +# If ONOS_HOME is not set (e.g. in the init or service environment), | ||
| 18 | +# set it based on this script's path. | ||
| 19 | +ONOS_HOME=${ONOS_HOME:-$(readlink -e `dirname $0`/..)} | ||
| 14 | KARAF_ARGS= | 20 | KARAF_ARGS= |
| 15 | SYS_APPS=drivers | 21 | SYS_APPS=drivers |
| 16 | -CURRENT_ONOS_HOME="`( cd $(dirname $0)/.. && pwd )`" | 22 | +ONOS_APPS=${ONOS_APPS:-} # Empty means don't activate any new apps |
| 17 | - | ||
| 18 | -# check whether executable onos binary is located under /opt/onos | ||
| 19 | -# if not try to reconfigure ONOS_HOME with current path | ||
| 20 | -if [ $CURRENT_ONOS_HOME != $ONOS_HOME ]; then | ||
| 21 | - ONOS_HOME=$CURRENT_ONOS_HOME | ||
| 22 | -fi | ||
| 23 | - | ||
| 24 | -echo $ONOS_HOME | ||
| 25 | 23 | ||
| 26 | -[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/.. | 24 | +cd $ONOS_HOME |
| 27 | 25 | ||
| 28 | # Parse out arguments destinted for karaf invocation v. arguments that | 26 | # Parse out arguments destinted for karaf invocation v. arguments that |
| 29 | # will be processed in line | 27 | # will be processed in line | ... | ... |
-
Please register or login to post a comment