fix: корректный make status при inactive и без -o

systemctl is-active с rc≠0 больше не дублирует inactive;
убран deprecated флаг -o.
This commit is contained in:
Sergey Antropoff
2026-07-23 08:46:17 +03:00
parent 062512121d
commit 100e3cee12
+6 -4
View File
@@ -72,19 +72,21 @@ ping: ## Проверить SSH-доступ ко всем VPS
$(ANSIBLE_ADHOC) hysteria2_servers -m ping $(ANSIBLE_OPTS) $(ANSIBLE_ADHOC) hysteria2_servers -m ping $(ANSIBLE_OPTS)
status: ## Краткий статус hysteria-server на VPS status: ## Краткий статус hysteria-server на VPS
@$(ANSIBLE_ADHOC) hysteria2_servers -m shell \ @ANSIBLE_DEPRECATION_WARNINGS=False ANSIBLE_STDOUT_CALLBACK=minimal \
$(ANSIBLE_ADHOC) hysteria2_servers -m shell \
-a 'UNIT=""; \ -a 'UNIT=""; \
if systemctl cat hysteria-server.service >/dev/null 2>&1; then UNIT=hysteria-server; \ if systemctl cat hysteria-server.service >/dev/null 2>&1; then UNIT=hysteria-server; \
elif systemctl cat hysteria2.service >/dev/null 2>&1; then UNIT=hysteria2; fi; \ elif systemctl cat hysteria2.service >/dev/null 2>&1; then UNIT=hysteria2; fi; \
if [ -z "$$UNIT" ]; then echo "not installed"; exit 0; fi; \ if [ -z "$$UNIT" ]; then echo "not installed"; exit 0; fi; \
STATE=$$(systemctl is-active "$$UNIT" 2>/dev/null || echo inactive); \ STATE=$$(systemctl is-active "$$UNIT" 2>/dev/null || true); \
[ -n "$$STATE" ] || STATE=inactive; \
SINCE=$$(systemctl show -p ActiveEnterTimestamp --value "$$UNIT" 2>/dev/null); \ SINCE=$$(systemctl show -p ActiveEnterTimestamp --value "$$UNIT" 2>/dev/null); \
PID=$$(systemctl show -p MainPID --value "$$UNIT" 2>/dev/null); \ PID=$$(systemctl show -p MainPID --value "$$UNIT" 2>/dev/null); \
MEM=$$(systemctl show -p MemoryCurrent --value "$$UNIT" 2>/dev/null); \ MEM=$$(systemctl show -p MemoryCurrent --value "$$UNIT" 2>/dev/null); \
case "$$MEM" in ""|"[not set]"|"0") MEM="-";; *) MEM="$$((MEM/1024/1024))M";; esac; \ case "$$MEM" in ""|"[not set]"|"0"|"n/a") MEM="-";; *) MEM="$$((MEM/1024/1024))M";; esac; \
echo "$$UNIT: $$STATE | since $$SINCE | PID $$PID | RAM $$MEM"; \ echo "$$UNIT: $$STATE | since $$SINCE | PID $$PID | RAM $$MEM"; \
[ "$$STATE" = "active" ]' \ [ "$$STATE" = "active" ]' \
-b -o $(ANSIBLE_OPTS) -b $(ANSIBLE_OPTS)
install: check ## Установить Hysteria2 на VPS (+ URL и QR локально) install: check ## Установить Hysteria2 на VPS (+ URL и QR локально)
$(ANSIBLE) playbook.yml --tags install $(ANSIBLE_OPTS) $(ANSIBLE) playbook.yml --tags install $(ANSIBLE_OPTS)