Última atividade 1 month ago

nuno revisou este gist 1 month ago. Ir para a revisão

1 file changed, 89 insertions

gistfile1.txt(arquivo criado)

@@ -0,0 +1,89 @@
1 + #!/usr/bin/env bash
2 +
3 + # ============================================
4 + # Static Context — resolved once at source time
5 + # ============================================
6 +
7 + _CTX_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8 + _CTX_WG="/etc/wireguard"
9 + _CTX_CORE="${_CTX_ROOT}/core"
10 + _CTX_MODULES="${_CTX_ROOT}/modules"
11 + _CTX_COMMANDS="${_CTX_ROOT}/commands"
12 + _CTX_CLIENTS="${_CTX_WG}/clients"
13 + _CTX_DATA="${_CTX_WG}/.wgctl"
14 +
15 + # ============================================
16 + # Artifacts
17 + # ============================================
18 +
19 + _CTX_RULES="${_CTX_DATA}/rules"
20 + _CTX_RULES_BASE="${_CTX_RULES}/base"
21 + _CTX_GROUPS="${_CTX_DATA}/groups"
22 + _CTX_BLOCKS="${_CTX_DATA}/blocks"
23 + _CTX_META="${_CTX_DATA}/meta"
24 + _CTX_IDENTITY="${_CTX_DATA}/identities"
25 + _CTX_DAEMON="${_CTX_DATA}/daemon"
26 + _CTX_NET="${_CTX_DATA}/services.json"
27 +
28 + # ============================================
29 +
30 + function ctx::root() { echo "$_CTX_ROOT"; }
31 + function ctx::core() { echo "$_CTX_CORE"; }
32 + function ctx::modules() { echo "$_CTX_MODULES"; }
33 + function ctx::commands() { echo "$_CTX_COMMANDS"; }
34 + function ctx::blocks() { echo "$_CTX_BLOCKS"; }
35 + function ctx::groups() { echo "$_CTX_GROUPS"; }
36 + function ctx::rules() { echo "$_CTX_RULES"; }
37 + function ctx::rules::base() { echo "$_CTX_RULES_BASE"; }
38 + function ctx::clients() { echo "$_CTX_CLIENTS"; }
39 + function ctx::wg() { echo "$_CTX_WG"; }
40 + function ctx::data() { echo "$_CTX_DATA"; }
41 + function ctx::rules() { echo "$_CTX_RULES"; }
42 + function ctx::groups() { echo "$_CTX_GROUPS"; }
43 + function ctx::blocks() { echo "$_CTX_BLOCKS"; }
44 + function ctx::meta() { echo "$_CTX_META"; }
45 + function ctx::daemon() { echo "$_CTX_DAEMON"; }
46 + function ctx::net() { echo "$_CTX_NET"; }
47 + function ctx::identities() { echo "${_CTX_IDENTITY}"; }
48 + function ctx::policies() { echo "${_CTX_DATA}/policies.json"; }
49 + function ctx::subnets() { echo "${_CTX_DATA}/subnets.json"; }
50 + function ctx::hosts() { echo "${_CTX_DATA}/hosts.json"; }
51 + function ctx::events_log() { echo "$(ctx::daemon)/events.log"; }
52 + function ctx::fw_events_log() { echo "$(ctx::daemon)/fw_events.log"; }
53 + function ctx::json_helper() { echo "${_CTX_CORE}/json_helper.py"; }
54 + function ctx::monitor_script() { echo "${_CTX_ROOT}/daemon/wgctl-monitor.py"; }
55 + function ctx::endpoint_cache() { echo "${_CTX_DAEMON}/endpoint_cache.json"; }
56 +
57 + # ============================================
58 + # Path Helpers
59 + # ============================================
60 +
61 + function ctx::client::path() {
62 + local IFS="/"
63 + echo "$_CTX_CLIENTS/$*"
64 + }
65 +
66 + function ctx::meta::path() {
67 + local IFS="/"
68 + echo "$_CTX_META/$*"
69 + }
70 +
71 + function ctx::identity::path() {
72 + local IFS="/"
73 + echo "$_CTX_IDENTITY/$*"
74 + }
75 +
76 + function ctx::block::path() {
77 + local IFS="/"
78 + echo "$_CTX_BLOCKS/$*"
79 + }
80 +
81 + function ctx::group::path() {
82 + local IFS="/"
83 + echo "$_CTX_GROUPS/$*"
84 + }
85 +
86 + function ctx::rule::path() {
87 + local IFS="/"
88 + echo "$_CTX_RULES/$*"
89 + }
Próximo Anterior