]> Git [git.vados.ru] :: Repos - Mikrotiks/ros.vados.ru.git/commitdiff
Autocommit in repo: ros.vados.ru, generated by owner: root, in 20:30:02 03.05.2026.
authorvados-dev <192440777+vados-dev@users.noreply.github.com>
Sun, 3 May 2026 17:30:03 +0000 (20:30 +0300)
committervados-dev <192440777+vados-dev@users.noreply.github.com>
Sun, 3 May 2026 17:30:03 +0000 (20:30 +0300)
html/AM-GlobalFunc.rsc
html/certs/Makefile

index 0a65d0421430e930d3260e3e6a9abc74727ac853..0192e934862c350b2da5a0dfbf70b9bdb3036845 100644 (file)
@@ -17,9 +17,9 @@
 :global GlobalFuncReady false;
 
 # Git commit id & info, expected configuration version
-:global CommitId "main/447/d3c4c763";
+:global CommitId "main/448/465d2959";
 :global CommitTAG "unknown";
-:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 20:25:02 03.05.2026.";
+:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 20:30:02 03.05.2026.";
 
 # The variables are received right here.
 :global GlobalConfVersion 138;
index 740711c6deaf975ec63e0696aaa6f97598ac0397..dacdcef05cf8d851c28ad157aca8b5603584d807 100644 (file)
@@ -1,4 +1,4 @@
-# Makefile to download and check certificates
+# Makefile to download, check, and clean certificates
 
 SHELL := /bin/bash
 BUILD_DIR := $(CURDIR)
@@ -13,6 +13,7 @@ LIST_DIRS := $(filter-out $(LIST_ROOT)/Makefile.%,$(wildcard $(LIST_ROOT)/*))
 DIR_TARGETS := $(notdir $(LIST_DIRS))
 TARGETS := $(sort $(FILE_TARGETS) $(DIR_TARGETS))
 CHECK_TARGETS := $(addprefix check-,$(TARGETS))
+CLEAN_TARGETS := $(addprefix clean-,$(TARGETS))
 
 # Big CA list with all certificates ~ 2Mb
 ALL_CA_URL := https://curl.se/ca/cacert.pem
@@ -26,18 +27,22 @@ CURL := curl \
        --silent \
        --show-error
 
-.PHONY: default all all-ca-lst download-list check-list $(TARGETS) $(CHECK_TARGETS)
+.PHONY: default all clean all-ca-lst download-list check-list clean-list $(TARGETS) $(CHECK_TARGETS) $(CLEAN_TARGETS)
 
 default:
        @echo "Available download targets: all-ca-lst $(TARGETS)"
        @echo "Available check targets: $(CHECK_TARGETS)"
+       @echo "Available clean targets: clean $(CLEAN_TARGETS)"
        @echo "all downloads all-ca-lst and certificates from all list targets"
+       @echo "clean checks all target directories and removes unavailable PEM files"
        @echo "List format: [scheme://]host[/path/to/generator]/certificate-basename"
        @echo "Example: example.com/pki/acme/ISRG-Root-X1 downloads https://example.com/pki/acme/ISRG-Root-X1.pem -> ./<target>/ISRG-Root-X1.pem"
-       @echo "check target verifies https://example.com/pki/acme/ with ./<target>/ISRG-Root-X1.pem"
+       @echo "check/clean verify https://example.com/pki/acme/ with ./<target>/ISRG-Root-X1.pem"
 
 all: all-ca-lst $(TARGETS)
 
+clean: $(CLEAN_TARGETS)
+
 all-ca-lst:
        @mkdir -p $(CA_LIST_DIR)
        @echo "Downloading $(ALL_CA_URL) -> $(ALL_CA_FILE)"
@@ -54,11 +59,14 @@ $(DIR_TARGETS): %: $(LIST_ROOT)/%
 $(CHECK_TARGETS): check-%:
        @$(MAKE) check-list LIST="$(call list_for_target,$*)" OUT_DIR="$*"
 
+$(CLEAN_TARGETS): clean-%:
+       @$(MAKE) clean-list LIST="$(call list_for_target,$*)" OUT_DIR="$*"
+
 list_for_target = $(if $(wildcard $(LIST_ROOT)/Makefile.$(1)),$(LIST_ROOT)/Makefile.$(1),$(LIST_ROOT)/$(1))
 
 # Convert a list item to URL/cert in shell:
 #   host/path/cert-name -> https://host/path/cert-name.pem for download
-#   host/path/cert-name -> https://host/path/ for check
+#   host/path/cert-name -> https://host/path/ for check/clean
 # IPv6 colons may be escaped as \: for make compatibility and are normalized here.
 download-list:
        @test -n "$(LIST)" || { echo "LIST is required" >&2; exit 2; }
@@ -101,3 +109,31 @@ check-list:
                done < "$$list"; \
        done; \
        true
+
+clean-list:
+       @test -n "$(LIST)" || { echo "LIST is required" >&2; exit 2; }
+       @test -n "$(OUT_DIR)" || { echo "OUT_DIR is required" >&2; exit 2; }
+       @if [ -d "$(LIST)" ]; then inputs=("$(LIST)"/*); else inputs=("$(LIST)"); fi; \
+       for list in "$${inputs[@]}"; do \
+               [ -f "$$list" ] || continue; \
+               while IFS= read -r item || [ -n "$$item" ]; do \
+                       [[ -z "$$item" || "$$item" =~ ^[[:space:]]*# ]] && continue; \
+                       item="$${item//\\:/:}"; \
+                       cert="$${item##*/}"; \
+                       url="$${item%/*}/"; \
+                       [[ "$$url" =~ ^https?:// ]] || url="https://$$url"; \
+                       pem="$(BUILD_DIR)/$(OUT_DIR)/$$cert.pem"; \
+                       if [ ! -f "$$pem" ]; then \
+                               echo "WARN: missing $$pem" >&2; \
+                               continue; \
+                       fi; \
+                       printf 'Cleaning check %s with %s\n' "$$url" "$$pem"; \
+                       if $(CURL) --output /dev/null --cacert "$$pem" "$$url"; then \
+                               echo "KEEP: $$pem"; \
+                       else \
+                               echo "REMOVE: $$pem"; \
+                               rm -f -- "$$pem"; \
+                       fi; \
+               done < "$$list"; \
+       done; \
+       true