diff --git a/cms_custom-ports.yml.template b/cms_custom-ports.yml.template index 6728aab..a1e3273 100644 --- a/cms_custom-ports.yml.template +++ b/cms_custom-ports.yml.template @@ -20,7 +20,7 @@ services: mem_limit: 256m env_file: config.env cms-web: - image: xibosignage/xibo-cms:release-1.8.4 + image: xibosignage/xibo-cms:release-1.8.5 volumes: - "./shared/cms/custom:/var/www/cms/custom" - "./shared/backup:/var/www/backup" diff --git a/cms_remote-mysql.yml b/cms_remote-mysql.yml index f7163f2..81e5b76 100644 --- a/cms_remote-mysql.yml +++ b/cms_remote-mysql.yml @@ -9,7 +9,7 @@ services: env_file: config.env mem_limit: 256m cms-web: - image: xibosignage/xibo-cms:release-1.8.4 + image: xibosignage/xibo-cms:release-1.8.5 volumes: - "./shared/cms/custom:/var/www/cms/custom" - "./shared/backup:/var/www/backup" diff --git a/config.env.template b/config.env.template index 41bacbc..39994fc 100644 --- a/config.env.template +++ b/config.env.template @@ -60,4 +60,12 @@ CMS_SERVER_NAME=cms.example.org ## Sometimes you want Xibo to run in a sub directory of the webserver ## rather than at the root. If so, specify it here. Comment it out to ## use the web root. -# CMS_ALIAS=/xibo \ No newline at end of file +# CMS_ALIAS=/xibo + + +## Xibo comes with a 2GB limit for individual file uploads +## If you require larger files, uncomment the following and adjust as +## required +# CMS_PHP_POST_MAX_SIZE=4G +# CMS_PHP_UPLOAD_MAX_FILESIZE=4G +# CMS_PHP_MAX_EXECUTION_TIME=600 \ No newline at end of file diff --git a/containers/web/Dockerfile b/containers/web/Dockerfile deleted file mode 100644 index 8529e29..0000000 --- a/containers/web/Dockerfile +++ /dev/null @@ -1,100 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Dan Garner - -RUN apt-get update && apt-get install -y \ - software-properties-common - -RUN LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -RUN LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/apache2 - -# Install apache, PHP, and supplimentary programs. -RUN apt-get update && apt-get install -y \ - apache2 \ - libapache2-mod-php5.6 \ - libapache2-mod-xsendfile \ - mysql-client \ - php5.6-mysql \ - php5.6-gd \ - php5.6-curl \ - php5.6-cli \ - curl \ - php5.6-mcrypt \ - php5.6-zmq \ - php5.6-xml \ - php5.6-memcached \ - php5.6-soap \ - php5.6-zip \ - php5.6-mbstring \ - ssmtp \ - wget \ - anacron - -# Enable apache mods and PHP extensions -RUN a2enmod php5.6 && a2enmod rewrite && a2enmod env && phpenmod mcrypt && a2enmod xsendfile && a2dismod mpm_event && a2enmod mpm_prefork - -# Configure mpm_prefork -ADD mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.conf - -# Disable cron sending emails to root -RUN awk '/PATH=/ { print; print "MAILTO=\"\""; next}1' /etc/crontab > /tmp/crontab && mv /tmp/crontab /etc/crontab -RUN awk '/LOGNAME=root/ { print; print "MAILTO=\"\""; next}1' /etc/anacrontab > /tmp/anacrontab && mv /tmp/anacrontab /etc/anacrontab - -# Setup persistent environment variables -ENV CMS_VERSION=1.8.4 XMR_HOST=xmr CMS_DB_VERSION=135 CMS_SERVER_NAME=localhost -ENV MYSQL_HOST=mysql MYSQL_USER=cms MYSQL_PASSWORD=none MYSQL_PORT=3306 MYSQL_DATABASE=cms -ENV CMS_SMTP_SERVER=smtp.gmail.com:587 CMS_SMTP_USERNAME=none CMS_SMTP_PASSWORD=none CMS_SMTP_USE_TLS=YES CMS_SMTP_USE_STARTTLS=YES CMS_SMTP_REWRITE_DOMAIN=gmail.com CMS_SMTP_HOSTNAME=none CMS_SMTP_FROM_LINE_OVERRIDE=YES -ENV CMS_ALIAS=none CMS_PHP_SESSION_GC_MAXLIFETIME=1440 -ENV CMS_PHP_POST_MAX_SIZE=2G CMS_PHP_UPLOAD_MAX_FILESIZE=2G -ENV CMS_PHP_MAX_EXECUTION_TIME=300 -ENV CMS_APACHE_START_SERVERS=2 CMS_APACHE_MIN_SPARE_SERVERS=5 -ENV CMS_APACHE_MAX_SPARE_SERVERS=10 CMS_APACHE_MAX_REQUEST_WORKERS=60 -ENV CMS_APACHE_MAX_CONNECTIONS_PER_CHILD=300 - - -# Update the PHP.ini file -RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php/5.6/apache2/php.ini -RUN sed -i "s/session.gc_probability = .*$/session.gc_probability = 1/" /etc/php/5.6/apache2/php.ini -RUN sed -i "s/session.gc_divisor = .*$/session.gc_divisor = 100/" /etc/php/5.6/apache2/php.ini - -# Expose port 80 -EXPOSE 80 - -# Pull in the release archive for the environment -RUN mkdir -p /var/www/cms && curl -o cms.tar.gz -SL https://github.com/xibosignage/xibo-cms/releases/download/${CMS_VERSION}/xibo-cms-${CMS_VERSION}.tar.gz \ - && tar --strip=1 -xzf cms.tar.gz -C /var/www/cms \ - && rm cms.tar.gz && rm /var/www/cms/web/install/index.php - -# https://github.com/vishnubob/wait-for-it - MIT Licence -ADD wait-for-it.sh /usr/local/bin/wait-for-it.sh -ADD settings.php-template /var/www/cms/web/settings.php -ADD settings.php-template /tmp/settings.php-template -ADD ssmtp.conf /etc/ssmtp/ssmtp.conf -ADD settings-custom.php /tmp/settings-custom.php - -# Map a volumes to this folder. -# Our CMS files, library, cache and backups will be in here. -RUN mkdir -p /var/www/cms/library/temp && mkdir -p /var/www/backup && mkdir -p /var/www/cms/cache && mkdir -p /var/www/cms/web/userscripts && chown -R www-data:www-data /var/www/cms - -# Update the default apache site with the config we created. -COPY apache-config.conf /etc/apache2/sites-enabled/000-default.conf - -# Copy up the various provisioning scripting -COPY entrypoint.sh /entrypoint.sh -COPY httpd-foreground /usr/local/bin/httpd-foreground -COPY anacron /etc/cron.d/anacron -RUN chmod +x /entrypoint.sh /usr/local/bin/httpd-foreground /usr/local/bin/wait-for-it.sh - -# Create a flag file which the bootstrapping process will delete -# This tells us if it's the first run of a new container -RUN touch /CMS-FLAG - -# Add a group for SSMTP -RUN /usr/sbin/groupadd ssmtp - -VOLUME /var/www/cms/library -VOLUME /var/www/cms/custom -VOLUME /var/www/cms/web/theme/custom -VOLUME /var/www/backup -VOLUME /var/www/cms/web/userscripts - -CMD ["/entrypoint.sh"] diff --git a/containers/web/Dockerfile.dev b/containers/web/Dockerfile.dev deleted file mode 100644 index 6f56aba..0000000 --- a/containers/web/Dockerfile.dev +++ /dev/null @@ -1,94 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER Dan Garner - -RUN apt-get update && apt-get install -y \ - software-properties-common - -RUN LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -RUN LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/apache2 - -# Install apache, PHP, and supplimentary programs. -RUN apt-get update && apt-get install -y \ - apache2 \ - libapache2-mod-php5.6 \ - libapache2-mod-xsendfile \ - mysql-client \ - php5.6-mysql \ - php5.6-gd \ - php5.6-curl \ - php5.6-cli \ - curl \ - php5.6-mcrypt \ - php5.6-zmq \ - php5.6-xml \ - php5.6-memcached \ - php5.6-soap \ - php5.6-zip \ - php5.6-mbstring \ - ssmtp \ - wget \ - anacron - -# Enable apache mods and PHP extensions -RUN a2enmod php5.6 && a2enmod rewrite && a2enmod env && phpenmod mcrypt && a2enmod xsendfile && a2dismod mpm_event && a2enmod mpm_prefork - -# Configure mpm_prefork -ADD mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.conf - -# Disable cron sending emails to root -RUN awk '/PATH=/ { print; print "MAILTO=\"\""; next}1' /etc/crontab > /tmp/crontab && mv /tmp/crontab /etc/crontab -RUN awk '/LOGNAME=root/ { print; print "MAILTO=\"\""; next}1' /etc/anacrontab > /tmp/anacrontab && mv /tmp/anacrontab /etc/anacrontab - -# Setup persistent environment variables -ENV CMS_VERSION=1.8.4 XMR_HOST=xmr CMS_DB_VERSION=135 CMS_SERVER_NAME=localhost -ENV MYSQL_HOST=mysql MYSQL_USER=cms MYSQL_PASSWORD=none MYSQL_PORT=3306 MYSQL_DATABASE=cms -ENV CMS_SMTP_SERVER=smtp.gmail.com:587 CMS_SMTP_USERNAME=none CMS_SMTP_PASSWORD=none CMS_SMTP_USE_TLS=YES CMS_SMTP_USE_STARTTLS=YES CMS_SMTP_REWRITE_DOMAIN=gmail.com CMS_SMTP_HOSTNAME=none CMS_SMTP_FROM_LINE_OVERRIDE=YES -ENV CMS_ALIAS=none CMS_PHP_SESSION_GC_MAXLIFETIME=1440 -ENV CMS_PHP_POST_MAX_SIZE=2G CMS_PHP_UPLOAD_MAX_FILESIZE=2G -ENV CMS_PHP_MAX_EXECUTION_TIME=300 -ENV CMS_APACHE_START_SERVERS=2 CMS_APACHE_MIN_SPARE_SERVERS=5 -ENV CMS_APACHE_MAX_SPARE_SERVERS=10 CMS_APACHE_MAX_REQUEST_WORKERS=60 -ENV CMS_APACHE_MAX_CONNECTIONS_PER_CHILD=300 - - -# Update the PHP.ini file -RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php/5.6/apache2/php.ini -RUN sed -i "s/session.gc_probability = .*$/session.gc_probability = 1/" /etc/php/5.6/apache2/php.ini -RUN sed -i "s/session.gc_divisor = .*$/session.gc_divisor = 100/" /etc/php/5.6/apache2/php.ini - -# Expose port 80 -EXPOSE 80 - -# Pull in the release archive for the environment -RUN mkdir -p /var/www/cms && curl -o cms.tar.gz -SL https://github.com/xibosignage/xibo-cms/releases/download/${CMS_VERSION}/xibo-cms-${CMS_VERSION}.tar.gz \ - && tar --strip=1 -xzf cms.tar.gz -C /var/www/cms \ - && rm cms.tar.gz && rm /var/www/cms/web/install/index.php - -# https://github.com/vishnubob/wait-for-it - MIT Licence -ADD wait-for-it.sh /usr/local/bin/wait-for-it.sh -ADD settings.php-template /var/www/cms/web/settings.php -ADD settings.php-template /tmp/settings.php-template -ADD ssmtp.conf /etc/ssmtp/ssmtp.conf -ADD settings-custom.php /tmp/settings-custom.php - -# Map a volumes to this folder. -# Our CMS files, library, cache and backups will be in here. -RUN mkdir -p /var/www/cms/library/temp && mkdir -p /var/www/backup && mkdir -p /var/www/cms/cache && mkdir -p /var/www/cms/web/userscripts && chown -R www-data:www-data /var/www/cms - -# Update the default apache site with the config we created. -COPY apache-config.conf /etc/apache2/sites-enabled/000-default.conf - -# Copy up the various provisioning scripting -COPY entrypoint.sh /entrypoint.sh -COPY httpd-foreground /usr/local/bin/httpd-foreground -COPY anacron /etc/cron.d/anacron -RUN chmod +x /entrypoint.sh /usr/local/bin/httpd-foreground /usr/local/bin/wait-for-it.sh - -# Create a flag file which the bootstrapping process will delete -# This tells us if it's the first run of a new container -RUN touch /CMS-FLAG - -# Add a group for SSMTP -RUN /usr/sbin/groupadd ssmtp - -CMD ["/entrypoint.sh"] diff --git a/containers/web/anacron b/containers/web/anacron deleted file mode 100644 index 0515995..0000000 --- a/containers/web/anacron +++ /dev/null @@ -1,6 +0,0 @@ -# /etc/cron.d/anacron: crontab entries for the anacron package - -SHELL=/bin/sh -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin - -30 23 * * * root /usr/sbin/anacron diff --git a/containers/web/apache-config.conf b/containers/web/apache-config.conf deleted file mode 100644 index 0604c99..0000000 --- a/containers/web/apache-config.conf +++ /dev/null @@ -1,32 +0,0 @@ - - ServerAdmin me@example.com - DocumentRoot /var/www/cms/web/ - - PassEnv MYSQL_DATABASE - PassEnv MYSQL_HOST - PassEnv MYSQL_USER - PassEnv MYSQL_PORT - PassEnv MYSQL_PASSWORD - PassEnv CMS_SERVER_NAME - - ServerName ${CMS_SERVER_NAME} - - KeepAlive Off - - XSendFile on - XSendFilePath /var/www/cms/library - - - DirectoryIndex index.php index.html - Options Indexes FollowSymLinks MultiViews - AllowOverride All - Order deny,allow - Allow from all - - - ErrorLog ${APACHE_LOG_DIR}/error.log - CustomLog ${APACHE_LOG_DIR}/access.log combined - - # Alias /xibo /var/www/cms/web - - diff --git a/containers/web/entrypoint.sh b/containers/web/entrypoint.sh deleted file mode 100644 index b7c78e6..0000000 --- a/containers/web/entrypoint.sh +++ /dev/null @@ -1,222 +0,0 @@ -#!/bin/bash - -if [ "$XIBO_DEV_MODE" == "true" ] -then - # Print MySQL connection details - echo "MySQL Connection Details:" - echo "Username: cms" - echo "Password: $MYSQL_PASSWORD" - echo "Host: mysql" - echo "" - echo "XMR Connection Details:" - echo "Host: $XMR_HOST" - echo "CMS Port: 50001" - echo "Player Port: 9505" - echo "" - echo "Starting Webserver" - /usr/local/bin/httpd-foreground - exit $? -fi - -# Sleep for a few seconds to give MySQL time to initialise -echo "Waiting for MySQL to start - max 300 seconds" -/usr/local/bin/wait-for-it.sh -q -t 300 $MYSQL_HOST:$MYSQL_PORT - -if [ ! "$?" == 0 ] -then - echo "MySQL didn't start in the allocated time" > /var/www/backup/LOG -fi - -# Safety sleep to give MySQL a moment to settle after coming up -echo "MySQL started" -sleep 1 - -# Check if there's a database file to import -if [ -f "/var/www/backup/import.sql" ] -then - echo "Attempting to import database" - - echo "Importing Database" - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "SOURCE /var/www/backup/import.sql" - - echo "Configuring Database Settings" - # Set LIBRARY_LOCATION - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='/var/www/cms/library/', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='LIBRARY_LOCATION' LIMIT 1" - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='Apache', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='SENDFILE_MODE' LIMIT 1" - - # Set XMR public/private address - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='tcp://$XMR_HOST:50001', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='XMR_ADDRESS' LIMIT 1" - - # Configure Maintenance - echo "Setting up Maintenance" - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='Protected' WHERE \`setting\`='MAINTENANCE_ENABLED' LIMIT 1" - - MAINTENANCE_KEY=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16) - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='$MAINTENANCE_KEY' WHERE \`setting\`='MAINTENANCE_KEY' LIMIT 1" - - mv /var/www/backup/import.sql /var/www/backup/import.sql.done -fi - -DB_EXISTS=0 -# Check if the database exists already -if mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "SELECT DBVersion from version" -then - # Database exists. - DB_EXISTS=1 -fi - -# Check if we need to run an upgrade -# if DB_EXISTS then see if the version installed matches -if [ "$DB_EXISTS" == "1" ] -then - # Get the currently installed schema version number - CURRENT_DB_VERSION=$(mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -se 'SELECT DBVersion from version') - - if [ ! "$CURRENT_DB_VERSION" == "$CMS_DB_VERSION" ] - then - # We're going to run an upgrade. Make a database backup - mysqldump -h $MYSQL_HOST -P $MYSQL_PORT -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE | gzip > /var/www/backup/db-$(date +"%Y-%m-%d_%H-%M-%S").sql.gz - - # Drop app cache on upgrade - rm -rf /var/www/cms/cache/* - fi -fi - -if [ "$DB_EXISTS" == "0" ] -then - # This is a fresh install so bootstrap the whole - # system - echo "New install" - - echo "Provisioning Database" - # Populate the database - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "SOURCE /var/www/cms/install/master/structure.sql" - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "SOURCE /var/www/cms/install/master/data.sql" - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "SOURCE /var/www/cms/install/master/constraints.sql" - - CMS_KEY=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8) - - echo "Configuring Database Settings" - # Set LIBRARY_LOCATION - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='/var/www/cms/library/', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='LIBRARY_LOCATION' LIMIT 1" - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='Apache', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='SENDFILE_MODE' LIMIT 1" - - # Set admin username/password - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`user\` SET \`UserName\`='xibo_admin', \`UserPassword\`='5f4dcc3b5aa765d61d8327deb882cf99' WHERE \`UserID\` = 1 LIMIT 1" - - # Set XMR public/private address - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='tcp://$XMR_HOST:50001', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='XMR_ADDRESS' LIMIT 1" - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='tcp://cms.example.org:9505' WHERE \`setting\`='XMR_PUB_ADDRESS' LIMIT 1" - - # Set CMS Key - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='$CMS_KEY' WHERE \`setting\`='SERVER_KEY' LIMIT 1" - - # Configure Maintenance - echo "Setting up Maintenance" - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='Protected' WHERE \`setting\`='MAINTENANCE_ENABLED' LIMIT 1" - - MAINTENANCE_KEY=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16) - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='$MAINTENANCE_KEY' WHERE \`setting\`='MAINTENANCE_KEY' LIMIT 1" -fi - -if [ -e /CMS-FLAG ] -then - # Remove the CMS-FLAG so we don't run this block time we're started - rm /CMS-FLAG - - # Write settings.php - echo "Updating settings.php" - SECRET_KEY=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8) - - if [ "$XIBO_DEV_MODE" == "ci" ] - then - # We won't have a settings.php in place, so we'll need to copy one in - cp /tmp/settings.php-template /var/www/cms/web/settings.php - chown www-data.www-data -R /var/www/cms - - # Unprotect maintenance in CI mode - mysql -D $MYSQL_DATABASE -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST -P $MYSQL_PORT -e "UPDATE \`setting\` SET \`value\`='On' WHERE \`setting\`='MAINTENANCE_ENABLED' LIMIT 1" - fi - - /bin/sed -i "s/define('SECRET_KEY','');/define('SECRET_KEY','$SECRET_KEY');/" /var/www/cms/web/settings.php -fi - -# Configure MySQL Backup -echo "Configuring Backups" -echo "#!/bin/bash" > /etc/cron.daily/cms-db-backup -echo "" >> /etc/cron.daily/cms-db-backup -echo "/bin/mkdir -p /var/www/backup/db" >> /etc/cron.daily/cms-db-backup -echo "/usr/bin/mysqldump --single-transaction -u '$MYSQL_USER' -p'$MYSQL_PASSWORD' -h $MYSQL_HOST -P $MYSQL_PORT $MYSQL_DATABASE > /var/www/backup/db/latest.sql" >> /etc/cron.daily/cms-db-backup -echo "RESULT=\$?" >> /etc/cron.daily/cms-db-backup -echo "if [ \$RESULT -eq 0 ]; then" >> /etc/cron.daily/cms-db-backup -echo " mv /var/www/backup/db/latest.sql.gz /var/www/backup/db/previous.sql.gz" >> /etc/cron.daily/cms-db-backup -echo " cd /var/www/backup/db && gzip latest.sql" >> /etc/cron.daily/cms-db-backup -echo "fi" >> /etc/cron.daily/cms-db-backup -/bin/chmod 700 /etc/cron.daily/cms-db-backup - -# Update /var/www/maintenance with current environment (for cron) -echo "Configuring Maintenance" -echo "#!/bin/bash" > /var/www/maintenance.sh -echo "" >> /var/www/maintenance.sh -/usr/bin/env | sed 's/^\(.*\)$/export \1/g' | grep -E "^export MYSQL" >> /var/www/maintenance.sh -echo "cd /var/www/cms && /usr/bin/php bin/xtr.php" >> /var/www/maintenance.sh -chmod 755 /var/www/maintenance.sh - -echo "* * * * * www-data /var/www/maintenance.sh > /dev/null 2>&1 " > /etc/cron.d/cms-maintenance - -# Configure SSMTP to send emails if required -/bin/sed -i "s/mailhub=.*$/mailhub=$CMS_SMTP_SERVER/" /etc/ssmtp/ssmtp.conf -if [ -z "$CMS_SMTP_USERNAME" ] || [ "$CMS_SMTP_USERNAME" == "none" ] -then - /bin/sed -i "s/^#*AuthUser=.*$/#AuthUser=/" /etc/ssmtp/ssmtp.conf - /bin/sed -i "s/^#*AuthPass=.*$/#AuthPass=/" /etc/ssmtp/ssmtp.conf -else - /bin/sed -i "s/^#*AuthUser=.*$/AuthUser=$CMS_SMTP_USERNAME/" /etc/ssmtp/ssmtp.conf - /bin/sed -i "s/^#*AuthPass=.*$/AuthPass=$CMS_SMTP_PASSWORD/" /etc/ssmtp/ssmtp.conf -fi - -/bin/sed -i "s/UseTLS=.*$/UseTLS=$CMS_SMTP_USE_TLS/" /etc/ssmtp/ssmtp.conf -/bin/sed -i "s/UseSTARTTLS=.*$/UseSTARTTLS=$CMS_SMTP_USE_STARTTLS/" /etc/ssmtp/ssmtp.conf -/bin/sed -i "s/rewriteDomain=.*$/rewriteDomain=$CMS_SMTP_REWRITE_DOMAIN/" /etc/ssmtp/ssmtp.conf -/bin/sed -i "s/hostname=.*$/hostname=$CMS_SMTP_HOSTNAME/" /etc/ssmtp/ssmtp.conf -/bin/sed -i "s/FromLineOverride=.*$/FromLineOverride=$CMS_SMTP_FROM_LINE_OVERRIDE/" /etc/ssmtp/ssmtp.conf - -# Secure SSMTP files -# Following recommendations here: -# https://wiki.archlinux.org/index.php/SSMTP#Security -/bin/chgrp ssmtp /etc/ssmtp/ssmtp.conf -/bin/chgrp ssmtp /usr/sbin/ssmtp -/bin/chmod 640 /etc/ssmtp/ssmtp.conf -/bin/chmod g+s /usr/sbin/ssmtp - -mkdir -p /var/www/cms/library/temp -chown www-data.www-data -R /var/www/cms - -if [ ! -e /var/www/cms/custom/settings-custom.php ] -then - /bin/cp /tmp/settings-custom.php /var/www/cms/custom -fi - -if [ ! "$CMS_ALIAS" == "none" ] -then - echo "Setting up CMS alias" - /bin/sed -i "s|.*Alias.*$|Alias $CMS_ALIAS /var/www/cms/web|" /etc/apache2/sites-enabled/000-default.conf - /bin/sed -i "s|.*RewriteBase.*$|RewriteBase $CMS_ALIAS|" /var/www/cms/web/.htaccess -fi - -# Configure PHP session.gc_maxlifetime -sed -i "s/session.gc_maxlifetime = .*$/session.gc_maxlifetime = $CMS_PHP_SESSION_GC_MAXLIFETIME/" /etc/php/5.6/apache2/php.ini -sed -i "s/post_max_size = .*$/post_max_size = $CMS_PHP_POST_MAX_SIZE/" /etc/php/5.6/apache2/php.ini -sed -i "s/upload_max_filesize = .*$/upload_max_filesize = $CMS_PHP_UPLOAD_MAX_FILESIZE/" /etc/php/5.6/apache2/php.ini -sed -i "s/max_execution_time = .*$/max_execution_time = $CMS_PHP_MAX_EXECUTION_TIME/" /etc/php/5.6/apache2/php.ini - -echo "Running maintenance" -cd /var/www/cms -su -s /bin/bash -c 'cd /var/www/cms && /usr/bin/php bin/run.php 1' www-data - -echo "Starting cron" -/usr/sbin/cron -/usr/sbin/anacron - -echo "Starting webserver" -/usr/local/bin/httpd-foreground diff --git a/containers/web/httpd-foreground b/containers/web/httpd-foreground deleted file mode 100644 index 38b7f90..0000000 --- a/containers/web/httpd-foreground +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -e - -# Apache gets grumpy about PID files pre-existing -rm -f /var/run/apache2/apache2.pid - -exec apache2ctl -DFOREGROUND diff --git a/containers/web/mpm_prefork.conf b/containers/web/mpm_prefork.conf deleted file mode 100644 index 1512203..0000000 --- a/containers/web/mpm_prefork.conf +++ /dev/null @@ -1,14 +0,0 @@ -# prefork MPM -# StartServers: number of server processes to start -# MinSpareServers: minimum number of server processes which are kept spare -# MaxSpareServers: maximum number of server processes which are kept spare -# MaxRequestWorkers: maximum number of server processes allowed to start -# MaxConnectionsPerChild: maximum number of requests a server process serves - - - StartServers ${CMS_APACHE_START_SERVERS} - MinSpareServers ${CMS_APACHE_MIN_SPARE_SERVERS} - MaxSpareServers ${CMS_APACHE_MAX_SPARE_SERVERS} - MaxRequestWorkers ${CMS_APACHE_MAX_REQUEST_WORKERS} - MaxConnectionsPerChild ${CMS_APACHE_MAX_CONNECTIONS_PER_CHILD} - diff --git a/containers/web/settings-custom.php b/containers/web/settings-custom.php deleted file mode 100644 index 0c44249..0000000 --- a/containers/web/settings-custom.php +++ /dev/null @@ -1,71 +0,0 @@ - array( -# // Enable/Disable Just-In-Time provisioning -# 'jit' => true, -# // Attribute to identify the user -# 'field_to_identify' => 'UserName', // Alternatives: UserID, UserName or email -# // Default libraryQuota assigned to the created user by JIT -# 'libraryQuota' => 1000, -# // Initial User Group -# 'group' => 'Users', -# // Home Page -# 'homePage' => 'dashboard', -# // Enable/Disable Single Logout -# 'slo' => true, -# // Attribute mapping between XIBO-CMS and the IdP -# 'mapping' => array ( -# 'UserID' => '', -# 'usertypeid' => '', -# 'UserName' => 'uid', -# 'email' => 'mail', -# ) -# ), -# // Settings for the PHP-SAML toolkit. -# // See documentation: https://github.com/onelogin/php-saml#settings -# 'strict' => false, -# 'debug' => true, -# 'idp' => array ( -# 'entityId' => 'https://idp.example.com/simplesaml/saml2/idp/metadata.php', -# 'singleSignOnService' => array ( -# 'url' => 'http://idp.example.com/simplesaml/saml2/idp/SSOService.php', -# ), -# 'singleLogoutService' => array ( -# 'url' => 'http://idp.example.com/simplesaml/saml2/idp/SingleLogoutService.php', -# ), -# 'x509cert' => 'MIICbDCCAdWgAwIBAgIBADANBgkqhkiG9w0BAQ0FADBTMQswCQYDVQQGEwJ1czETMBEGA1UECAwKQ2FsaWZvcm5pYTEVMBMGA1UECgwMT25lbG9naW4gSW5jMRgwFgYDVQQDDA9pZHAuZXhhbXBsZS5jb20wHhcNMTQwOTIzMTIyNDA4WhcNNDIwMjA4MTIyNDA4WjBTMQswCQYDVQQGEwJ1czETMBEGA1UECAwKQ2FsaWZvcm5pYTEVMBMGA1UECgwMT25lbG9naW4gSW5jMRgwFgYDVQQDDA9pZHAuZXhhbXBsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOWA+YHU7cvPOrBOfxCscsYTJB+kH3MaA9BFrSHFS+KcR6cw7oPSktIJxUgvDpQbtfNcOkE/tuOPBDoech7AXfvH6d7Bw7xtW8PPJ2mB5Hn/HGW2roYhxmfh3tR5SdwN6i4ERVF8eLkvwCHsNQyK2Ref0DAJvpBNZMHCpS24916/AgMBAAGjUDBOMB0GA1UdDgQWBBQ77/qVeiigfhYDITplCNtJKZTM8DAfBgNVHSMEGDAWgBQ77/qVeiigfhYDITplCNtJKZTM8DAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBDQUAA4GBAJO2j/1uO80E5C2PM6Fk9mzerrbkxl7AZ/mvlbOn+sNZE+VZ1AntYuG8ekbJpJtG1YfRfc7EA9mEtqvv4dhv7zBy4nK49OR+KpIBjItWB5kYvrqMLKBa32sMbgqqUqeF1ENXKjpvLSuPdfGJZA3dNa/+Dyb8GGqWe707zLyc5F8m', -# ), -# 'sp' => array ( -# 'entityId' => 'http://xibo-cms.example.com/saml/metadata', -# 'assertionConsumerService' => array ( -# 'url' => 'http://xibo-cms.example.com/saml/acs', -# ), -# 'singleLogoutService' => array ( -# 'url' => 'http://xibo-cms.example.com/saml/sls', -# ), -# 'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress', -# 'x509cert' => '', -# 'privateKey' > '', -# ), -# 'security' => array ( -# 'nameIdEncrypted' => false, -# 'authnRequestsSigned' => false, -# 'logoutRequestSigned' => false, -# 'logoutResponseSigned' => false, -# 'signMetadata' => false, -# 'wantMessagesSigned' => false, -# 'wantAssertionsSigned' => false, -# 'wantAssertionsEncrypted' => false, -# 'wantNameIdEncrypted' => false, -# ) -#); - -?> diff --git a/containers/web/settings.php-template b/containers/web/settings.php-template deleted file mode 100644 index 56d2290..0000000 --- a/containers/web/settings.php-template +++ /dev/null @@ -1,29 +0,0 @@ -" . __("Please press the back button in your browser.")); - -global $dbhost; -global $dbuser; -global $dbpass; -global $dbname; - -$dbhost = $_SERVER['MYSQL_HOST'] . ':' . $_SERVER['MYSQL_PORT']; -$dbuser = $_SERVER['MYSQL_USER']; -$dbpass = $_SERVER['MYSQL_PASSWORD']; -$dbname = $_SERVER['MYSQL_DATABASE']; - -if (!defined('SECRET_KEY')) -define('SECRET_KEY',''); - -if (file_exists('/var/www/cms/custom/settings-custom.php')) - include_once('/var/www/cms/custom/settings-custom.php'); - -?> diff --git a/containers/web/ssmtp.conf b/containers/web/ssmtp.conf deleted file mode 100644 index 6c18b8c..0000000 --- a/containers/web/ssmtp.conf +++ /dev/null @@ -1,24 +0,0 @@ -# Config file for sSMTP sendmail -# Set root= blank to avoid relaying all the local emails for -# root out to the internet -root= - -# The place where the mail goes. The actual machine name is required no -# MX records are consulted. Commonly mailhosts are named mail.domain.com -mailhub=smtp.gmail.com:587 - -AuthUser=MyEmailAddress@gmail.com -AuthPass=MyPassword -UseTLS=YES -UseSTARTTLS=YES - -# Where will the mail seem to come from? -rewriteDomain=gmail.com - -# The full hostname -hostname=MyEmailAddress@gmail.com - -# Are users allowed to set their own From: address? -# YES - Allow the user to specify their own From: address -# NO - Use the system generated From: address -FromLineOverride=YES diff --git a/containers/web/wait-for-it.sh b/containers/web/wait-for-it.sh deleted file mode 100644 index eca6c3b..0000000 --- a/containers/web/wait-for-it.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env bash -# Use this script to test if a given TCP host/port are available - -cmdname=$(basename $0) - -echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } - -usage() -{ - cat << USAGE >&2 -Usage: - $cmdname host:port [-s] [-t timeout] [-- command args] - -h HOST | --host=HOST Host or IP under test - -p PORT | --port=PORT TCP port under test - Alternatively, you specify the host and port as host:port - -s | --strict Only execute subcommand if the test succeeds - -q | --quiet Don't output any status messages - -t TIMEOUT | --timeout=TIMEOUT - Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit 1 -} - -wait_for() -{ - if [[ $TIMEOUT -gt 0 ]]; then - echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" - else - echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" - fi - start_ts=$(date +%s) - while : - do - (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 - result=$? - if [[ $result -eq 0 ]]; then - end_ts=$(date +%s) - echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" - break - fi - sleep 1 - done - return $result -} - -wait_for_wrapper() -{ - # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 - if [[ $QUIET -eq 1 ]]; then - timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - else - timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - fi - PID=$! - trap "kill -INT -$PID" INT - wait $PID - RESULT=$? - if [[ $RESULT -ne 0 ]]; then - echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" - fi - return $RESULT -} - -# process arguments -while [[ $# -gt 0 ]] -do - case "$1" in - *:* ) - hostport=(${1//:/ }) - HOST=${hostport[0]} - PORT=${hostport[1]} - shift 1 - ;; - --child) - CHILD=1 - shift 1 - ;; - -q | --quiet) - QUIET=1 - shift 1 - ;; - -s | --strict) - STRICT=1 - shift 1 - ;; - -h) - HOST="$2" - if [[ $HOST == "" ]]; then break; fi - shift 2 - ;; - --host=*) - HOST="${1#*=}" - shift 1 - ;; - -p) - PORT="$2" - if [[ $PORT == "" ]]; then break; fi - shift 2 - ;; - --port=*) - PORT="${1#*=}" - shift 1 - ;; - -t) - TIMEOUT="$2" - if [[ $TIMEOUT == "" ]]; then break; fi - shift 2 - ;; - --timeout=*) - TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - CLI="$@" - break - ;; - --help) - usage - ;; - *) - echoerr "Unknown argument: $1" - usage - ;; - esac -done - -if [[ "$HOST" == "" || "$PORT" == "" ]]; then - echoerr "Error: you need to provide a host and port to test." - usage -fi - -TIMEOUT=${TIMEOUT:-15} -STRICT=${STRICT:-0} -CHILD=${CHILD:-0} -QUIET=${QUIET:-0} - -if [[ $CHILD -gt 0 ]]; then - wait_for - RESULT=$? - exit $RESULT -else - if [[ $TIMEOUT -gt 0 ]]; then - wait_for_wrapper - RESULT=$? - else - wait_for - RESULT=$? - fi -fi - -if [[ $CLI != "" ]]; then - if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then - echoerr "$cmdname: strict mode, refusing to execute subprocess" - exit $RESULT - fi - exec $CLI -else - exit $RESULT -fi diff --git a/docker-compose.yml b/docker-compose.yml index cb16b61..499711b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,7 @@ services: mem_limit: 256m env_file: config.env cms-web: - image: xibosignage/xibo-cms:release-1.8.4 + image: xibosignage/xibo-cms:release-1.8.5 volumes: - "./shared/cms/custom:/var/www/cms/custom" - "./shared/backup:/var/www/backup"