Last active
July 20, 2023 20:18
-
-
Save johnmaguire/9f305b5ac23ede90f45e68b1123d65e4 to your computer and use it in GitHub Desktop.
Revisions
-
johnmaguire revised this gist
Jul 20, 2023 . 3 changed files with 9 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,10 @@ FROM alpine:3 RUN apk add --update \ curl \ jq RUN curl -o /usr/local/bin/dnclient $(curl https://api.defined.net/v1/downloads | jq -r '.data.dnclient.latest."linux-amd64"') && \ chmod +x /usr/local/bin/dnclient VOLUME ["/etc/defined"] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,11 @@ FROM debian:11 RUN apt-get update && apt-get install -y \ curl \ jq RUN curl -o /usr/local/bin/dnclient $(curl https://api.defined.net/v1/downloads | jq -r '.data.dnclient.latest."linux-amd64"') && \ chmod +x /usr/local/bin/dnclient VOLUME ["/etc/defined"] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ HOST_CONFIG="/etc/defined/dnclient.yml" CONTROL_SOCKET="/var/run/dnclient.sock" dnclient run -server "${DN_API_SERVER:-https://api.defined.net}" & for i in $(seq 1 11); do if [ -S "$CONTROL_SOCKET" ]; then -
johnmaguire revised this gist
Mar 16, 2023 . 2 changed files with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ docker run \ --network host \ --volume defined:/etc/defined \ --volume /dev/net/tun:/dev/net/tun \ --env DN_ENROLLMENT_CODE="insert code here" \ --rm \ dnclient ``` @@ -38,4 +38,4 @@ A few notes: - The `NET_ADMIN` capability and `/dev/net/tun` volume are necessary to create the tun adapter on the host. - `--volume defined:/etc/defined` will persist the config to a named volume across runs. - `--env DN_ENROLLMENT_CODE="insert code here"` is necessary only for the first run. Get an enrollment code from https://admin.defined.net This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ HOST_CONFIG="/etc/defined/dnclient.yml" CONTROL_SOCKET="/var/run/dnclient.sock" dnclient run -server "$DN_API_SERVER" & for i in $(seq 1 11); do if [ -S "$CONTROL_SOCKET" ]; then @@ -20,12 +20,12 @@ for i in $(seq 1 11); do done if [ ! -f "$HOST_CONFIG" ]; then if [ -z "$DN_ENROLLMENT_CODE" ]; then echo "Please provide an enrollment code using the DN_ENROLLMENT_CODE environment variable." exit 1 fi if ! dnclient enroll -code "$DN_ENROLLMENT_CODE"; then echo "Enrollment failed." exit 1 else -
johnmaguire revised this gist
Mar 15, 2023 . 2 changed files with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,4 +8,6 @@ RUN curl -o /usr/local/bin/dnclient https://dl.defined.net/02c6d0f9/v0.1.9/linux VOLUME ["/etc/defined"] COPY main.sh /main.sh RUN chmod +x /main.sh CMD ["/main.sh"] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,4 +9,6 @@ RUN curl -o /usr/local/bin/dnclient https://dl.defined.net/02c6d0f9/v0.1.9/linux VOLUME ["/etc/defined"] COPY main.sh /main.sh RUN chmod +x /main.sh CMD ["/main.sh"] -
johnmaguire revised this gist
Mar 15, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Building ## Alpine-based image ``` docker build . \ -
johnmaguire revised this gist
Mar 15, 2023 . 1 changed file with 18 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,26 @@ # Building ## Alpine-based iamge ``` docker build . \ --file alpine.Dockerfile \ --tag "dnclient:alpine-latest" \ --tag "dnclient:latest" ``` ## Debian-based image ``` docker build . \ --file debian.Dockerfile \ --tag "dnclient:debian-latest" \ --tag "dnclient:latest" ``` # Running To run the built image, use the following command: ``` docker run \ -
johnmaguire revised this gist
Mar 15, 2023 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,14 +7,14 @@ To build a Docker image, run `docker build . --file alpine.Dockerfile --tag "dnc To run the image, use the following: ``` docker run \ --name dnclient \ --cap-add NET_ADMIN \ --network host \ --volume defined:/etc/defined \ --volume /dev/net/tun:/dev/net/tun \ --env ENROLLMENT_CODE="insert code here" \ --rm \ dnclient ``` -
johnmaguire created this gist
Mar 15, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ # Building To build a Docker image, run `docker build . --file alpine.Dockerfile --tag "dnclient:alpine-latest"` or `docker build . --file debian.Dockerfile --tag "dnclient:debian-latest"` # Running To run the image, use the following: ``` docker run --name dnclient --cap-add NET_ADMIN --network host --volume defined:/etc/defined --volume /dev/net/tun:/dev/net/tun --env ENROLLMENT_CODE="insert code here" --rm dnclient ``` A few notes: - The `NET_ADMIN` capability and `/dev/net/tun` volume are necessary to create the tun adapter on the host. - `--volume defined:/etc/defined` will persist the config to a named volume across runs. - `--env ENROLLMENT_CODE="insert code here"` is necessary only for the first run. Get an enrollment code from https://admin.defined.net This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ FROM alpine:3 RUN apk add --update curl RUN curl -o /usr/local/bin/dnclient https://dl.defined.net/02c6d0f9/v0.1.9/linux/amd64/dnclient && \ chmod +x /usr/local/bin/dnclient VOLUME ["/etc/defined"] COPY main.sh /main.sh CMD ["/main.sh"] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ FROM debian:11 RUN apt-get update && apt-get install -y \ curl RUN curl -o /usr/local/bin/dnclient https://dl.defined.net/02c6d0f9/v0.1.9/linux/amd64/dnclient && \ chmod +x /usr/local/bin/dnclient VOLUME ["/etc/defined"] COPY main.sh /main.sh CMD ["/main.sh"] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ #!/bin/sh HOST_CONFIG="/etc/defined/dnclient.yml" CONTROL_SOCKET="/var/run/dnclient.sock" dnclient run & for i in $(seq 1 11); do if [ -S "$CONTROL_SOCKET" ]; then break fi if [ "$i" -eq 11 ]; then echo "Timed out." exit 1 fi echo "Waiting for dnclient $CONTROL_SOCKET ($i/10)..." sleep 1 done if [ ! -f "$HOST_CONFIG" ]; then if [ -z "$ENROLLMENT_CODE" ]; then echo "Please provide an enrollment code using the ENROLLMENT_CODE environment variable." exit 1 fi if ! dnclient enroll -code "$ENROLLMENT_CODE"; then echo "Enrollment failed." exit 1 else echo "Enrollment complete." fi fi wait