Skip to content

Commit

Permalink
Move to new directory layout
Browse files Browse the repository at this point in the history
  • Loading branch information
dubo-dubon-duponey committed Mar 20, 2024
1 parent 95426ab commit fc549a7
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 24 deletions.
28 changes: 18 additions & 10 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,22 @@ Be sure to run `./hack/lint.sh` and `./hack/test.sh` before submitting anything.
* no write
* no cap
* use the provided infrastructure
* runnable artifacts go to:
* `/boot/bin` (read-only)
* configuration should be read from:
* `/config` (read-only)
* certificates should go to:
* `/certs` (either read-only or read-write)
* persistent application data should use:
* `/data` (usually read-write)
* volatile data should use:
* `/tmp` (usually read-write)
* runnable artifacts go to:
* `/boot/bin` (read-only)
* configuration should be read from:
* `/magnetar/system/config` (read-only)
* and:
* `/magnetar/user/config` (read-write, user controlled)
* certificates should go to:
* `/magnetar/user/data` (either read-only or read-write)
* or:
* `/magnetar/system/data` (read-only)
* persistent application data should use:
* `/magnerar/system/data` (usually read-only)
* runtime data (socket, pipes) should use:
* `/magnerar/runtime`
* temp data (logs, states, etc) should use:
* `/magnerar/state`
* cache should use:
* `/magnerar/cache`
* only use chroot to downgrade if you really REALLY need to start your entrypoint with "root"
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ EXPOSE $DNS_OVER_TLS_LEGO_PORT/tcp
#EXPOSE $DNS_OVER_GRPC_PORT/tcp
EXPOSE $MOD_METRICS_BIND/tcp

# Lego just needs /certs to work
VOLUME /certs
# Lego just needs certs to work
VOLUME "$XDG_DATA_HOME"

ENV HEALTHCHECK_URL="127.0.0.1:$DNS_PORT"
ENV HEALTHCHECK_QUESTION=dns.autonomous.healthcheck.farcloser.world
Expand Down
10 changes: 5 additions & 5 deletions context/runtime/boot/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ readonly root
# shellcheck source=/dev/null
. "$root/helpers.sh"

helpers::dir::writable /certs
helpers::dir::writable "$XDG_DATA_HOME"

LOG_LEVEL=${LOG_LEVEL:-}

Expand Down Expand Up @@ -43,17 +43,17 @@ certs::renew(){
&& staging= \
|| staging="--server=https://acme-staging-v02.api.letsencrypt.org/directory"

[ -e "/certs/certificates/$domain.key" ] || command="run"
[ -e "$XDG_DATA_HOME/certificates/$domain.key" ] || command="run"

printf >&2 "Running command: %s" "lego --domains=\"$domain\" \
--accept-tos --email=\"$email\" --path=/certs --tls $staging --pem \
--accept-tos --email=\"$email\" --path=\"$XDG_DATA_HOME\" --tls $staging --pem \
--tls.port=:$port \
${command}"

lego --domains="$domain" \
--accept-tos \
--email="$email" \
--path=/certs \
--path="$XDG_DATA_HOME" \
--tls $staging --pem \
--tls.port=:"$port" \
${command}
Expand Down Expand Up @@ -84,7 +84,7 @@ fi
[ "$DNS_FORWARD_ENABLED" == true ] && mode=forward || mode=recursive
[ "$DNS_STUFF_MDNS" == true ] && with_mdns=+mdns || with_mdns=

args=(-conf "/config/coredns-${mode}${with_tls}${with_mdns}.conf")
args=(-conf "$XDG_CONFIG_DIRS/coredns-${mode}${with_tls}${with_mdns}.conf")

normalized_log_level="$(printf "%s" "$LOG_LEVEL" | tr '[:upper:]' '[:lower:]')"
[ "$normalized_log_level" != "error" ] && [ "$normalized_log_level" != "warning" ] || args+=(-quiet)
Expand Down
8 changes: 3 additions & 5 deletions context/runtime/boot/mdns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mdns::start::avahi(){
[ "$LOG_LEVEL" != "debug" ] || args+=(--debug)

# -D/--daemonize implies -s/--syslog that we do not want, so, just background it
avahi-daemon -f /config/avahi/main.conf --no-drop-root --no-chroot "${args[@]}" &
avahi-daemon -f "$XDG_CONFIG_DIRS"/avahi/main.conf --no-drop-root --no-chroot "${args[@]}" &

local tries=1
# Wait until the socket is there
Expand All @@ -109,11 +109,9 @@ mdns::start::dbus(){
# https://man7.org/linux/man-pages/man3/sd_bus_default.3.html
# https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html

# $XDG_RUNTIME_DIR=/tmp/runtime
local dbussocket=/magnetar/runtime/dbus/system_bus_socket
# Configuration file also has that ^ hardcoded, so, cannot use the variable...

local dbussocket=/tmp/runtime/dbus/system_bus_socket

# Ensure directory exists
helpers::dir::writable "$(dirname "$dbussocket")" create

Expand All @@ -122,7 +120,7 @@ mdns::start::dbus(){
export DBUS_SESSION_BUS_ADDRESS=unix:path="$dbussocket"

# Start it, without a PID file
dbus-daemon --nopidfile --config-file /config/dbus/main.conf
dbus-daemon --nopidfile --config-file "$XDG_CONFIG_DIRS"/dbus/main.conf

local tries=1
# Wait until the socket is there
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tls://.:{$DNS_OVER_TLS_PORT} {
tls /certs/certificates/{$DOMAIN}.crt /certs/certificates/{$DOMAIN}.key /certs/certificates/{$DOMAIN}.issuer.crt
tls {$XDG_DATA_HOME}/certificates/{$DOMAIN}.crt {$XDG_DATA_HOME}/certificates/{$DOMAIN}.key {$XDG_DATA_HOME}/certificates/{$DOMAIN}.issuer.crt

import snips/hosts.conf
import snips/forward.conf
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tls://.:{$DNS_OVER_TLS_PORT} {
tls /certs/certificates/{$DNS_OVER_TLS_DOMAIN}.crt /certs/certificates/{$DNS_OVER_TLS_DOMAIN}.key /certs/certificates/{$DNS_OVER_TLS_DOMAIN}.issuer.crt
tls {$XDG_DATA_HOME}/certificates/{$DNS_OVER_TLS_DOMAIN}.crt {$XDG_DATA_HOME}/certificates/{$DNS_OVER_TLS_DOMAIN}.key {$XDG_DATA_HOME}/certificates/{$DNS_OVER_TLS_DOMAIN}.issuer.crt

import snips/hosts.conf
import snips/recursive.conf
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit fc549a7

Please sign in to comment.