readme refreshed

This commit is contained in:
2026-02-05 08:50:11 +01:00
parent 1de7f5b593
commit 14b770af55
15 changed files with 1453 additions and 27 deletions
+35 -2
View File
@@ -63,6 +63,34 @@ fetch_active_servers() {
curl -sf "$API_URL/vpn-servers/active" 2>/dev/null || echo "[]"
}
# =============================================================================
# Fetch CCD files for a server
# =============================================================================
fetch_ccd_files() {
local server_id="$1"
local ccd_dir="$2"
log " Fetching CCD files for server $server_id..."
# Get all CCD files from API
local ccd_json
ccd_json=$(curl -sf "$API_URL/vpn-servers/$server_id/ccd" 2>/dev/null || echo '{"files":{}}')
# Parse and create CCD files
echo "$ccd_json" | jq -r '.files | to_entries[] | @base64' | while read -r entry; do
local cn=$(echo "$entry" | base64 -d | jq -r '.key')
local content=$(echo "$entry" | base64 -d | jq -r '.value')
if [ -n "$cn" ] && [ "$cn" != "null" ]; then
echo "$content" > "$ccd_dir/$cn"
log " Created CCD file: $cn"
fi
done
local count=$(echo "$ccd_json" | jq -r '.count // 0')
log " Fetched $count CCD files"
}
# =============================================================================
# Setup a single VPN server
# =============================================================================
@@ -120,8 +148,9 @@ setup_server() {
# CRL
curl -sf "$API_URL/vpn-servers/$server_id/crl" > "$server_dir/crl.pem" 2>/dev/null || true
# Create client-config directory
# Create client-config directory and fetch CCD files
mkdir -p "$server_dir/ccd"
fetch_ccd_files "$server_id" "$server_dir/ccd"
# Create status file location
touch "$RUN_DIR/openvpn-$server_id.status"
@@ -263,12 +292,16 @@ poll_for_changes() {
fi
done
# Update CRL for all running servers
# Update CRL and CCD files for all running servers
for id in $api_server_ids; do
if [ -d "$SERVERS_DIR/$id" ]; then
# Update CRL
curl -sf "$API_URL/vpn-servers/$id/crl" > "$SERVERS_DIR/$id/crl.pem.new" 2>/dev/null && \
mv "$SERVERS_DIR/$id/crl.pem.new" "$SERVERS_DIR/$id/crl.pem" || \
rm -f "$SERVERS_DIR/$id/crl.pem.new"
# Update CCD files (gateway routes)
fetch_ccd_files "$id" "$SERVERS_DIR/$id/ccd"
fi
done
}