From 587b3d02e162156cb6a75bef3c36503bda320163 Mon Sep 17 00:00:00 2001 From: WeeXnes Date: Sun, 22 Sep 2024 22:29:27 +0200 Subject: [PATCH] initial commit --- Dockerfile | 23 +++++++++++++++++++++++ config.yaml | 24 ++++++++++++++++++++++++ run.sh | 25 +++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 Dockerfile create mode 100644 config.yaml create mode 100644 run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..deee967 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +ARG BUILD_FROM +FROM $BUILD_FROM + +RUN apk add --no-cache curl + +# Download FRP +RUN curl -L https://github.com/fatedier/frp/releases/download/v0.60.0/frp_0.60.0_linux_amd64.tar.gz -o frp.tar.gz + +# Extract the downloaded tar.gz file +RUN tar -zxvf frp.tar.gz + +# Move the FRPC binary to the desired location +RUN mv frp_0.60.0_linux_amd64/frpc /usr/local/bin/ + +# Clean up by removing unnecessary files +RUN rm -rf frp.tar.gz frp_0.60.0_linux_amd64 + + +# Copy data for add-on +COPY run.sh / +RUN chmod a+x /run.sh + +CMD [ "/run.sh" ] \ No newline at end of file diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..8c17ef4 --- /dev/null +++ b/config.yaml @@ -0,0 +1,24 @@ +name: "FRP (Fast Reverse Proxy)" +description: "Expose internal services (like Home Assistant) securely to the internet using FRP" +version: "0.60.0" +slug: "frp" +init: false +arch: + - amd64 +network: + mode: host +options: + server_addr: "" + server_port: 2113 + token: "" + local_ip: "" + local_port: 8123 + remote_port: 8123 + +schema: + server_addr: str + server_port: int + token: str + local_ip: str + local_port: int + remote_port: int \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..2afef33 --- /dev/null +++ b/run.sh @@ -0,0 +1,25 @@ +#!/usr/bin/with-contenv bashio + +server_addr=$(bashio::config 'server_addr') +server_port=$(bashio::config 'server_port') +token=$(bashio::config 'token') +local_ip=$(bashio::config 'local_ip') +local_port=$(bashio::config 'local_port') +remote_port=$(bashio::config 'remote_port') + +# Create FRP configuration file +echo "[common]" > /etc/frpc.ini +echo "server_addr = ${server_addr}" >> /etc/frpc.ini +echo "server_port = ${server_port}" >> /etc/frpc.ini +echo "token = ${token}" >> /etc/frpc.ini + +echo "[ha_dashboard]" >> /etc/frpc.ini +echo "type = tcp" >> /etc/frpc.ini +echo "local_ip = ${local_ip}" >> /etc/frpc.ini +echo "local_port = ${local_port}" >> /etc/frpc.ini +echo "remote_port = ${remote_port}" >> /etc/frpc.ini + +echo "--------------- FRP Configuration (frpc.ini): -----------------------" +cat /etc/frpc.ini +echo "Starting FRP Service..." +/usr/local/bin/frpc -c /etc/frpc.ini \ No newline at end of file