From f799ad2612391aa08c9de3858b8d3d9a3e24d80f Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Tue, 6 Jul 2021 21:40:43 +0200 Subject: [PATCH] Add FreeRadius container (#675) * Add radius container with logic to automatically add config * fix typo * donnot define a user * whoops * try adding goss * switch to udp --- containers/apps/freeradius/BASE | 1 + containers/apps/freeradius/Dockerfile | 16 ++++++++++ containers/apps/freeradius/VERSION | 1 + containers/apps/freeradius/entrypoint.sh | 31 ++++++++++++++++++++ containers/apps/freeradius/goss.yaml | 5 ++++ containers/apps/freeradius/latest-base.sh | 2 ++ containers/apps/freeradius/latest-version.sh | 6 ++++ 7 files changed, 62 insertions(+) create mode 100644 containers/apps/freeradius/BASE create mode 100644 containers/apps/freeradius/Dockerfile create mode 100644 containers/apps/freeradius/VERSION create mode 100644 containers/apps/freeradius/entrypoint.sh create mode 100644 containers/apps/freeradius/goss.yaml create mode 100644 containers/apps/freeradius/latest-base.sh create mode 100644 containers/apps/freeradius/latest-version.sh diff --git a/containers/apps/freeradius/BASE b/containers/apps/freeradius/BASE new file mode 100644 index 00000000000..4b9ea582122 --- /dev/null +++ b/containers/apps/freeradius/BASE @@ -0,0 +1 @@ +focal-20210609 diff --git a/containers/apps/freeradius/Dockerfile b/containers/apps/freeradius/Dockerfile new file mode 100644 index 00000000000..b25b6e89442 --- /dev/null +++ b/containers/apps/freeradius/Dockerfile @@ -0,0 +1,16 @@ +ARG TARGETPLATFORM +ARG VERSION +# hadolint ignore=DL3007 +FROM freeradius/freeradius-server:${VERSION} + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# hadolint ignore=DL3008,DL3015,SC2086,SC2155 +RUN \ + mkdir -p /defaults/raddb/ && \ + cp -Rf /etc/raddb/* /defaults/raddb/ + +COPY ./containers/apps/freeradius/entrypoint.sh /entrypoint.sh + +LABEL "maintainer"="TrueCharts " +LABEL "org.opencontainers.image.source"="https://github.com/truecharts/apps" diff --git a/containers/apps/freeradius/VERSION b/containers/apps/freeradius/VERSION new file mode 100644 index 00000000000..148fd54484e --- /dev/null +++ b/containers/apps/freeradius/VERSION @@ -0,0 +1 @@ +3.0.23 diff --git a/containers/apps/freeradius/entrypoint.sh b/containers/apps/freeradius/entrypoint.sh new file mode 100644 index 00000000000..6c4a6db3e06 --- /dev/null +++ b/containers/apps/freeradius/entrypoint.sh @@ -0,0 +1,31 @@ +#!/bin/sh +set -e + +if [ -f "/etc/raddb/clients.conf" ]; then + echo "Radius config already exists, skipping config copy..." +else + echo "Radius config does not exist copying..." + cp -Rf /defaults/raddb/* /etc/raddb/ +fi + +# this if will check if the first argument is a flag +# but only works if all arguments require a hyphenated flag +# -v; -SL; -f arg; etc will work, but not arg1 arg2 +if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then + set -- freeradius "$@" +fi + +# check for the expected command +if [ "$1" = 'freeradius' ]; then + shift + exec freeradius -f "$@" +fi + +# many people are likely to call "radiusd" as well, so allow that +if [ "$1" = 'radiusd' ]; then + shift + exec freeradius -f "$@" +fi + +# else default to run whatever the user wanted like "bash" or "sh" +exec "$@" diff --git a/containers/apps/freeradius/goss.yaml b/containers/apps/freeradius/goss.yaml new file mode 100644 index 00000000000..229e594f292 --- /dev/null +++ b/containers/apps/freeradius/goss.yaml @@ -0,0 +1,5 @@ +--- + +port: + udp:1812: + listening: true diff --git a/containers/apps/freeradius/latest-base.sh b/containers/apps/freeradius/latest-base.sh new file mode 100644 index 00000000000..cee4f14a2ce --- /dev/null +++ b/containers/apps/freeradius/latest-base.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +cat "./containers/base/ubuntu/VERSION" diff --git a/containers/apps/freeradius/latest-version.sh b/containers/apps/freeradius/latest-version.sh new file mode 100644 index 00000000000..83001f37605 --- /dev/null +++ b/containers/apps/freeradius/latest-version.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +version=$(curl "https://registry.hub.docker.com/v1/repositories/freeradius/freeradius-server/tags" | jq --raw-output '.[].name' | grep -v layer | grep -v alpine | grep -v latest | tail -n1) +version="${version#*v}" +version="${version#*release-}" +echo "${version}"