diff --git a/influxdb/1.5/alpine/init-influxdb.sh b/influxdb/1.5/alpine/init-influxdb.sh index c2097ecd8..79d3ada7c 100755 --- a/influxdb/1.5/alpine/init-influxdb.sh +++ b/influxdb/1.5/alpine/init-influxdb.sh @@ -4,9 +4,9 @@ set -e AUTH_ENABLED="$INFLUXDB_HTTP_AUTH_ENABLED" if [ -z "$AUTH_ENABLED" ]; then - AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*true' /etc/influxdb/influxdb.conf | grep -io 'true' | cat)" + AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*(true|1)' /etc/influxdb/influxdb.conf | grep -ioE '(true|1)' | cat)" else - AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -io 'true' | cat)" + AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -ioE '(true|1)' | cat)" fi INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo 1 || echo) @@ -14,7 +14,7 @@ INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo if ( [ ! -z "$INIT_USERS" ] || [ ! -z "$INFLUXDB_DB" ] || [ "$(ls -A /docker-entrypoint-initdb.d 2> /dev/null)" ] ) && [ ! "$(ls -d /var/lib/influxdb/meta 2>/dev/null)" ]; then INIT_QUERY="" - CREATE_DB_QUERY="CREATE DATABASE $INFLUXDB_DB" + CREATE_DB_QUERY="CREATE DATABASE \"$INFLUXDB_DB\"" if [ ! -z "$INIT_USERS" ]; then diff --git a/influxdb/1.5/data/alpine/init-influxdb.sh b/influxdb/1.5/data/alpine/init-influxdb.sh index c2097ecd8..79d3ada7c 100755 --- a/influxdb/1.5/data/alpine/init-influxdb.sh +++ b/influxdb/1.5/data/alpine/init-influxdb.sh @@ -4,9 +4,9 @@ set -e AUTH_ENABLED="$INFLUXDB_HTTP_AUTH_ENABLED" if [ -z "$AUTH_ENABLED" ]; then - AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*true' /etc/influxdb/influxdb.conf | grep -io 'true' | cat)" + AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*(true|1)' /etc/influxdb/influxdb.conf | grep -ioE '(true|1)' | cat)" else - AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -io 'true' | cat)" + AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -ioE '(true|1)' | cat)" fi INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo 1 || echo) @@ -14,7 +14,7 @@ INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo if ( [ ! -z "$INIT_USERS" ] || [ ! -z "$INFLUXDB_DB" ] || [ "$(ls -A /docker-entrypoint-initdb.d 2> /dev/null)" ] ) && [ ! "$(ls -d /var/lib/influxdb/meta 2>/dev/null)" ]; then INIT_QUERY="" - CREATE_DB_QUERY="CREATE DATABASE $INFLUXDB_DB" + CREATE_DB_QUERY="CREATE DATABASE \"$INFLUXDB_DB\"" if [ ! -z "$INIT_USERS" ]; then diff --git a/influxdb/1.5/data/init-influxdb.sh b/influxdb/1.5/data/init-influxdb.sh index c2097ecd8..79d3ada7c 100755 --- a/influxdb/1.5/data/init-influxdb.sh +++ b/influxdb/1.5/data/init-influxdb.sh @@ -4,9 +4,9 @@ set -e AUTH_ENABLED="$INFLUXDB_HTTP_AUTH_ENABLED" if [ -z "$AUTH_ENABLED" ]; then - AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*true' /etc/influxdb/influxdb.conf | grep -io 'true' | cat)" + AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*(true|1)' /etc/influxdb/influxdb.conf | grep -ioE '(true|1)' | cat)" else - AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -io 'true' | cat)" + AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -ioE '(true|1)' | cat)" fi INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo 1 || echo) @@ -14,7 +14,7 @@ INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo if ( [ ! -z "$INIT_USERS" ] || [ ! -z "$INFLUXDB_DB" ] || [ "$(ls -A /docker-entrypoint-initdb.d 2> /dev/null)" ] ) && [ ! "$(ls -d /var/lib/influxdb/meta 2>/dev/null)" ]; then INIT_QUERY="" - CREATE_DB_QUERY="CREATE DATABASE $INFLUXDB_DB" + CREATE_DB_QUERY="CREATE DATABASE \"$INFLUXDB_DB\"" if [ ! -z "$INIT_USERS" ]; then diff --git a/influxdb/1.5/init-influxdb.sh b/influxdb/1.5/init-influxdb.sh index c2097ecd8..79d3ada7c 100755 --- a/influxdb/1.5/init-influxdb.sh +++ b/influxdb/1.5/init-influxdb.sh @@ -4,9 +4,9 @@ set -e AUTH_ENABLED="$INFLUXDB_HTTP_AUTH_ENABLED" if [ -z "$AUTH_ENABLED" ]; then - AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*true' /etc/influxdb/influxdb.conf | grep -io 'true' | cat)" + AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*(true|1)' /etc/influxdb/influxdb.conf | grep -ioE '(true|1)' | cat)" else - AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -io 'true' | cat)" + AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -ioE '(true|1)' | cat)" fi INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo 1 || echo) @@ -14,7 +14,7 @@ INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo if ( [ ! -z "$INIT_USERS" ] || [ ! -z "$INFLUXDB_DB" ] || [ "$(ls -A /docker-entrypoint-initdb.d 2> /dev/null)" ] ) && [ ! "$(ls -d /var/lib/influxdb/meta 2>/dev/null)" ]; then INIT_QUERY="" - CREATE_DB_QUERY="CREATE DATABASE $INFLUXDB_DB" + CREATE_DB_QUERY="CREATE DATABASE \"$INFLUXDB_DB\"" if [ ! -z "$INIT_USERS" ]; then diff --git a/influxdb/1.6/alpine/init-influxdb.sh b/influxdb/1.6/alpine/init-influxdb.sh index c2097ecd8..79d3ada7c 100755 --- a/influxdb/1.6/alpine/init-influxdb.sh +++ b/influxdb/1.6/alpine/init-influxdb.sh @@ -4,9 +4,9 @@ set -e AUTH_ENABLED="$INFLUXDB_HTTP_AUTH_ENABLED" if [ -z "$AUTH_ENABLED" ]; then - AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*true' /etc/influxdb/influxdb.conf | grep -io 'true' | cat)" + AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*(true|1)' /etc/influxdb/influxdb.conf | grep -ioE '(true|1)' | cat)" else - AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -io 'true' | cat)" + AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -ioE '(true|1)' | cat)" fi INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo 1 || echo) @@ -14,7 +14,7 @@ INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo if ( [ ! -z "$INIT_USERS" ] || [ ! -z "$INFLUXDB_DB" ] || [ "$(ls -A /docker-entrypoint-initdb.d 2> /dev/null)" ] ) && [ ! "$(ls -d /var/lib/influxdb/meta 2>/dev/null)" ]; then INIT_QUERY="" - CREATE_DB_QUERY="CREATE DATABASE $INFLUXDB_DB" + CREATE_DB_QUERY="CREATE DATABASE \"$INFLUXDB_DB\"" if [ ! -z "$INIT_USERS" ]; then diff --git a/influxdb/1.6/data/alpine/init-influxdb.sh b/influxdb/1.6/data/alpine/init-influxdb.sh index c2097ecd8..79d3ada7c 100755 --- a/influxdb/1.6/data/alpine/init-influxdb.sh +++ b/influxdb/1.6/data/alpine/init-influxdb.sh @@ -4,9 +4,9 @@ set -e AUTH_ENABLED="$INFLUXDB_HTTP_AUTH_ENABLED" if [ -z "$AUTH_ENABLED" ]; then - AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*true' /etc/influxdb/influxdb.conf | grep -io 'true' | cat)" + AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*(true|1)' /etc/influxdb/influxdb.conf | grep -ioE '(true|1)' | cat)" else - AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -io 'true' | cat)" + AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -ioE '(true|1)' | cat)" fi INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo 1 || echo) @@ -14,7 +14,7 @@ INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo if ( [ ! -z "$INIT_USERS" ] || [ ! -z "$INFLUXDB_DB" ] || [ "$(ls -A /docker-entrypoint-initdb.d 2> /dev/null)" ] ) && [ ! "$(ls -d /var/lib/influxdb/meta 2>/dev/null)" ]; then INIT_QUERY="" - CREATE_DB_QUERY="CREATE DATABASE $INFLUXDB_DB" + CREATE_DB_QUERY="CREATE DATABASE \"$INFLUXDB_DB\"" if [ ! -z "$INIT_USERS" ]; then diff --git a/influxdb/1.6/data/init-influxdb.sh b/influxdb/1.6/data/init-influxdb.sh index c2097ecd8..79d3ada7c 100755 --- a/influxdb/1.6/data/init-influxdb.sh +++ b/influxdb/1.6/data/init-influxdb.sh @@ -4,9 +4,9 @@ set -e AUTH_ENABLED="$INFLUXDB_HTTP_AUTH_ENABLED" if [ -z "$AUTH_ENABLED" ]; then - AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*true' /etc/influxdb/influxdb.conf | grep -io 'true' | cat)" + AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*(true|1)' /etc/influxdb/influxdb.conf | grep -ioE '(true|1)' | cat)" else - AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -io 'true' | cat)" + AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -ioE '(true|1)' | cat)" fi INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo 1 || echo) @@ -14,7 +14,7 @@ INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo if ( [ ! -z "$INIT_USERS" ] || [ ! -z "$INFLUXDB_DB" ] || [ "$(ls -A /docker-entrypoint-initdb.d 2> /dev/null)" ] ) && [ ! "$(ls -d /var/lib/influxdb/meta 2>/dev/null)" ]; then INIT_QUERY="" - CREATE_DB_QUERY="CREATE DATABASE $INFLUXDB_DB" + CREATE_DB_QUERY="CREATE DATABASE \"$INFLUXDB_DB\"" if [ ! -z "$INIT_USERS" ]; then diff --git a/influxdb/1.6/init-influxdb.sh b/influxdb/1.6/init-influxdb.sh index c2097ecd8..79d3ada7c 100755 --- a/influxdb/1.6/init-influxdb.sh +++ b/influxdb/1.6/init-influxdb.sh @@ -4,9 +4,9 @@ set -e AUTH_ENABLED="$INFLUXDB_HTTP_AUTH_ENABLED" if [ -z "$AUTH_ENABLED" ]; then - AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*true' /etc/influxdb/influxdb.conf | grep -io 'true' | cat)" + AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*(true|1)' /etc/influxdb/influxdb.conf | grep -ioE '(true|1)' | cat)" else - AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -io 'true' | cat)" + AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -ioE '(true|1)' | cat)" fi INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo 1 || echo) @@ -14,7 +14,7 @@ INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo if ( [ ! -z "$INIT_USERS" ] || [ ! -z "$INFLUXDB_DB" ] || [ "$(ls -A /docker-entrypoint-initdb.d 2> /dev/null)" ] ) && [ ! "$(ls -d /var/lib/influxdb/meta 2>/dev/null)" ]; then INIT_QUERY="" - CREATE_DB_QUERY="CREATE DATABASE $INFLUXDB_DB" + CREATE_DB_QUERY="CREATE DATABASE \"$INFLUXDB_DB\"" if [ ! -z "$INIT_USERS" ]; then diff --git a/influxdb/circle-test.sh b/influxdb/circle-test.sh index d64dc3859..f8d4d2ad5 100755 --- a/influxdb/circle-test.sh +++ b/influxdb/circle-test.sh @@ -65,8 +65,8 @@ test_default_without_auth_enabled() { cleanup } -test_default_with_auth_enabled() { - log_msg 'Executing test_default_with_auth_enabled' +test_default_with_auth_enabled_by_true() { + log_msg 'Executing test_default_with_auth_enabled_by_true' setup '--env INFLUXDB_HTTP_AUTH_ENABLED=true' assert_contains "$(influx 'SHOW DATABASES' 2> /dev/null)" 'create admin user first or disable authentication' 'test_default_with_auth_enabled: influxdb should not be initialized' @@ -74,11 +74,20 @@ test_default_with_auth_enabled() { cleanup } -test_create_db() { - log_msg 'Executing test_create_db' - setup '--env INFLUXDB_DB=test_db' +test_default_with_auth_enabled_by_1() { + log_msg 'Executing test_default_with_auth_enabled_by_1' + setup '--env INFLUXDB_HTTP_AUTH_ENABLED=1' - assert_contains "$(influx 'SHOW DATABASES')" 'test_db' 'test_create_db: influxdb should contain a test_db database' + assert_contains "$(influx 'SHOW DATABASES' 2> /dev/null)" 'create admin user first or disable authentication' 'test_default_with_auth_enabled: influxdb should not be initialized' + + cleanup +} + +test_create_db_with_keyword_name() { + log_msg 'Executing test_create_db_with_keyword_name' + setup '--env INFLUXDB_DB=database' + + assert_contains "$(influx 'SHOW DATABASES')" 'database' 'test_create_db_with_keyword_name: influxdb should contain a database with name "database"' cleanup } @@ -186,7 +195,7 @@ test_create_db_on_non_default_port() { cleanup } -influxdb_dockerfiles=$(find 'influxdb' -name nightly -prune -o -name Dockerfile -print0 | xargs -0 -I{} dirname {} | sed 's@^./@@' | sed 's@//*@/@g') +influxdb_dockerfiles=$(find 'influxdb' -name nightly -prune -o -name data -prune -o -name meta -prune -o -name Dockerfile -print0 | xargs -0 -I{} dirname {} | sed 's@^./@@' | sed 's@//*@/@g') for path in $influxdb_dockerfiles; do # Generate a tag by replacing the first slash with a colon and all remaining slashes with a dash. @@ -196,9 +205,11 @@ for path in $influxdb_dockerfiles; do test_default_without_auth_enabled - test_default_with_auth_enabled + test_default_with_auth_enabled_by_true + + test_default_with_auth_enabled_by_1 - test_create_db + test_create_db_with_keyword_name test_create_admin diff --git a/influxdb/nightly/alpine/init-influxdb.sh b/influxdb/nightly/alpine/init-influxdb.sh index c2097ecd8..79d3ada7c 100755 --- a/influxdb/nightly/alpine/init-influxdb.sh +++ b/influxdb/nightly/alpine/init-influxdb.sh @@ -4,9 +4,9 @@ set -e AUTH_ENABLED="$INFLUXDB_HTTP_AUTH_ENABLED" if [ -z "$AUTH_ENABLED" ]; then - AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*true' /etc/influxdb/influxdb.conf | grep -io 'true' | cat)" + AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*(true|1)' /etc/influxdb/influxdb.conf | grep -ioE '(true|1)' | cat)" else - AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -io 'true' | cat)" + AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -ioE '(true|1)' | cat)" fi INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo 1 || echo) @@ -14,7 +14,7 @@ INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo if ( [ ! -z "$INIT_USERS" ] || [ ! -z "$INFLUXDB_DB" ] || [ "$(ls -A /docker-entrypoint-initdb.d 2> /dev/null)" ] ) && [ ! "$(ls -d /var/lib/influxdb/meta 2>/dev/null)" ]; then INIT_QUERY="" - CREATE_DB_QUERY="CREATE DATABASE $INFLUXDB_DB" + CREATE_DB_QUERY="CREATE DATABASE \"$INFLUXDB_DB\"" if [ ! -z "$INIT_USERS" ]; then diff --git a/influxdb/nightly/init-influxdb.sh b/influxdb/nightly/init-influxdb.sh index c2097ecd8..79d3ada7c 100755 --- a/influxdb/nightly/init-influxdb.sh +++ b/influxdb/nightly/init-influxdb.sh @@ -4,9 +4,9 @@ set -e AUTH_ENABLED="$INFLUXDB_HTTP_AUTH_ENABLED" if [ -z "$AUTH_ENABLED" ]; then - AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*true' /etc/influxdb/influxdb.conf | grep -io 'true' | cat)" + AUTH_ENABLED="$(grep -iE '^\s*auth-enabled\s*=\s*(true|1)' /etc/influxdb/influxdb.conf | grep -ioE '(true|1)' | cat)" else - AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -io 'true' | cat)" + AUTH_ENABLED="$(echo "$INFLUXDB_HTTP_AUTH_ENABLED" | grep -ioE '(true|1)' | cat)" fi INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo 1 || echo) @@ -14,7 +14,7 @@ INIT_USERS=$([ ! -z "$AUTH_ENABLED" ] && [ ! -z "$INFLUXDB_ADMIN_USER" ] && echo if ( [ ! -z "$INIT_USERS" ] || [ ! -z "$INFLUXDB_DB" ] || [ "$(ls -A /docker-entrypoint-initdb.d 2> /dev/null)" ] ) && [ ! "$(ls -d /var/lib/influxdb/meta 2>/dev/null)" ]; then INIT_QUERY="" - CREATE_DB_QUERY="CREATE DATABASE $INFLUXDB_DB" + CREATE_DB_QUERY="CREATE DATABASE \"$INFLUXDB_DB\"" if [ ! -z "$INIT_USERS" ]; then