74 lines
No EOL
2.2 KiB
Bash
74 lines
No EOL
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# ============================================
|
|
# Static Context — resolved once at source time
|
|
# ============================================
|
|
|
|
_CTX_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
_CTX_WG="/etc/wireguard"
|
|
_CTX_CORE="${_CTX_ROOT}/core"
|
|
_CTX_MODULES="${_CTX_ROOT}/modules"
|
|
_CTX_COMMANDS="${_CTX_ROOT}/commands"
|
|
_CTX_CLIENTS="${_CTX_WG}/clients"
|
|
_CTX_DATA="${_CTX_WG}/.wgctl"
|
|
|
|
# ============================================
|
|
# Artifacts
|
|
# ============================================
|
|
|
|
_CTX_RULES="${_CTX_DATA}/rules"
|
|
_CTX_RULES_BASE="${_CTX_RULES}/base"
|
|
_CTX_GROUPS="${_CTX_DATA}/groups"
|
|
_CTX_BLOCKS="${_CTX_DATA}/blocks"
|
|
_CTX_META="${_CTX_DATA}/meta"
|
|
_CTX_DAEMON="${_CTX_DATA}/daemon"
|
|
|
|
# ============================================
|
|
|
|
function ctx::root() { echo "$_CTX_ROOT"; }
|
|
function ctx::core() { echo "$_CTX_CORE"; }
|
|
function ctx::modules() { echo "$_CTX_MODULES"; }
|
|
function ctx::commands() { echo "$_CTX_COMMANDS"; }
|
|
function ctx::blocks() { echo "$_CTX_BLOCKS"; }
|
|
function ctx::groups() { echo "$_CTX_GROUPS"; }
|
|
function ctx::rules() { echo "$_CTX_RULES"; }
|
|
function ctx::rules::base() { echo "$_CTX_RULES_BASE"; }
|
|
function ctx::clients() { echo "$_CTX_CLIENTS"; }
|
|
function ctx::wg() { echo "$_CTX_WG"; }
|
|
function ctx::data() { echo "$_CTX_DATA"; }
|
|
function ctx::rules() { echo "$_CTX_RULES"; }
|
|
function ctx::groups() { echo "$_CTX_GROUPS"; }
|
|
function ctx::blocks() { echo "$_CTX_BLOCKS"; }
|
|
function ctx::meta() { echo "$_CTX_META"; }
|
|
function ctx::daemon() { echo "$_CTX_DAEMON"; }
|
|
function ctx::events_log() { echo "$(ctx::daemon)/events.log"; }
|
|
function ctx::fw_events_log() { echo "$(ctx::daemon)/fw_events.log"; }
|
|
|
|
# ============================================
|
|
# Path Helpers
|
|
# ============================================
|
|
|
|
function ctx::client::path() {
|
|
local IFS="/"
|
|
echo "$_CTX_CLIENTS/$*"
|
|
}
|
|
|
|
function ctx::meta::path() {
|
|
local IFS="/"
|
|
echo "$_CTX_META/$*"
|
|
}
|
|
|
|
function ctx::block::path() {
|
|
local IFS="/"
|
|
echo "$_CTX_BLOCKS/$*"
|
|
}
|
|
|
|
function ctx::group::path() {
|
|
local IFS="/"
|
|
echo "$_CTX_GROUPS/$*"
|
|
}
|
|
|
|
function ctx::rule::path() {
|
|
local IFS="/"
|
|
echo "$_CTX_RULES/$*"
|
|
} |