From d65b39453e51731e8ff83f84d9220d1cea97ed80 Mon Sep 17 00:00:00 2001 From: Devin Norgarb Date: Sat, 20 May 2023 21:50:08 +0200 Subject: [PATCH] wip --- .idea/.gitignore | 8 + .idea/aws.xml | 17 ++ .idea/csv-editor.xml | 16 ++ .idea/inspectionProfiles/Project_Default.xml | 178 +++++++++++++++++++ .idea/magento2plugin.xml | 6 + .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/php.xml | 19 ++ .idea/raspap-docker.iml | 10 ++ .idea/vcs.xml | 7 + Dockerfile | 86 ++++++++- composer.json | 2 + dnsmasq.conf | 8 + hostapd.conf | 9 + lighttpd.conf | 18 ++ raspap-webgui | 1 + supervisord.conf | 40 +++++ 17 files changed, 436 insertions(+), 3 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/aws.xml create mode 100644 .idea/csv-editor.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/magento2plugin.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/raspap-docker.iml create mode 100644 .idea/vcs.xml create mode 100644 composer.json create mode 100644 dnsmasq.conf create mode 100644 hostapd.conf create mode 100644 lighttpd.conf create mode 160000 raspap-webgui create mode 100644 supervisord.conf diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..1850186 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/csv-editor.xml b/.idea/csv-editor.xml new file mode 100644 index 0000000..613fc08 --- /dev/null +++ b/.idea/csv-editor.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..280f0a3 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,178 @@ + + + + \ No newline at end of file diff --git a/.idea/magento2plugin.xml b/.idea/magento2plugin.xml new file mode 100644 index 0000000..6485e05 --- /dev/null +++ b/.idea/magento2plugin.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3ce3588 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9286e98 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..f324872 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/raspap-docker.iml b/.idea/raspap-docker.iml new file mode 100644 index 0000000..4312e89 --- /dev/null +++ b/.idea/raspap-docker.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..cadae7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3740b7d..3017ee0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,83 @@ -FROM alehaa/debian-systemd:buster -RUN apt update && apt install -y sudo wget procps curl systemd && rm -rf /var/lib/apt/lists/* -COPY setup.sh . +# Base image +FROM debian:latest + +RUN debian_frontend=noninteractive + +USER root +RUN echo 'iptables-persistent iptables-persistent/autosave_v4 boolean true' | debconf-set-selections +RUN echo 'iptables-persistent iptables-persistent/autosave_v6 boolean true' | debconf-set-selections + + +# Update the system +RUN apt-get update && apt-get upgrade -y + +# Install dependencies +RUN apt-get install -y \ + git \ + lighttpd \ + php7.4-cgi \ + hostapd \ + dnsmasq \ + vnstat \ + qrencode \ + dhcpcd5 -y \ + iptables-persistent + + + +# Enable PHP for lighttpd +RUN lighttpd-enable-mod fastcgi-php + +# Clone RaspAP repository +RUN git clone https://github.com/RaspAP/raspap-webgui /var/www/html/raspap-webgui + +# Copy additional lighttpd config file +COPY raspap-webgui/config/50-raspap-router.conf /etc/lighttpd/conf-available/50-raspap-router.conf +RUN ln -s /etc/lighttpd/conf-available/50-raspap-router.conf /etc/lighttpd/conf-enabled/50-raspap-router.conf + +# Set up configuration directories +RUN mkdir /etc/raspap/ +RUN mkdir /etc/raspap/backups +RUN mkdir /etc/raspap/networking +RUN mkdir /etc/raspap/hostapd +RUN mkdir /etc/raspap/lighttpd + +# Copy auth control file +RUN cp /var/www/html/raspap-webgui/raspap.php /etc/raspap/ + +# Set file ownership +RUN chown -R www-data:www-data /var/www/html +RUN chown -R www-data:www-data /etc/raspap + +# Move control scripts +RUN mv /var/www/html/raspap-webgui/installers/*log.sh /etc/raspap/hostapd +RUN mv /var/www/html/raspap-webgui/installers/service*.sh /etc/raspap/hostapd +RUN chown -c root:www-data /etc/raspap/hostapd/*.sh +RUN chmod 750 /etc/raspap/hostapd/*.sh + +# Copy default configurations +COPY raspap-webgui/config/hostapd.conf /etc/default/hostapd +COPY raspap-webgui/config/hostapd.conf /etc/hostapd/hostapd.conf +COPY raspap-webgui/config/090_raspap.conf /etc/dnsmasq.d/090_raspap.conf +COPY raspap-webgui/config/090_wlan0.conf /etc/dnsmasq.d/090_wlan0.conf +COPY raspap-webgui/config/dhcpcd.conf /etc/dhcpcd.conf +COPY raspap-webgui/config/config.php /var/www/html/includes/ +COPY raspap-webgui/config/defaults.json /etc/raspap/networking/ + +# Enable IP forwarding +RUN #mkdir /etc/sysctl.d/ +RUN #echo "net.ipv4.ip_forward=1" >> /etc/sysctl.d/90_raspap.conf +#RUN sysctl -p /etc/sysctl.d/90_raspap.conf +RUN #/etc/init.d/procps restart +USER root + +# Set up iptables masquerade rules +#RUN iptables -t nat -git +# Enable hostapd service +RUN echo "DAEMON_CONF=\"/etc/hostapd/hostapd.conf\"" >> /etc/default/hostapd + +# Expose port 80 +EXPOSE 80 + +# Start lighttpd service +CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"] diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/composer.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/dnsmasq.conf b/dnsmasq.conf new file mode 100644 index 0000000..6316eed --- /dev/null +++ b/dnsmasq.conf @@ -0,0 +1,8 @@ +interface=wlan0 +dhcp-range=192.168.50.100,192.168.50.200,255.255.255.0,12h +dhcp-option=3,192.168.50.1 +dhcp-option=6,192.168.50.1 +server=8.8.8.8 +server=8.8.4.4 +log-queries +log-dhcp diff --git a/hostapd.conf b/hostapd.conf new file mode 100644 index 0000000..a33c900 --- /dev/null +++ b/hostapd.conf @@ -0,0 +1,9 @@ +interface=wlan0 +ssid=raspi-webgui +hw_mode=g +channel=6 +wpa=2 +wpa_passphrase=secretpassword +wpa_key_mgmt=WPA-PSK +wpa_pairwise=CCMP +rsn_pairwise=CCMP diff --git a/lighttpd.conf b/lighttpd.conf new file mode 100644 index 0000000..702f40d --- /dev/null +++ b/lighttpd.conf @@ -0,0 +1,18 @@ +server.document-root = "/var/www/html" +server.port = 80 +server.modules = ( + "mod_fastcgi", + "mod_accesslog" +) +index-file.names = ("index.php", "index.html", "index.lighttpd.html") +fastcgi.server = ( + ".php" => ( + "localhost" => ( + "socket" => "/var/run/php/php7.3-fpm.sock", + "bin-path" => "/usr/bin/php-cgi7.3", + "max-procs" => 1, + "broken-scriptfilename" => "enable" + ) + ) +) +accesslog.filename = "/var/log/lighttpd/access.log" diff --git a/raspap-webgui b/raspap-webgui new file mode 160000 index 0000000..9ddff8f --- /dev/null +++ b/raspap-webgui @@ -0,0 +1 @@ +Subproject commit 9ddff8f245713fa97c86d3ba945649248ce0ce28 diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..ade1f95 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,40 @@ +[unix_http_server] +file=/var/run/supervisor.sock + +[supervisord] +logfile=/var/log/supervisor/supervisord.log +logfile_maxbytes=50MB +logfile_backups=10 +loglevel=info +pidfile=/var/run/supervisord.pid +nodaemon=false +minfds=1024 +minprocs=200 + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///var/run/supervisor.sock + +[program:lighttpd] +command=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf +autostart=true +autorestart=true +stderr_logfile=/var/log/supervisor/lighttpd.err.log +stdout_logfile=/var/log/supervisor/lighttpd.out.log + +[program:hostapd] +command=/usr/sbin/hostapd -B /etc/raspap/hostapd/hostapd.conf +autostart=true +autorestart=true +stderr_logfile=/var/log/supervisor/hostapd.err.log +stdout_logfile=/var/log/supervisor/hostapd.out.log + +[program:dnsmasq] +command=/usr/sbin/dnsmasq -C /etc/raspap/networking/dnsmasq.conf +autostart=true +autorestart=true +stderr_logfile=/var/log/supervisor/dnsmasq.err.log +stdout_logfile=/var/log/supervisor/dnsmasq.out.log +