From eb1ac18c10b64423194ad8b51709d39ba5ada4e0 Mon Sep 17 00:00:00 2001 From: setiseta Date: Sun, 31 May 2015 15:39:41 +0200 Subject: [PATCH] Update readme, finish restructures. --- Dockerfile | 4 +--- README.md | 20 ++++++++++++++++++-- init.sh | 1 - initdb.sh | 41 ----------------------------------------- 4 files changed, 19 insertions(+), 47 deletions(-) delete mode 100644 initdb.sh diff --git a/Dockerfile b/Dockerfile index b9928f2..f87444d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,6 @@ ENV HOME=/root \ COPY init.sh /etc/my_init.d/init.sh COPY apache2.sh /etc/service/apache2/run COPY cron-observium /etc/cron.d/observium -#COPY initdb.sh /etc/my_init.d/initdb.sh # Use baseimage-docker's init system CMD ["/sbin/my_init"] @@ -27,7 +26,7 @@ RUN \ locale-gen de_DE.UTF-8 && locale-gen en_US.UTF-8 && \ apt-get update -q && \ apt-get install -y --no-install-recommends \ - libapache2-mod-php5 php5-cli php5-json wget unzip software-properties-common pwgen \ + mysql-client libapache2-mod-php5 php5-cli php5-json wget unzip software-properties-common \ php5-mysql php5-gd php5-mcrypt python-mysqldb rrdtool subversion whois mtr-tiny at \ nmap ipmitool graphviz imagemagick php5-snmp php-pear snmp graphviz fping libvirt-bin && \ apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ @@ -57,5 +56,4 @@ COPY apache-observium /etc/apache2/sites-available/000-default.conf EXPOSE 80/tcp -#VOLUME ["/config","/opt/observium/logs","/opt/observium/rrd"] VOLUME ["/data"] diff --git a/README.md b/README.md index 8d929fc..d176fb9 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,25 @@ Environment Vars - **TZ**: Set timezone. Defaults to `UTC` --- -Convert from older version with integrated DB to new +Convert from older version with integrated DB to new container === - +- we use "ocontainer" as container name. replace it with your name. +``` +mkdir mysql +docker exec -it ocontainer mysqldump observium > mysql/observiumdb.sql +mkdir data +mv config data/ && mv rrd data/ && mv logs data/ +chown nobody:users data -R +``` +- now run your db container, we use the example from above, then run this command (observium-db is the container name) +``` +echo "#!/bin/bash" > mysql/import.sh +echo "mysql -u observium -pobserviumpwd observium < /var/lib/mysql/observiumdb.sql" >> mysql/import.sh +chmod 0755 mysql/import.sh +docker exec -it observium-db bash /var/lib/mysql/import.sh +rm -f mysql/import.sh mysql/observiumdb.sql +``` +- now run your observium container, like the example from above --- Credits diff --git a/init.sh b/init.sh index 1dbb99a..5a96ccf 100644 --- a/init.sh +++ b/init.sh @@ -49,7 +49,6 @@ DB_PORT=${DB_PORT:-} DB_NAME=${DB_NAME:-} DB_USER=${DB_USER:-} DB_PASS=${DB_PASS:-} -DB_POOL=${DB_POOL:-10} if [ -n "${MYSQL_PORT_3306_TCP_ADDR}" ]; then DB_TYPE=${DB_TYPE:-mysql} diff --git a/initdb.sh b/initdb.sh deleted file mode 100644 index 3b5c163..0000000 --- a/initdb.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -start_mysql(){ - /usr/bin/mysqld_safe --datadir=/config/databases > /dev/null 2>&1 & - RET=1 - while [[ RET -ne 0 ]]; do - mysql -uroot -e "status" > /dev/null 2>&1 - RET=$? - sleep 1 - done -} - -# If databases do not exist, create them -if [ -f /config/databases/observium/users.ibd ]; then - echo "Database exists." -else - echo "Initializing Data Directory." - /usr/bin/mysql_install_db --datadir=/config/databases >/dev/null 2>&1 - echo "Installation complete." - start_mysql - echo "Creating user and database." - mysql -uroot -e "CREATE DATABASE IF NOT EXISTS observium DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" - PW=$(cat /config/config.php | grep -m 1 "'db_pass'" | sed -r 's/.*(.{34})/\1/;s/.{2}$//') - mysql -uroot -e "CREATE USER 'observium'@'localhost' IDENTIFIED BY '$PW'" - echo "Database created. Granting access to 'observium' user for localhost." - mysql -uroot -e "GRANT ALL PRIVILEGES ON observium.* TO 'observium'@'localhost'" - mysql -uroot -e "FLUSH PRIVILEGES" - cd /opt/observium - php includes/update/update.php - php adduser.php observium observium 10 - echo "Shutting down." - mysqladmin -u root shutdown - sleep 1 - echo "chown time" - chown -R nobody:users /config/databases - chmod -R 755 /config/databases - sleep 3 - echo "Initialization complete." -fi - -echo "Starting MariaDB..." -/usr/bin/mysqld_safe --skip-syslog --datadir='/config/databases'