Commit d3f24ca9 authored by Ian Johnson's avatar Ian Johnson Committed by Ian Johnson

many: make snap scripts shellcheck compliant

Note we turn off the warning about the constant value for loop in case
we ever need to add another java service it will be easier if we leave
this in place.
Signed-off-by: default avatarIan Johnson <ian.johnson@canonical.com>
parent 82cece71
......@@ -60,7 +60,7 @@ handle_svc () {
for key in $ALL_SERVICES; do
# get the config key for the service
status=$(snapctl get $key)
status=$(snapctl get "$key")
case $key in
device*)
# the device services are all using the device-sdk-go which waits
......@@ -71,7 +71,7 @@ for key in $ALL_SERVICES; do
handle_svc "core-metadata" "on"
fi
# handle the service too
handle_svc "$key" $status
handle_svc "$key" "$status"
;;
mongo-worker|edgexproxy|vault-worker)
# it doesn't make any sense to disable the *-worker daemons since
......@@ -83,9 +83,9 @@ for key in $ALL_SERVICES; do
# - kong
# - cassandra (because kong requires it)
# - edgexproxy
handle_svc "cassandra" $status
handle_svc "kong-daemon" $status
handle_svc "edgexproxy" $status
handle_svc "cassandra" "$status"
handle_svc "kong-daemon" "$status"
handle_svc "edgexproxy" "$status"
# additionally, the secrity-api-gateway needs to use the following
# services:
# - vault (because edgexproxy will access/store secrets in vault)
......@@ -109,14 +109,14 @@ for key in $ALL_SERVICES; do
handle_svc "kong-daemon" "off"
handle_svc "edgexproxy" "off"
fi
handle_svc "vault" $status
handle_svc "vault-worker" $status
handle_svc "vault" "$status"
handle_svc "vault-worker" "$status"
;;
*)
# default case for all other services just enable/disable the service using
# snapd/systemd
# if the service is meant to be off, then disable it
handle_svc $key $status
handle_svc "$key" "$status"
;;
esac
done
......@@ -217,4 +217,4 @@ case "$dbProvider" in
echo "invalid setting for dbtype: $dbProvider"
exit 1
;;
esac
\ No newline at end of file
esac
This diff is collapsed.
#!/bin/bash
# example usage:
# $ gopartbootstrap github.com/edgexfoundry/edgex-go
gopartbootstrap()
{
# first set the GOPATH to be in the current directory and in ".gopath"
export GOPATH="$(pwd)/.gopath"
GOPATH="$(pwd)/.gopath"
export GOPATH
# setup path to include both $SNAPCRAFT_STAGE/bin and $GOPATH/bin
# the former is for the go tools, as well as things like glide, etc.
# while the later is for govendor, etc. and other go tools that might need to be installed
export PATH="$SNAPCRAFT_STAGE/bin:$GOPATH/bin:$PATH"
# set GOROOT to be whatever the go tool from SNAPCRAFT_STAGE/bin is
export GOROOT=$(go env GOROOT)
GOROOT=$(go env GOROOT)
export GOROOT
# now setup the GOPATH for this part using the import path
export GOIMPORTPATH="$GOPATH/src/$1"
mkdir -p $GOIMPORTPATH
mkdir -p "$GOIMPORTPATH"
# note that some tools such as govendor don't work well with symbolic links, so while it's unfortunate
# we have to copy all this it's a necessary evil at the moment...
# but note that we do ignore all files that start with "." with the "./*" pattern
cp -r ./* $GOIMPORTPATH
cp -r ./* "$GOIMPORTPATH"
# finally go into the go import path to prepare for building
cd $GOIMPORTPATH
cd "$GOIMPORTPATH" || exit
}
......@@ -20,7 +20,7 @@ else
CLASSPATH=$CASSANDRA_CONF
fi
for jar in $SNAP/usr/share/cassandra/lib/*.jar; do
for jar in "$SNAP/usr/share/cassandra/lib"/*.jar; do
CLASSPATH="$CLASSPATH:$jar"
done
......@@ -47,7 +47,8 @@ export cassandra_storagedir="$CASSANDRA_DATA"
export JVM_OPTS="$JVM_OPTS -Dcassandra.config=file://$CASSANDRA_CONF/cassandra.yaml"
# set JAVA_HOME
export JAVA_HOME=$(ls -d $SNAP/usr/lib/jvm/java-1.8.0-openjdk-*)
JAVA_HOME=$(ls -d "$SNAP/usr/lib/jvm"/java-1.8.0-openjdk-*)
export JAVA_HOME
# The -x bit isn't set on cassandra
/bin/sh $SNAP/usr/sbin/cassandra -R -p "$CASSANDRA_HOME/cassandra.pid"
/bin/sh "$SNAP/usr/sbin/cassandra" -R -p "$CASSANDRA_HOME/cassandra.pid"
#!/bin/bash -e
export SEC_API_GATEWAY_CONFIG_DIR=${SNAP_DATA}/config/security-api-gateway
export SEC_API_GATEWAY_CONFIG_DIR=$SNAP_DATA/config/security-api-gateway
cd ${SEC_API_GATEWAY_CONFIG_DIR}
$SNAP/bin/edgexproxy --configfile=${SEC_API_GATEWAY_CONFIG_DIR}/res/configuration.toml --init=true
cd "$SEC_API_GATEWAY_CONFIG_DIR"
"$SNAP/bin/edgexproxy" --configfile="$SEC_API_GATEWAY_CONFIG_DIR/res/configuration.toml" --init=true
#!/bin/bash -e
# the kong wrapper script from $SNAP
export KONG_SNAP="${SNAP}/bin/kong-wrapper.sh"
export KONG_SNAP="$SNAP/bin/kong-wrapper.sh"
# run kong migrations up to bootstrap the cassandra database
# note that sometimes cassandra can be in a "starting up" state, etc.
# and in this case we should just loop and keep trying
# we don't implement a timeout here because systemd will kill us if we
# don't succeed in 15 minutes (or whatever the configured stop-timeout is)
until $KONG_SNAP migrations up --yes --conf $KONG_CONF; do
until $KONG_SNAP migrations up --yes --conf "$KONG_CONF"; do
sleep 5
done
# now start kong normally
$KONG_SNAP start --conf $KONG_CONF
$KONG_SNAP start --conf "$KONG_CONF"
#!/bin/bash
# stop kong
$SNAP/bin/kong-wrapper.sh stop -p $SNAP_DATA/kong
"$SNAP/bin/kong-wrapper.sh" stop -p "$SNAP_DATA/kong"
# in some cases stopping kong doesn't succeed properly, so to ensure that
# it always is put into a state where it can startup, just remove the env
# file in case it somehow still exists, then the next invocation of kong
# will always be able to start
rm -f $SNAP_DATA/kong/.kong_env
rm -f "$SNAP_DATA/kong/.kong_env"
......@@ -3,7 +3,7 @@
# try to initialize mongo, giving up after a reasonable number of tries
MAX_TRIES=10
num_tries=0
until mongo $SNAP/mongo/init_mongo.js; do
until mongo "$SNAP/mongo/init_mongo.js"; do
sleep 5
# increment number of tries
num_tries=$((num_tries+1))
......
......@@ -14,5 +14,5 @@ JAVA="$SNAP"/usr/lib/jvm/java-8-openjdk-"$ARCH"/jre/bin/java
$JAVA -jar -Djava.security.egd=file:/dev/urandom -Xmx100M \
-Dspring.cloud.consul.enabled=true \
-Dspring.cloud.consul.host=localhost \
-Dlogging.file=$SNAP_COMMON/logs/edgex-support-rulesengine.log \
$SNAP/jar/support-rulesengine/support-rulesengine.jar
-Dlogging.file="$SNAP_COMMON/logs/edgex-support-rulesengine.log" \
"$SNAP/jar/support-rulesengine/support-rulesengine.jar"
#!/bin/bash -e
export CONFIG_DIR=${SNAP_DATA}/config
export SEC_SEC_STORE_CONFIG_DIR=${CONFIG_DIR}/security-secret-store
export SEC_API_GATEWAY_CONFIG_DIR=${CONFIG_DIR}/security-api-gateway
export CONFIG_DIR=$SNAP_DATA/config
export SEC_SEC_STORE_CONFIG_DIR=$CONFIG_DIR/security-secret-store
export SEC_API_GATEWAY_CONFIG_DIR=$CONFIG_DIR/security-api-gateway
# run the vault-worker
cd ${SEC_SEC_STORE_CONFIG_DIR}
cd "$SEC_SEC_STORE_CONFIG_DIR"
$SNAP/bin/vault-worker --init=true --configfile=${SEC_SEC_STORE_CONFIG_DIR}/res/configuration.toml
"$SNAP/bin/vault-worker" --init=true --configfile="$SEC_SEC_STORE_CONFIG_DIR/res/configuration.toml"
# copy the kong access token to the config directory for the security-api-gateway so it has
# perms to read the certs from vault and upload them into kong
cp ${SEC_SEC_STORE_CONFIG_DIR}/res/kong-token.json ${SEC_API_GATEWAY_CONFIG_DIR}/res/kong-token.json
cp "$SEC_SEC_STORE_CONFIG_DIR/res/kong-token.json" "$SEC_API_GATEWAY_CONFIG_DIR/res/kong-token.json"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment