From d22c95d9eabfa38c4bf00a7fda2003b78ceab183 Mon Sep 17 00:00:00 2001 From: ex0nuss Date: Sat, 19 Dec 2020 16:07:23 +0100 Subject: [PATCH] Initial commit --- build/000-default.conf | 49 ++++++++++++++++++++++++++++++++++++++++ build/Dockerfile | 46 +++++++++++++++++++++++++++++++++++++ build/config.php | 50 +++++++++++++++++++++++++++++++++++++++++ build/entrypoint.sh | 39 ++++++++++++++++++++++++++++++++ build/ports.conf | 15 +++++++++++++ docker-compose.yml | 25 +++++++++++++++++++++ docker-compose.yml.save | 22 ++++++++++++++++++ 7 files changed, 246 insertions(+) create mode 100644 build/000-default.conf create mode 100644 build/Dockerfile create mode 100644 build/config.php create mode 100755 build/entrypoint.sh create mode 100644 build/ports.conf create mode 100644 docker-compose.yml create mode 100644 docker-compose.yml.save diff --git a/build/000-default.conf b/build/000-default.conf new file mode 100644 index 0000000..bc27fcc --- /dev/null +++ b/build/000-default.conf @@ -0,0 +1,49 @@ + + + # TLS/SSL configuration, this is for the use of crypto. + ServerAdmin webmaster@localhost + + SSLEngine On + SSLCertificateFile /etc/apache2/ssl/wol.crt + SSLCertificateKeyFile /etc/apache2/ssl/wol.key + + DocumentRoot /var/www/html + + AllowOverride AuthConfig FileInfo + Order allow,deny + allow from all + Options -Indexes + + + ErrorLog ${APACHE_LOG_DIR}/ssl_error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel error + + CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined + + + + + + # Non-TLS/SSL configuration. + ServerAdmin webmaster@localhost + + DocumentRoot /var/www/html + + AllowOverride AuthConfig FileInfo + Order allow,deny + allow from all + Options -Indexes + + + ErrorLog ${APACHE_LOG_DIR}/error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel error + + CustomLog ${APACHE_LOG_DIR}/access.log combined + + diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..3cc47eb --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,46 @@ +FROM php:7.2-apache +MAINTAINER ex0nuss + +RUN apt-get -y update && \ + apt install -y --no-install-recommends \ + iputils-ping \ + wakeonlan \ + git +#RUN docker-php-ext-install curl + +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" +RUN chmod u+s `which ping` +RUN git clone https://github.com/sciguy14/Remote-Wake-Sleep-On-LAN-Server.git + +WORKDIR /var/www/html + +RUN a2enmod headers &&\ + service apache2 restart + +RUN mv -f Remote-Wake-Sleep-On-LAN-Server/000-default.conf /etc/apache2/sites-available/000-default.conf +COPY ports.conf /etc/apache2/ + +RUN sed -i.bak "s/expose_php = On/expose_php = Off/g" $PHP_INI_DIR/php.ini &&\ + sed -i.bak "s/E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED/error_reporting = E_ERROR/g" $PHP_INI_DIR/php.ini &&\ + sed -i.bak "s/ServerSignature On/ServerSignature Off/g" /etc/apache2/conf-available/security.conf &&\ + sed -i.bak "s/ServerTokens OS/ServerTokens Prod/g" /etc/apache2/conf-available/security.conf &&\ + service apache2 restart + +RUN mv Remote-Wake-Sleep-On-LAN-Server/* /var/www/html &&\ + mv Remote-Wake-Sleep-On-LAN-Server/.htaccess /var/www/html &&\ + rm -rf Remote-Wake-Sleep-On-LAN-Server/ &&\ + rm -f /var/www/html/index.html +# mv /var/www/html/config_sample.php /var/www/html/config.php + +COPY config.php /var/www/html/config.php +COPY entrypoint.sh / + +ENV APACHE2_PORT=80 +ENV PASSPHRASE= +ENV RWSOLS_MAX_PINGS=15 +ENV RWSOL_SLEEP_TIME=5 +ENV RWSOLS_COMPUTER_NAME= +ENV RWSOLS_COMPUTER_MAC= +ENV RWSOLS_COMPUTER_IP= + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/build/config.php b/build/config.php new file mode 100644 index 0000000..7e1a9b2 --- /dev/null +++ b/build/config.php @@ -0,0 +1,50 @@ + diff --git a/build/entrypoint.sh b/build/entrypoint.sh new file mode 100755 index 0000000..0e69cde --- /dev/null +++ b/build/entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +#File to edit +file='/var/www/html/config.php' + +#Searches $1 and replaces with $2 in $file +function search_and_replace { + sed -i 's|'$1'|'$2'|g' "$file" +} + +#RWSOLS +#Does everything for ENV-vars with RWSOLS_* +compgen -A variable RWSOLS_ | while read v; do + #Checks if REPLACE_envvar is in $file + if grep -q "REPLACE_$v" "$file"; then + echo "search_and_replace REPLACE_$v with ${!v}" + search_and_replace REPLACE_$v ${!v} + fi +done + +#Settings RWSOLS_HASH for keyphrase +RWSOLS_HASH=$(echo -n $PASSPHRASE | sha256sum | cut -d " " -f 1) +search_and_replace RWSOLS_HASH $RWSOLS_HASH + + +#APACHE2 port mapping +echo "search_and_replace port 80 with $APACHE2_PORT" +sed -i 's|'80'|'$APACHE2_PORT'|g' '/etc/apache2/ports.conf' + + +#Starting apache2 +service apache2 reload +exec apache2-foreground + + +#TODO +# 1. PHP-Arrays mit env vars testen: z.B. RWSOLS_COMPUTER_NAME="PcTest","PcTest1" +# 2. Für alle Config-Settings Env vars erstellen +# 3. Hash for Keyphrase erstellen diff --git a/build/ports.conf b/build/ports.conf new file mode 100644 index 0000000..5daec58 --- /dev/null +++ b/build/ports.conf @@ -0,0 +1,15 @@ +# If you just change the port or add more ports here, you will likely also +# have to change the VirtualHost statement in +# /etc/apache2/sites-enabled/000-default.conf + +Listen 80 + + + Listen 443 + + + + Listen 443 + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f271328 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +version: "3" + +services: + development-rwsols: + build: ./build +# image: ex0nuss/plex-export-docker + container_name: development-rwsols +# restart: unless-stopped + network_mode: host +# ports: +# - 9999:81 +# volumes: +# - + environment: + - APACHE2_PORT=81 + - PASSPHRASE=Test + - RWSOLS_COMPUTER_NAME="HansPc","OMV-nas" + - RWSOLS_COMPUTER_MAC="54:04:A6:3C:B2:D5","AA:AA:AA" + - RWSOLS_COMPUTER_IP="192.168.178.45","192.168.178.100" + labels: + - com.centurylinklabs.watchtower.enable=false + +### ENV-file presets ### +# Europe/Berlin +# 996 diff --git a/docker-compose.yml.save b/docker-compose.yml.save new file mode 100644 index 0000000..475723c --- /dev/null +++ b/docker-compose.yml.save @@ -0,0 +1,22 @@ +RWSOLS_COMPUTER_IPversion: "3" + +services: + development-rwsols: + build: ./build +# image: ex0nuss/plex-export-docker + container_name: development-rwsols +# restart: unless-stopped + ports: + - 9999:80 +# volumes: +# - + environment: + - RWSOLS_COMPUTER_NAME=PcTest + - RWSOLS_COMPUTER_MAC=FF:FF:32:FF + - RWSOLS_IP=192.168.178.1 + labels: + - com.centurylinklabs.watchtower.enable=false + +### ENV-file presets ### +# Europe/Berlin +# 996