Skip to content

[Bug][docker] Variable reference error in startup.sh #3894

@hydra-bu

Description

@hydra-bu

*For better global communication, please give priority to using English description, thx! *

Please review https://dolphinscheduler.apache.org/en-us/docs/development/issue.html when describe an issue.

Describe the bug
in file docker/build/startup.sh , variables cannot reference in single quotes.

# start database
initDatabase() {
    echo "test ${DATABASE_TYPE} service"
    while ! nc -z ${DATABASE_HOST} ${DATABASE_PORT}; do
        counter=$((counter+1))
        if [ $counter == 30 ]; then
            echo "Error: Couldn't connect to ${DATABASE_TYPE}."
            exit 1
        fi
        echo "Trying to connect to ${DATABASE_TYPE} at ${DATABASE_HOST}:${DATABASE_PORT}. Attempt $counter."
        sleep 5
    done

    echo "connect ${DATABASE_TYPE} service"
    if [ ${DATABASE_TYPE} = "mysql" ]; then
        v=$(mysql -h${DATABASE_HOST} -P${DATABASE_PORT} -u${DATABASE_USERNAME} --password=${DATABASE_PASSWORD} -D ${DATABASE_DATABASE} -e "select 1" 2>&1)
        if [ "$(echo '${v}' | grep 'ERROR' | wc -l)" -eq 1 ]; then
            echo "Error: Can't connect to database...${v}"
            exit 1
        fi
    else
        v=$(sudo -u postgres PGPASSWORD=${DATABASE_PASSWORD} psql -h ${DATABASE_HOST} -p ${DATABASE_PORT} -U ${DATABASE_USERNAME} -d ${DATABASE_DATABASE} -tAc "select 1")
        if [ "$(echo '${v}' | grep 'FATAL' | wc -l)" -eq 1 ]; then
            echo "Error: Can't connect to database...${v}"
            exit 1
        fi
    fi

    echo "import sql data"
    ${DOLPHINSCHEDULER_SCRIPT}/create-dolphinscheduler.sh
}

To Reproduce
v="ERROR"
echo '${v}' | grep 'ERROR' | wc -l

Expected behavior
v="ERROR"
echo ${v} | grep 'ERROR' | wc -l

Screenshots

Which version of Dolphin Scheduler:
-[1.3.2-release]
-[dev]

Additional context
Add any other context about the problem here.

Requirement or improvement

  • Please describe about your requirements or improvement suggestions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions