"Fossies" - the Fresh Open Source Software Archive

Member "pandora_server/docker_entrypoint.sh" (5 Nov 2021, 2038 Bytes) of package /linux/misc/pandorafms_server-7.0NG.758.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 set -e
    3 if [ -n "$MYSQL_PORT_3306_TCP" ]; then
    4         if [ -z "$PANDORA_DB_HOST" ]; then
    5             PANDORA_DB_HOST='mysql'
    6         else
    7             echo >&2 'warning: both PANDORA_DB_HOST and MYSQL_PORT_3306_TCP found'
    8             echo >&2 "  Connecting to PANDORA_DB_HOST ($PANDORA_DB_HOST)"
    9             echo >&2 '  instead of the linked mysql container'
   10         fi
   11 fi
   12 
   13 if [ -z "$PANDORA_DB_HOST" ]; then
   14     echo >&2 'error: missing PANDORA_DB_HOST and MYSQL_PORT_3306_TCP environment variables'
   15     echo >&2 '  Did you forget to --link some_mysql_container:mysql or set an external db'
   16     echo >&2 '  with -e PANDORA_DB_HOST=hostname:port?'
   17     exit 1
   18 fi
   19 
   20 # if we're linked to MySQL and thus have credentials already, let's use them
   21 : ${PANDORA_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}
   22 if [ "$PANDORA_DB_USER" = 'root' ]; then
   23     : ${PANDORA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
   24 fi
   25 : ${PANDORA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_PASSWORD}
   26 if [ -z "$PANDORA_DB_NAME" ]; then
   27     : ${PANDORA_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-pandora}}
   28 fi
   29 
   30 if [ -z "$PANDORA_DB_PASSWORD" ]; then
   31     echo >&2 'error: missing required PANDORA_DB_PASSWORD environment variable'
   32     echo >&2 '  Did you forget to -e PANDORA_DB_PASSWORD=... ?'
   33     echo >&2
   34     echo >&2 '  (Also of interest might be PANDORA_DB_USER and PANDORA_DB_NAME.)'
   35     exit 1
   36 fi
   37 
   38 #Create the pandora user, mainly
   39 /usr/sbin/useradd -d /home/pandora -s /bin/false -M -g 0 pandora
   40 
   41 cd /tmp/pandorafms/pandora_server && ./pandora_server_installer --install
   42 
   43 #Configure the Pandora FMS Server to connect to the database
   44 sed -i "s/dbname pandora/dbname $PANDORA_DB_NAME/g" /etc/pandora/pandora_server.conf
   45 sed -i "s/dbpass pandora/dbpass $PANDORA_DB_PASSWORD/g" /etc/pandora/pandora_server.conf
   46 sed -i "s/dbuser pandora/dbuser $PANDORA_DB_USER/g" /etc/pandora/pandora_server.conf
   47 sed -i "s/dbhost 127.0.0.1/dbhost $PANDORA_DB_HOST/g" /etc/pandora/pandora_server.conf
   48 
   49 #Rock n' roll!
   50 /etc/init.d/crond start &
   51 /etc/init.d/ntpd start &
   52 /etc/init.d/postfix start &
   53 /etc/init.d/tentacle_serverd start &
   54 /usr/bin/pandora_server /etc/pandora/pandora_server.conf