Added skeleton for remaining files

master
Keith Irwin 2022-09-14 09:21:52 -06:00
parent 2965127eeb
commit dc1c89ef7a
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
7 changed files with 68 additions and 0 deletions

38
back/admin.Dockerfile Normal file
View File

@ -0,0 +1,38 @@
FROM debian:latest
# Change these
ENV LISTEN_PORT=4410
ENV ADMIN_EMAIL='me@example.com'
# Install deps
RUN apt-get update && apt-get install --yes \
sudo curl apache2 openssl wireguard-tools dnsutils ipv6calc jq \
&& rm -rf /var/lib/apt/lists/*
# Copy over index.cgi
RUN mkdir /var/www/cgi-bin/ && chown www-data:www-data /var/www/cgi-bin/
COPY admin.cgi /var/www/cgi-bin/index.cgi
COPY lib/ /usr/local/bin/
# Configure apache
RUN a2enmod cgi rewrite
RUN sed -i "s/^Listen 80$/Listen ${LISTEN_PORT}/" \
/etc/apache2/ports.conf
RUN sed -i "s/^<VirtualHost \*:80>$/<VirtualHost *:${LISTEN_PORT}>/" \
/etc/apache2/sites-available/000-default.conf
RUN sed -i "s/ServerAdmin .*$/ServerAdmin ${ADMIN_EMAIL}/" \
/etc/apache2/sites-available/000-default.conf
RUN sed -i "s|DocumentRoot .*$|DocumentRoot /var/www/cgi-bin\n\tScriptAlias / /var/www/cgi-bin/index.cgi|" \
/etc/apache2/sites-available/000-default.conf
# Allow http to run these binaries as root with sudo
RUN echo "www-data ALL=(ALL:ALL) NOPASSWD: /usr/bin/wg, /usr/bin/openssl, /usr/bin/[, /usr/bin/tee, /bin/cat, /bin/mkdir, /bin/rm, /bin/chmod" \
| sudo EDITOR='tee -a' visudo
# Create temporary files
RUN touch /var/local/wgapi_tokens
RUN chown www-data:www-data /var/local/wgapi_tokens
# Run time!
EXPOSE ${LISTEN_PORT}
CMD ["apachectl", "-D", "FOREGROUND"]

30
back/admin.cgi Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# FILE: wgapi:back/admin.cgi
# DESCRIPTION: Recieves incoming dashboard API requests
# USAGE: serve
# ERRORS:
# 3: Bad usage
# 4: Missing vars vile
CONFIG_FILE='/etc/wgapi/config'
[ -f "${CONFIG_FILE}" ] || exit 4
source "${CONFIG_FILE}"
case "${REQUEST_METHOD}" in
# List
#'GET') "${LIB_DIR}/peer_list" "${HTTP_X_REAL_IP}";;
# Add
#'POST') "${LIB_DIR}/peer_add" "${HTTP_X_REAL_IP}" "${QUERY_STRING}";;
# Delete
#'DELETE') "${LIB_DIR}/peer_del" "${HTTP_X_REAL_IP}" "${QUERY_STRING}";;
# Needed for CORS preflight
'OPTIONS') "${LIB_DIR}/http_res" 200;;
# Bad request
*) printf 'Invalid HTTP verb' | "${LIB_DIR}/http_res" 405;;
esac && exit 0

0
back/fed.Dockerfile Normal file
View File

0
back/fed.cgi Executable file
View File

0
front/admin.Dockerfile Normal file
View File

0
front/admin.html Normal file
View File

0
front/admin.js Normal file
View File