Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some linter warnings #199

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions elasticsearch-init/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ TPL_DIR=/templates

_get_tpl_name_from_file() {
local tpl=$1
local tpl_name=$(basename $tpl)
echo $tpl_name
local tpl_name
tpl_name=$(basename "$tpl")
echo "$tpl_name"
}

if [ ! -d $TPL_DIR ]; then
Expand All @@ -18,10 +19,8 @@ fi
for template in $TPLS; do

echo "Handling template file $template"
tpl_name=`_get_tpl_name_from_file $template`
tpl_name=`_get_tpl_name_from_file "$template"`

curl -XPUT --retry 2 --retry-delay 2 $ELASTICSEARCH_URI/_template/${tpl_name} -d @$TPL_DIR/$template
curl -XPUT --retry 2 --retry-delay 2 "$ELASTICSEARCH_URI"/_template/"${tpl_name}" -d @$TPL_DIR/"$template"

done


8 changes: 4 additions & 4 deletions elasticsearch-init/wait-for.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/sh

: ${SLEEP_LENGTH:=2}
: "${SLEEP_LENGTH:=2}"

wait_for() {
echo Waiting for $1 to listen on $2...
while ! nc -z $1 $2; do echo sleeping; sleep $SLEEP_LENGTH; done
echo "Waiting for $1 to listen on $2..."
while ! nc -z "$1" "$2"; do echo sleeping; sleep "$SLEEP_LENGTH"; done
}

for var in "$@"
do
host=${var%:*}
port=${var#*:}
wait_for $host $port
wait_for "$host" "$port"
done
14 changes: 7 additions & 7 deletions kafka-init/wait-for.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Use this script to test if a given TCP host/port are available
# https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh

cmdname=$(basename $0)
cmdname=$(basename "$0")

echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }

Expand Down Expand Up @@ -34,10 +34,10 @@ wait_for()
while :
do
if [[ $ISBUSY -eq 1 ]]; then
nc -z $HOST $PORT
nc -z "$HOST" "$PORT"
result=$?
else
(echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1
(echo > /dev/tcp/"$HOST"/"$PORT") >/dev/null 2>&1
result=$?
fi
if [[ $result -eq 0 ]]; then
Expand All @@ -54,9 +54,9 @@ wait_for_wrapper()
{
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
if [[ $QUIET -eq 1 ]]; then
timeout $BUSYTIMEFLAG $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
timeout "$BUSYTIMEFLAG" "$TIMEOUT" "$0" --quiet --child --host="$HOST" --port="$PORT" --timeout="$TIMEOUT" &
else
timeout $BUSYTIMEFLAG $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
timeout "$BUSYTIMEFLAG" "$TIMEOUT" "$0" --child --host="$HOST" --port="$PORT" --timeout="$TIMEOUT" &
fi
PID=$!
trap "kill -INT -$PID" INT
Expand Down Expand Up @@ -172,7 +172,7 @@ if [[ $CLI != "" ]]; then
echoerr "$cmdname: strict mode, refusing to execute subprocess"
exit $RESULT
fi
exec $CLI
exec "$CLI"
else
exit $RESULT
exit "$RESULT"
fi
14 changes: 7 additions & 7 deletions kafka/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ export STATE_CHANGE_LOG_LEVEL=${STATE_CHANGE_LOG_LEVEL:-"INFO"}
export AUTHORIZER_LOG_LEVEL=${AUTHORIZER_LOG_LEVEL:-"WARN"}
GC_LOG_ENABLED=${GC_LOG_ENABLED:-"False"}

first_zk=$(echo $ZOOKEEPER_CONNECTION_STRING | cut -d, -f1)
zk_host=$(echo $first_zk | cut -d\: -f1)
zk_port=$(echo $first_zk | cut -d\: -f2)
first_zk=$(echo "$ZOOKEEPER_CONNECTION_STRING" | cut -d, -f1)
zk_host=$(echo "$first_zk" | cut -d\: -f1)
zk_port=$(echo "$first_zk" | cut -d\: -f2)

# wait for zookeeper to become available
if [ "$ZOOKEEPER_WAIT" = "true" ]; then
success="false"
for i in $(seq $ZOOKEEPER_WAIT_RETRIES); do
ok=$(echo ruok | nc $zk_host $zk_port -w $ZOOKEEPER_WAIT_TIMEOUT)
for i in $(seq "$ZOOKEEPER_WAIT_RETRIES"); do
ok=$(echo ruok | nc "$zk_host" "$zk_port" -w "$ZOOKEEPER_WAIT_TIMEOUT")
if [ $? -eq 0 -a "$ok" = "imok" ]; then
success="true"
break
else
echo "Connect attempt $i of $ZOOKEEPER_WAIT_RETRIES failed, retrying..."
sleep $ZOOKEEPER_WAIT_DELAY
sleep "$ZOOKEEPER_WAIT_DELAY"
fi
done

Expand Down Expand Up @@ -69,7 +69,7 @@ for f in $CONFIG_TEMPLATES/*.properties.j2; do
done

if [ -z "$KAFKA_HEAP_OPTS" ]; then
max_heap=$(python /heap.py $KAFKA_MAX_HEAP_MB)
max_heap=$(python /heap.py "$KAFKA_MAX_HEAP_MB")
KAFKA_HEAP_OPTS="-Xmx${max_heap} -Xms${max_heap}"
export KAFKA_HEAP_OPTS
fi
Expand Down
18 changes: 9 additions & 9 deletions keystone/keystone-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ fi
if [[ -e /db-init ]]; then
echo "Creating bootstrap credentials..."
keystone-manage bootstrap \
--bootstrap-password $admin_password \
--bootstrap-username $admin_username \
--bootstrap-project-name $admin_project \
--bootstrap-role-name $admin_role \
--bootstrap-service-name $admin_service \
--bootstrap-region-id $admin_region \
--bootstrap-admin-url $admin_url \
--bootstrap-public-url $public_url \
--bootstrap-internal-url $internal_url
--bootstrap-password "$admin_password" \
--bootstrap-username "$admin_username" \
--bootstrap-project-name "$admin_project" \
--bootstrap-role-name "$admin_role" \
--bootstrap-service-name "$admin_service" \
--bootstrap-region-id "$admin_region" \
--bootstrap-admin-url "$admin_url" \
--bootstrap-public-url "$public_url" \
--bootstrap-internal-url "$internal_url"

sleep 5

Expand Down
4 changes: 2 additions & 2 deletions keystone/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [[ "$KEYSTONE_DATABASE_BACKEND" = "mysql" ]]; then

echo "Waiting for mysql to become available..."
success="false"
for i in $(seq $retries); do
for i in $(seq "$retries"); do
mysqladmin status \
--host="$mysql_host" \
--user="$mysql_user" \
Expand Down Expand Up @@ -40,7 +40,7 @@ if [[ "$KEYSTONE_DATABASE_BACKEND" = "mysql" ]]; then
/etc/keystone/keystone.conf

# check to see if table exists already and skip init if so
mysql -h ${mysql_host} -u ${mysql_user} -p${mysql_pass} -e "desc ${mysql_db}.migrate_version" &> /dev/null
mysql -h "${mysql_host}" -u "${mysql_user}" -p"${mysql_pass}" -e "desc ${mysql_db}.migrate_version" &> /dev/null
if [[ $? -eq 0 ]]; then
echo "MySQL database has already been initialized, skipping..."
else
Expand Down
4 changes: 2 additions & 2 deletions kibana/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

python /template.py /kibana.yml.j2 /opt/kibana/config/kibana.yml

if [ $MONASCA_PLUGIN_ENABLED == True ]; then
/wait-for.sh $KEYSTONE_URI -- kibana
if [ "$MONASCA_PLUGIN_ENABLED" == True ]; then
/wait-for.sh "$KEYSTONE_URI" -- kibana
else
kibana
fi
16 changes: 8 additions & 8 deletions kibana/wait-for.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Use this script to test if a given TCP host/port are available

cmdname=$(basename $0)
cmdname=$(basename "$0")

echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }

Expand Down Expand Up @@ -33,10 +33,10 @@ wait_for()
while :
do
if [[ $ISBUSY -eq 1 ]]; then
nc -z $HOST $PORT
nc -z "$HOST" "$PORT"
result=$?
else
(echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1
(echo > /dev/tcp/"$HOST"/"$PORT") >/dev/null 2>&1
result=$?
fi
if [[ $result -eq 0 ]]; then
Expand All @@ -53,9 +53,9 @@ wait_for_wrapper()
{
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
if [[ $QUIET -eq 1 ]]; then
timeout $BUSYTIMEFLAG $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
timeout "$BUSYTIMEFLAG" "$TIMEOUT" "$0" --quiet --child --host="$HOST" --port="$PORT" --timeout="$TIMEOUT" &
else
timeout $BUSYTIMEFLAG $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
timeout "$BUSYTIMEFLAG" "$TIMEOUT" "$0" --child --host="$HOST" --port="$PORT" --timeout="$TIMEOUT" &
fi
PID=$!
trap "kill -INT -$PID" INT
Expand Down Expand Up @@ -142,7 +142,7 @@ CHILD=${CHILD:-0}
QUIET=${QUIET:-0}

# check to see if timeout is from busybox?
TIMEOUT_PATH=$(realpath $(which timeout))
TIMEOUT_PATH=$(realpath "$(which timeout)")
if [[ $TIMEOUT_PATH =~ "busybox" ]]; then
ISBUSY=1
BUSYTIMEFLAG="-t"
Expand Down Expand Up @@ -170,7 +170,7 @@ if [[ $CLI != "" ]]; then
echoerr "$cmdname: strict mode, refusing to execute subprocess"
exit $RESULT
fi
exec $CLI
exec "$CLI"
else
exit $RESULT
exit "$RESULT"
fi
4 changes: 2 additions & 2 deletions monasca-alarms/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [ -n "$MONASCA_WAIT_FOR_API" ]; then
echo "Waiting for Monasca API to become available..."
success="false"

for i in $(seq $MONASCA_API_WAIT_RETRIES); do
for i in $(seq "$MONASCA_API_WAIT_RETRIES"); do
monasca alarm-definition-list --limit 1
if [ $? -eq 0 ]; then
success="true"
Expand All @@ -29,4 +29,4 @@ fi
echo "Loading Definitions...."

python /template.py /config/definitions.yml.j2 /config/definitions.yml
python monasca_alarm_definition.py --verbose --definitions-file /config/definitions.yml
python monasca_alarm_definition.py --verbose --definitions-file /config/definitions.yml
2 changes: 1 addition & 1 deletion monasca-api-python/health-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ KEYSTONE_TOKEN=$(curl --include --silent --show-error --output - --header "Conte
}'
) && \
curl --include --silent --show-error --output - --header "X-Auth-Token:${KEYSTONE_TOKEN}" \
http://localhost:${MONASCA_CONTAINER_API_PORT} 2>&1 | \
http://localhost:"${MONASCA_CONTAINER_API_PORT}" 2>&1 | \
awk '
BEGIN {status_code="0"; body=""; output=""}
$1 ~ /^HTTP\// {status_line=$0; status_code=$2}
Expand Down
6 changes: 3 additions & 3 deletions monasca-api-python/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ KAFKA_WAIT_DELAY=${KAFKA_WAIT_DELAY:-"5"}
if [ "$MYSQL_WAIT_RETRIES" != "0" ]; then
echo "Waiting for MySQL to become available..."
success="false"
for i in $(seq $MYSQL_WAIT_RETRIES); do
for i in $(seq "$MYSQL_WAIT_RETRIES"); do
mysqladmin status \
--host="$MYSQL_HOST" \
--user="$MYSQL_USER" \
Expand All @@ -41,7 +41,7 @@ if [ -n "$KAFKA_WAIT_FOR_TOPICS" ]; then
echo "Waiting for Kafka topics to become available..."
success="false"

for i in $(seq $KAFKA_WAIT_RETRIES); do
for i in $(seq "$KAFKA_WAIT_RETRIES"); do
python /kafka_wait_for_topics.py
if [ $? -eq 0 ]; then
success="true"
Expand Down Expand Up @@ -89,7 +89,7 @@ gunicorn --capture-output \
-n monasca-api \
--worker-class="$GUNICORN_WORKER_CLASS" \
--worker-connections="$GUNICORN_WORKER_CONNECTIONS" \
--backlog=$GUNICORN_BACKLOG \
--backlog="$GUNICORN_BACKLOG" \
$access_arg \
--access-logformat "$ACCESS_LOG_FIELDS" \
--paste /etc/monasca/api-config.ini \
Expand Down
2 changes: 1 addition & 1 deletion monasca-forwarder/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [ -n "$KAFKA_WAIT_FOR_TOPICS" ]; then
echo "Waiting for Kafka topics to become available..."
success="false"

for i in $(seq $KAFKA_WAIT_RETRIES); do
for i in $(seq "$KAFKA_WAIT_RETRIES"); do
python /kafka_wait_for_topics.py
if [ $? -eq 0 ]; then
success="true"
Expand Down
2 changes: 1 addition & 1 deletion monasca-log-api/health-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
MONASCA_CONTAINER_LOG_API_PORT=${1:-5607}

curl --include --silent --show-error --output - \
http://localhost:${MONASCA_CONTAINER_LOG_API_PORT}/healthcheck 2>&1 | \
http://localhost:"${MONASCA_CONTAINER_LOG_API_PORT}"/healthcheck 2>&1 | \
awk '
BEGIN {status_code="0"; body=""; output=""}
$1 ~ /^HTTP\// {status_line=$0; status_code=$2}
Expand Down
2 changes: 1 addition & 1 deletion monasca-log-api/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ -n "$KAFKA_WAIT_FOR_TOPICS" ]; then
echo "Waiting for Kafka topics to become available..."
success="false"

for i in $(seq $KAFKA_WAIT_RETRIES); do
for i in $(seq "$KAFKA_WAIT_RETRIES"); do
python /kafka_wait_for_topics.py
if [ $? -eq 0 ]; then
success="true"
Expand Down
2 changes: 1 addition & 1 deletion monasca-log-metrics/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ -n "$KAFKA_WAIT_FOR_TOPICS" ]; then
echo "Waiting for Kafka topics to become available..."
success="false"

for i in $(seq $KAFKA_WAIT_RETRIES); do
for i in $(seq "$KAFKA_WAIT_RETRIES"); do
python /kafka_wait_for_topics.py
if [ $? -eq 0 ]; then
success="true"
Expand Down
2 changes: 1 addition & 1 deletion monasca-log-persister/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ -n "$KAFKA_WAIT_FOR_TOPICS" ]; then
echo "Waiting for Kafka topics to become available..."
success="false"

for i in $(seq $KAFKA_WAIT_RETRIES); do
for i in $(seq "$KAFKA_WAIT_RETRIES"); do
python /kafka_wait_for_topics.py
if [ $? -eq 0 ]; then
success="true"
Expand Down
2 changes: 1 addition & 1 deletion monasca-log-transformer/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ -n "$KAFKA_WAIT_FOR_TOPICS" ]; then
echo "Waiting for Kafka topics to become available..."
success="false"

for i in $(seq $KAFKA_WAIT_RETRIES); do
for i in $(seq "$KAFKA_WAIT_RETRIES"); do
python /kafka_wait_for_topics.py
if [ $? -eq 0 ]; then
success="true"
Expand Down
4 changes: 2 additions & 2 deletions monasca-notification/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ KAFKA_WAIT_DELAY=${KAFKA_WAIT_DELAY:-"5"}

echo "Waiting for MySQL to become available..."
success="false"
for i in $(seq $MYSQL_WAIT_RETRIES); do
for i in $(seq "$MYSQL_WAIT_RETRIES"); do
mysqladmin status \
--host="$MYSQL_DB_HOST" \
--port="$MYSQL_DB_PORT" \
Expand All @@ -36,7 +36,7 @@ if [ -n "$KAFKA_WAIT_FOR_TOPICS" ]; then
echo "Waiting for Kafka topics to become available..."
success="false"

for i in $(seq $KAFKA_WAIT_RETRIES); do
for i in $(seq "$KAFKA_WAIT_RETRIES"); do
python /kafka_wait_for_topics.py
if [ $? -eq 0 ]; then
success="true"
Expand Down
2 changes: 1 addition & 1 deletion monasca-persister-python/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [ -n "$KAFKA_WAIT_FOR_TOPICS" ]; then
echo "Waiting for Kafka topics to become available..."
success="false"

for i in $(seq $KAFKA_WAIT_RETRIES); do
for i in $(seq "$KAFKA_WAIT_RETRIES"); do
python /kafka_wait_for_topics.py
if [ $? -eq 0 ]; then
success="true"
Expand Down
Loading