0

I have an apache app container. My docker entrypoint is something like this:

#!/bin/bash
set -euo pipefail
declare MOODLE_DATA=/var/www/moodledata

# install only if executed without CMD parameter

if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then

    if [ ! -e config.php ]; then
      # COPY LOCAL CODE FROM /usr/local/code
    else
        echo >&2 "MOODLE CODE FOUND: SKIP CREATION"
    fi

    # database

    echo "Checking database status..."
    #wait till is ready for connections
    dockerize -wait tcp://db:3306 -timeout 20s
    # prevent container exit by php return value
    set +e
    php /var/www/html/admin/cli/check_database_schema.php
    dbStatus=$?
    if [ $dbStatus  -eq 2 ]; then
        echo >&2 "CREATING DATABASE...."
        # som code 
        echo >&2 "DATABASE CREATED"
    elif [ $dbStatus -eq 0 ]; then
        echo >&2 "DATABASE FOUND: SKIP CREATION"
    else
        echo >&2 "Could not install Database due to errors!"
    fi

    echo >&2 "Starting web server..."
fi

exec "$@"

It takes quite long to execute, about 5 minutes so i would like to show some info to our users about the installation process.

Is there a way to echo not only to console, but also to an html file? Any script, command to make it simple?

My idea would be to have an html template like the one below, insert text to body and auto refresh every 5':

<html>
    <head>
        <title>Show installation</title>
        <meta http-equiv="refresh" content="5" >
    </head>
    <body>

    </body>
</html>

However I run the web server just at the end exec "$@". How could I fix it? If I run it before the rest of the script it does not go on with the script

user2670996
  • 2,654
  • 6
  • 29
  • 45
  • Does this answer your question? [How to redirect output to a file and stdout](https://stackoverflow.com/questions/418896/how-to-redirect-output-to-a-file-and-stdout) – KamilCuk May 09 '20 at 18:18
  • `{ command; command; command; } | tee htmlfile` – KamilCuk May 09 '20 at 18:19
  • tee would be an option, but I would need to make all the html composition. Also I don't have my web server till the end. I'm looking for something more standard & "complex" for this. If exists... – user2670996 May 09 '20 at 18:36

0 Answers0