devzone 0.23.3 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Sortie machine de devzone agent etat (--json) : sessions, écarts, alertes droits.
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
6
|
+
while [ -L "$SOURCE" ]; do
|
|
7
|
+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
8
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
9
|
+
case "$SOURCE" in
|
|
10
|
+
/*) ;;
|
|
11
|
+
*) SOURCE="$DIR/$SOURCE" ;;
|
|
12
|
+
esac
|
|
13
|
+
done
|
|
14
|
+
ICI="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
15
|
+
RACINE="${DEVZONE_RACINE:-$(dirname "$ICI")}"
|
|
16
|
+
|
|
17
|
+
# shellcheck source=agent-erreurs.sh
|
|
18
|
+
# shellcheck disable=SC1091
|
|
19
|
+
. "$ICI/agent-erreurs.sh"
|
|
20
|
+
# shellcheck source=agent-droits.sh
|
|
21
|
+
# shellcheck disable=SC1091
|
|
22
|
+
. "$ICI/agent-droits.sh"
|
|
23
|
+
# shellcheck source=agent-session.sh
|
|
24
|
+
# shellcheck disable=SC1091
|
|
25
|
+
. "$ICI/agent-session.sh"
|
|
26
|
+
|
|
27
|
+
AGENT_ETAT="${DEVZONE_AGENT_ETAT:-$HOME/.local/state/oc-lancer}"
|
|
28
|
+
|
|
29
|
+
# Date UTC ISO-8601 d'une époque, GNU puis BSD date : champ `fin` des écarts.
|
|
30
|
+
iso() {
|
|
31
|
+
if date -u -d "@$1" '+%Y-%m-%dT%H:%M:%SZ' >/dev/null 2>&1; then
|
|
32
|
+
date -u -d "@$1" '+%Y-%m-%dT%H:%M:%SZ'
|
|
33
|
+
else
|
|
34
|
+
date -u -r "$1" '+%Y-%m-%dT%H:%M:%SZ'
|
|
35
|
+
fi
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# État des sessions d'agent en JSON : réutilise les données d'agent_etat,
|
|
39
|
+
# agent_ecarts et droits_alertes, sans recopier leur logique.
|
|
40
|
+
agent_etat_json() {
|
|
41
|
+
local sessions_json='[]' ecarts_json='[]' alertes_json='[]'
|
|
42
|
+
local f journal modele debut dernier project en_cours
|
|
43
|
+
local e cause d fin fin_iso maintenant
|
|
44
|
+
|
|
45
|
+
for f in "$RACINE"/workspace/.agents/*.log; do
|
|
46
|
+
[ -e "$f" ] || continue
|
|
47
|
+
journal="$(basename "$f")"
|
|
48
|
+
session_modele_debut "$f"
|
|
49
|
+
modele="$MODELE_SESSION"
|
|
50
|
+
[ -n "$modele" ] || modele="inconnu"
|
|
51
|
+
debut="$DEBUT_SESSION"
|
|
52
|
+
dernier="$(heure "$(mtime "$f")")"
|
|
53
|
+
project="${journal%.log}"
|
|
54
|
+
en_cours=false
|
|
55
|
+
if session_en_cours "$project"; then en_cours=true; fi
|
|
56
|
+
sessions_json="$(jq -c \
|
|
57
|
+
--arg journal "$journal" \
|
|
58
|
+
--arg modele "$modele" \
|
|
59
|
+
--arg debut "$debut" \
|
|
60
|
+
--arg dernier "$dernier" \
|
|
61
|
+
--argjson en_cours "$en_cours" \
|
|
62
|
+
'. + [{journal:$journal,modele:$modele,debut:(if $debut=="" then null else $debut end),dernier_ecrit:(if $dernier=="" then null else $dernier end),en_cours:$en_cours}]' \
|
|
63
|
+
<<<"$sessions_json")"
|
|
64
|
+
done
|
|
65
|
+
|
|
66
|
+
maintenant="$(date +%s)"
|
|
67
|
+
for f in "$AGENT_ETAT"/ecart-*; do
|
|
68
|
+
[ -e "$f" ] || continue
|
|
69
|
+
modele="${f##*/ecart-}"
|
|
70
|
+
read -r e cause d <<<"$(cat "$f" 2>/dev/null || true)"
|
|
71
|
+
[ -n "$e" ] || continue
|
|
72
|
+
fin=$(( e + ${d:-3600} ))
|
|
73
|
+
[ "$maintenant" -lt "$fin" ] || continue
|
|
74
|
+
fin_iso="$(iso "$fin")"
|
|
75
|
+
ecarts_json="$(jq -c \
|
|
76
|
+
--arg modele "$modele" \
|
|
77
|
+
--arg cause "${cause:-autre}" \
|
|
78
|
+
--arg fin "$fin_iso" \
|
|
79
|
+
'. + [{modele:$modele,cause:$cause,fin:$fin}]' \
|
|
80
|
+
<<<"$ecarts_json")"
|
|
81
|
+
done
|
|
82
|
+
for f in "$AGENT_ETAT"/muet-*; do
|
|
83
|
+
[ -e "$f" ] || continue
|
|
84
|
+
modele="${f##*/muet-}"
|
|
85
|
+
e="$(cat "$f" 2>/dev/null || true)"
|
|
86
|
+
[ -n "$e" ] || continue
|
|
87
|
+
fin=$(( e + 3600 ))
|
|
88
|
+
[ "$maintenant" -lt "$fin" ] || continue
|
|
89
|
+
fin_iso="$(iso "$fin")"
|
|
90
|
+
ecarts_json="$(jq -c \
|
|
91
|
+
--arg modele "$modele" \
|
|
92
|
+
--arg cause "muet" \
|
|
93
|
+
--arg fin "$fin_iso" \
|
|
94
|
+
'. + [{modele:$modele,cause:$cause,fin:$fin}]' \
|
|
95
|
+
<<<"$ecarts_json")"
|
|
96
|
+
done
|
|
97
|
+
|
|
98
|
+
for f in "$AGENT_ETAT"/droits-*.alerte; do
|
|
99
|
+
[ -e "$f" ] || continue
|
|
100
|
+
name="${f##*/droits-}"
|
|
101
|
+
name="${name%.alerte}"
|
|
102
|
+
alertes_json="$(jq -c --arg n "$name" '. + [$n]' <<<"$alertes_json")"
|
|
103
|
+
done
|
|
104
|
+
|
|
105
|
+
jq -n \
|
|
106
|
+
--argjson schema 1 \
|
|
107
|
+
--argjson sessions "$sessions_json" \
|
|
108
|
+
--argjson ecarts "$ecarts_json" \
|
|
109
|
+
--argjson alertes "$alertes_json" \
|
|
110
|
+
'{schema:$schema,sessions:$sessions,ecarts:$ecarts,alertes_droits:$alertes}'
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
agent_etat_json
|
|
@@ -123,6 +123,34 @@ liste_modeles() {
|
|
|
123
123
|
fi
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
# Modèle et début d'une session (#308) : lus uniquement sur la dernière ligne
|
|
127
|
+
# « === modèle opencode/? début » du superviseur ; le texte écrit par le
|
|
128
|
+
# modèle dans le journal (un « opencode/agent.json » possible) n'est pas lu.
|
|
129
|
+
session_modele_debut() {
|
|
130
|
+
local ligne
|
|
131
|
+
ligne="$(grep '^=== modèle opencode/' "$1" 2>/dev/null | tail -1 || true)"
|
|
132
|
+
MODELE_SESSION="$(sed -nE 's/^=== modèle opencode\/([^ ]+) début .*/\1/p' <<<"$ligne")"
|
|
133
|
+
DEBUT_SESSION="$(sed -nE 's/.* début ([^ ]+).*/\1/p' <<<"$ligne")"
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# Une session est en cours (#308) si un processus agent.sh vivant a pour
|
|
137
|
+
# premier argument (le dossier, absolu depuis #287) un chemin dont le nom est
|
|
138
|
+
# exactement le journal sans « .log » ; un simple dossier contenant ce nom ne
|
|
139
|
+
# suffit pas, ni un chemin qui ne serait pas le dossier d'un agent.
|
|
140
|
+
session_en_cours() {
|
|
141
|
+
local ligne dossier
|
|
142
|
+
while IFS= read -r ligne; do
|
|
143
|
+
case "$ligne" in
|
|
144
|
+
*agent.sh\ *) dossier="${ligne#*agent.sh }" ;;
|
|
145
|
+
*) continue ;;
|
|
146
|
+
esac
|
|
147
|
+
dossier="${dossier%% *}"
|
|
148
|
+
[ -n "$dossier" ] || continue
|
|
149
|
+
if [ "$(basename "$dossier")" = "$1" ]; then return 0; fi
|
|
150
|
+
done < <(ps -eo args= 2>/dev/null || true)
|
|
151
|
+
return 1
|
|
152
|
+
}
|
|
153
|
+
|
|
126
154
|
# Sessions connues (journal, dernier modèle, début, dernier écrit) et modèles
|
|
127
155
|
# écartés par le superviseur, avec l'heure de fin d'écart.
|
|
128
156
|
agent_etat() {
|
|
@@ -131,9 +159,9 @@ agent_etat() {
|
|
|
131
159
|
for f in "$RACINE"/workspace/.agents/*.log; do
|
|
132
160
|
[ -e "$f" ] || continue
|
|
133
161
|
vu=1
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
162
|
+
session_modele_debut "$f"
|
|
163
|
+
m="${MODELE_SESSION:+opencode/$MODELE_SESSION}"
|
|
164
|
+
debut="$DEBUT_SESSION"
|
|
137
165
|
dernier="$(heure "$(mtime "$f")")"
|
|
138
166
|
echo " session $(basename "$f") : modèle ${m:-inconnu}, depuis ${debut:-inconnu}, dernier écrit $dernier"
|
|
139
167
|
done
|
package/.devcontainer/agent.sh
CHANGED
|
@@ -230,7 +230,7 @@ AGENTEOF2
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
case "${1:-}" in
|
|
233
|
-
etat) agent_etat ;;
|
|
233
|
+
etat) if [ "${2:-}" = "--json" ]; then exec bash "$ICI/agent-etat-json.sh"; else agent_etat; fi ;;
|
|
234
234
|
liberer)
|
|
235
235
|
[ -n "${2:-}" ] || { agent_aide >&2; exit 2; }
|
|
236
236
|
ecart_liberer "$2"
|
package/.devcontainer/devzone
CHANGED
|
@@ -57,7 +57,7 @@ MODULES=(ia kubernetes gitlab postgres)
|
|
|
57
57
|
# change pas : deux montées simultanées (workflow versions) se fusionnent sans
|
|
58
58
|
# conflit, git n'en signalant qu'entre lignes voisines modifiées.
|
|
59
59
|
# Claude Code
|
|
60
|
-
IA_CLAUDE=@anthropic-ai/claude-code@2.1.
|
|
60
|
+
IA_CLAUDE=@anthropic-ai/claude-code@2.1.319
|
|
61
61
|
# opencode
|
|
62
62
|
IA_OPENCODE=opencode-ai@1.19.5
|
|
63
63
|
IA_PAQUETS=("$IA_CLAUDE" "$IA_OPENCODE")
|
|
@@ -1009,8 +1009,14 @@ changer() {
|
|
|
1009
1009
|
"appliquer_$m" "$1" "${@:3}"
|
|
1010
1010
|
}
|
|
1011
1011
|
|
|
1012
|
+
# shellcheck source=etat-json.sh
|
|
1013
|
+
# shellcheck disable=SC1091
|
|
1014
|
+
if [ -f "$ICI/etat-json.sh" ]; then
|
|
1015
|
+
. "$ICI/etat-json.sh"
|
|
1016
|
+
fi
|
|
1017
|
+
|
|
1012
1018
|
case "${1:-}" in
|
|
1013
|
-
"" | etat | modules) etat ;;
|
|
1019
|
+
"" | etat | modules) if [ "${2:-}" = "--json" ]; then etat_json; else etat; fi ;;
|
|
1014
1020
|
activer) changer on "${2:-}" "${@:3}" ;;
|
|
1015
1021
|
desactiver) changer off "${2:-}" ;;
|
|
1016
1022
|
appliquer)
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Sortie machine de devzone etat (--json) : objet JSON stable et versionné.
|
|
3
|
+
# Sourcé par devzone : réutilise ses fonctions (valeur, description, …), ne
|
|
4
|
+
# réécrit pas etat(). Construit uniquement avec jq (échappement garanti).
|
|
5
|
+
|
|
6
|
+
# Ajoute une entrée à $erreurs : la rubrique qui a échoué et pourquoi.
|
|
7
|
+
ajouter_erreur() {
|
|
8
|
+
erreurs="$(jq -c --arg k "$1" --arg v "$2" '. + {($k): $v}' <<<"$erreurs")"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
# Ajoute une alerte (code, message, commande devzone à lancer) à $alertes_json.
|
|
12
|
+
append_alerte() {
|
|
13
|
+
local code="$1" message="$2" commande="${3:-}"
|
|
14
|
+
alertes_json="$(jq -c \
|
|
15
|
+
--arg code "$code" \
|
|
16
|
+
--arg message "$message" \
|
|
17
|
+
--arg commande "$commande" \
|
|
18
|
+
'. + [{code:$code,message:$message,commande:(if $commande=="" then null else $commande end)}]' \
|
|
19
|
+
<<<"$alertes_json")"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# État complet du poste en JSON : reprend chaque rubrique de etat() avec les
|
|
23
|
+
# mêmes commandes, en isolant chaque calcul (échec → valeur null et erreurs).
|
|
24
|
+
etat_json() {
|
|
25
|
+
local erreurs='{}'
|
|
26
|
+
local alertes_json='[]'
|
|
27
|
+
local dv_raw="" dvp_raw=""
|
|
28
|
+
local id_nom="" id_email="" id_ok=false id_commande=""
|
|
29
|
+
local plat_nom plat_url="" github_json="null"
|
|
30
|
+
local outils_retards_json='[]' outils_commande=""
|
|
31
|
+
local modules_json='[]' m actif desc ef content etat_val echec_val commande_val s
|
|
32
|
+
local services_cluster="" services_distant=false
|
|
33
|
+
local travail_ctx="" travail_interne=false ctx_hote=""
|
|
34
|
+
local clusters_services_raw="" clusters_travail_raw="" clusters_commande=""
|
|
35
|
+
local ports_json='[]' ports_out
|
|
36
|
+
local identifiants_raw=""
|
|
37
|
+
local retards_out paquet figee installee count
|
|
38
|
+
local relais_marque paquets_marque paquets_noms n chemin wt_out
|
|
39
|
+
local gh_statut gh_code
|
|
40
|
+
|
|
41
|
+
if v="$(version_du_dossier 2>/dev/null)"; then
|
|
42
|
+
dv_raw="$v"
|
|
43
|
+
else
|
|
44
|
+
ajouter_erreur devzone "version_du_dossier indisponible"
|
|
45
|
+
fi
|
|
46
|
+
dvp_raw="$(version_publiee 2>/dev/null || true)"
|
|
47
|
+
|
|
48
|
+
id_nom="$(git config --get user.name 2>/dev/null || true)"
|
|
49
|
+
id_email="$(git config --get user.email 2>/dev/null || true)"
|
|
50
|
+
if [ -n "$id_nom" ] && [ -n "$id_email" ]; then
|
|
51
|
+
id_ok=true
|
|
52
|
+
else
|
|
53
|
+
id_commande='gh auth login -s workflow (automatique), ou git config --file ~/.config/git/config user.name "<nom>" et user.email "<email>"'
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
plat_nom="$(plateforme_lue)"
|
|
57
|
+
if [ "$plat_nom" = gitlab ]; then
|
|
58
|
+
plat_url="$(url_gitlab_lue)"
|
|
59
|
+
else
|
|
60
|
+
plat_url=""
|
|
61
|
+
fi
|
|
62
|
+
if [ "$plat_nom" = github ]; then
|
|
63
|
+
gh_statut="$(gh auth status 2>&1)" && gh_code=0 || gh_code=$?
|
|
64
|
+
if [ "$gh_code" -ne 0 ]; then
|
|
65
|
+
github_json="null"
|
|
66
|
+
ajouter_erreur github "gh auth status a échoué"
|
|
67
|
+
else
|
|
68
|
+
if printf '%s\n' "$gh_statut" | grep -q "Token scopes:" && ! printf '%s\n' "$gh_statut" | grep -q "'workflow'"; then
|
|
69
|
+
github_json="$(jq -cn '{connecte:true,workflow:false,commande:"gh auth refresh -h github.com -s workflow"}')"
|
|
70
|
+
else
|
|
71
|
+
github_json="$(jq -cn '{connecte:true,workflow:true,commande:null}')"
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
else
|
|
75
|
+
github_json="null"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
if retards_out="$(outils_retard 2>/dev/null)"; then
|
|
79
|
+
outils_retards_json='[]'
|
|
80
|
+
while IFS= read -r ligne; do
|
|
81
|
+
[ -n "$ligne" ] || continue
|
|
82
|
+
# shellcheck disable=SC2086
|
|
83
|
+
set -- $ligne
|
|
84
|
+
paquet="${1:-}"; figee="${2:-}"; installee="${3:-}"
|
|
85
|
+
[ -n "$paquet" ] || continue
|
|
86
|
+
outils_retards_json="$(jq -c \
|
|
87
|
+
--arg p "$paquet" --arg f "$figee" --arg i "$installee" \
|
|
88
|
+
'. + [{paquet:$p,figee:$f,installee:$i}]' <<<"$outils_retards_json")"
|
|
89
|
+
done <<<"$retards_out"
|
|
90
|
+
count="$(jq 'length' <<<"$outils_retards_json" 2>/dev/null || echo 0)"
|
|
91
|
+
if [ "$count" -gt 0 ]; then
|
|
92
|
+
outils_commande="devzone appliquer"
|
|
93
|
+
fi
|
|
94
|
+
else
|
|
95
|
+
outils_retards_json="null"
|
|
96
|
+
ajouter_erreur outils "outils_retard indisponible"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
modules_json='[]'
|
|
100
|
+
for m in "${MODULES[@]}"; do
|
|
101
|
+
actif=false
|
|
102
|
+
[ "$(valeur "$m")" = on ] && actif=true
|
|
103
|
+
desc="$(description "$m")"
|
|
104
|
+
echec_val=""
|
|
105
|
+
etat_val=""
|
|
106
|
+
commande_val=""
|
|
107
|
+
if [ "$actif" = true ]; then
|
|
108
|
+
ef="$(fichier_echec "$m")"
|
|
109
|
+
if [ -f "$ef" ]; then
|
|
110
|
+
content="$(cat "$ef" 2>/dev/null || true)"
|
|
111
|
+
echec_val="$content"
|
|
112
|
+
etat_val="en échec"
|
|
113
|
+
commande_val="devzone appliquer"
|
|
114
|
+
elif [ "$m" = gitlab ]; then
|
|
115
|
+
if s="$(bash "$ICI/gitlab/gitlab.sh" etat 2>/dev/null)"; then
|
|
116
|
+
etat_val="$s"
|
|
117
|
+
else
|
|
118
|
+
etat_val=""
|
|
119
|
+
ajouter_erreur modules "gitlab.sh etat indisponible"
|
|
120
|
+
fi
|
|
121
|
+
elif [ "$m" = postgres ]; then
|
|
122
|
+
if s="$(bash "$ICI/postgres/postgres.sh" etat 2>/dev/null)"; then
|
|
123
|
+
etat_val="$s"
|
|
124
|
+
else
|
|
125
|
+
etat_val=""
|
|
126
|
+
ajouter_erreur modules "postgres.sh etat indisponible"
|
|
127
|
+
fi
|
|
128
|
+
else
|
|
129
|
+
etat_val="actif"
|
|
130
|
+
fi
|
|
131
|
+
else
|
|
132
|
+
etat_val="facultatif"
|
|
133
|
+
commande_val="devzone activer $m"
|
|
134
|
+
fi
|
|
135
|
+
modules_json="$(jq -c \
|
|
136
|
+
--arg nom "$m" \
|
|
137
|
+
--argjson actif "$actif" \
|
|
138
|
+
--arg description "$desc" \
|
|
139
|
+
--arg etat "$etat_val" \
|
|
140
|
+
--arg echec "$echec_val" \
|
|
141
|
+
--arg commande "$commande_val" \
|
|
142
|
+
'. + [{nom:$nom,actif:$actif,description:$description,etat:(if $etat=="" then null else $etat end),echec:(if $echec=="" then null else $echec end),commande:(if $commande=="" then null else $commande end)}]' \
|
|
143
|
+
<<<"$modules_json")"
|
|
144
|
+
done
|
|
145
|
+
|
|
146
|
+
services_cluster="$(cluster_lu)"
|
|
147
|
+
if [ -n "$services_cluster" ] && ! cluster_est_local "$services_cluster"; then
|
|
148
|
+
services_distant=true
|
|
149
|
+
fi
|
|
150
|
+
clusters_services_raw="$services_cluster"
|
|
151
|
+
travail_ctx="$(kubectl config current-context 2>/dev/null || true)"
|
|
152
|
+
case "$travail_ctx" in
|
|
153
|
+
kind-gitlab* | kind-devzone*)
|
|
154
|
+
ctx_hote="$(KUBECONFIG="${DEVZONE_KUBE_HOTE:-$HOME/.kube/hote.config}" kubectl config current-context 2>/dev/null || true)"
|
|
155
|
+
if [ -n "$ctx_hote" ] && cluster_joignable "$ctx_hote" 2>/dev/null; then
|
|
156
|
+
travail_interne=true
|
|
157
|
+
fi
|
|
158
|
+
;;
|
|
159
|
+
esac
|
|
160
|
+
clusters_travail_raw="$travail_ctx"
|
|
161
|
+
if [ "$travail_interne" = true ]; then
|
|
162
|
+
clusters_commande="devzone utiliser $ctx_hote"
|
|
163
|
+
fi
|
|
164
|
+
|
|
165
|
+
if ports_out="$(bash "$ICI/ports.sh" liste --json 2>/dev/null)"; then
|
|
166
|
+
if printf '%s' "$ports_out" | jq -e . >/dev/null 2>&1; then
|
|
167
|
+
ports_json="$ports_out"
|
|
168
|
+
else
|
|
169
|
+
ports_json="null"
|
|
170
|
+
ajouter_erreur ports "sortie ports illisible"
|
|
171
|
+
fi
|
|
172
|
+
else
|
|
173
|
+
ports_json="null"
|
|
174
|
+
ajouter_erreur ports "ports.sh indisponible"
|
|
175
|
+
fi
|
|
176
|
+
|
|
177
|
+
if [ -f "$RACINE/.password" ]; then
|
|
178
|
+
identifiants_raw="$RACINE/.password"
|
|
179
|
+
fi
|
|
180
|
+
|
|
181
|
+
relais_marque="${DEVZONE_RELAIS_MARQUE:-/tmp/devzone-relais-docker.echec}"
|
|
182
|
+
if [ -f "$relais_marque" ]; then
|
|
183
|
+
msg="$(head -1 "$relais_marque" 2>/dev/null || true)"
|
|
184
|
+
append_alerte relais_docker "$msg" "devzone reparer"
|
|
185
|
+
fi
|
|
186
|
+
paquets_marque="${DEVZONE_PAQUETS_MARQUE:-/tmp/devzone-paquets.echec}"
|
|
187
|
+
if [ -f "$paquets_marque" ]; then
|
|
188
|
+
paquets_noms=""
|
|
189
|
+
while IFS= read -r n; do
|
|
190
|
+
[ -n "$n" ] || continue
|
|
191
|
+
paquets_noms="${paquets_noms:+$paquets_noms, }$n"
|
|
192
|
+
done < "$paquets_marque"
|
|
193
|
+
append_alerte paquets "$paquets_noms" "devzone paquets"
|
|
194
|
+
fi
|
|
195
|
+
wt_out="$(worktrees_absents 2>/dev/null || true)"
|
|
196
|
+
while IFS= read -r chemin; do
|
|
197
|
+
[ -n "$chemin" ] || continue
|
|
198
|
+
append_alerte worktree "$chemin absent ici (créé hors du conteneur ?)" ""
|
|
199
|
+
done <<<"$wt_out"
|
|
200
|
+
if [ -n "$services_cluster" ] && ! cluster_est_local "$services_cluster"; then
|
|
201
|
+
append_alerte cluster_distant "cluster distant : $services_cluster — services sur un cluster distant" ""
|
|
202
|
+
fi
|
|
203
|
+
if [ "$travail_interne" = true ]; then
|
|
204
|
+
append_alerte cluster_interne "cluster de travail : $travail_ctx (cluster interne de devzone)" "devzone utiliser $ctx_hote"
|
|
205
|
+
fi
|
|
206
|
+
|
|
207
|
+
jq -n \
|
|
208
|
+
--argjson schema 1 \
|
|
209
|
+
--arg dv "$dv_raw" \
|
|
210
|
+
--arg dvp "$dvp_raw" \
|
|
211
|
+
--argjson id_ok "$id_ok" \
|
|
212
|
+
--arg id_nom "$id_nom" \
|
|
213
|
+
--arg id_email "$id_email" \
|
|
214
|
+
--arg id_commande "$id_commande" \
|
|
215
|
+
--arg plat_nom "$plat_nom" \
|
|
216
|
+
--arg plat_url "$plat_url" \
|
|
217
|
+
--argjson github "$github_json" \
|
|
218
|
+
--argjson retards "$outils_retards_json" \
|
|
219
|
+
--arg outils_commande "$outils_commande" \
|
|
220
|
+
--argjson modules "$modules_json" \
|
|
221
|
+
--arg clusters_services "$clusters_services_raw" \
|
|
222
|
+
--argjson services_distant "$services_distant" \
|
|
223
|
+
--arg clusters_travail "$clusters_travail_raw" \
|
|
224
|
+
--argjson travail_interne "$travail_interne" \
|
|
225
|
+
--arg clusters_commande "$clusters_commande" \
|
|
226
|
+
--argjson ports "$ports_json" \
|
|
227
|
+
--arg identifiants "$identifiants_raw" \
|
|
228
|
+
--argjson alertes "$alertes_json" \
|
|
229
|
+
--argjson erreurs "$erreurs" \
|
|
230
|
+
'{
|
|
231
|
+
schema: $schema,
|
|
232
|
+
devzone: { version: (if $dv=="" then null else $dv end), disponible: (if $dvp=="" then null else $dvp end) },
|
|
233
|
+
identite_git: { ok: $id_ok, nom: (if $id_nom=="" then null else $id_nom end), email: (if $id_email=="" then null else $id_email end), commande: (if $id_commande=="" then null else $id_commande end) },
|
|
234
|
+
plateforme: { nom: $plat_nom, url: (if $plat_url=="" then null else $plat_url end), github: $github },
|
|
235
|
+
outils: { retards: $retards, commande: (if $outils_commande=="" then null else $outils_commande end) },
|
|
236
|
+
modules: $modules,
|
|
237
|
+
clusters: { services: (if $clusters_services=="" then null else $clusters_services end), services_distant: $services_distant, travail: (if $clusters_travail=="" then null else $clusters_travail end), travail_interne: $travail_interne, commande: (if $clusters_commande=="" then null else $clusters_commande end) },
|
|
238
|
+
ports: $ports,
|
|
239
|
+
identifiants: (if $identifiants=="" then null else $identifiants end),
|
|
240
|
+
alertes: $alertes,
|
|
241
|
+
erreurs: $erreurs
|
|
242
|
+
}'
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
246
|
+
etat_json
|
|
247
|
+
fi
|
package/.devcontainer/ports.sh
CHANGED
|
@@ -211,8 +211,36 @@ relancer() {
|
|
|
211
211
|
return "$rc"
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
# Sortie lisible par machine de liste : tableau JSON [{port,actif,application}], via jq seul.
|
|
215
|
+
liste_json() {
|
|
216
|
+
local ports port actif app json='[]'
|
|
217
|
+
ports="$(trier_ports "$(lire_ports)")"
|
|
218
|
+
if [ -z "$ports" ]; then
|
|
219
|
+
printf '[]\n'
|
|
220
|
+
return 0
|
|
221
|
+
fi
|
|
222
|
+
# shellcheck disable=SC2046 # liste de ports séparés par des virgules
|
|
223
|
+
for port in $(printf '%s' "$ports" | tr ',' ' '); do
|
|
224
|
+
if relais_actif "$port"; then
|
|
225
|
+
actif=true
|
|
226
|
+
else
|
|
227
|
+
actif=false
|
|
228
|
+
fi
|
|
229
|
+
if application_repond "$port"; then
|
|
230
|
+
app="application répond"
|
|
231
|
+
else
|
|
232
|
+
app="aucune application"
|
|
233
|
+
fi
|
|
234
|
+
json="$(jq -c --argjson port "$port" --argjson actif "$actif" --arg app "$app" \
|
|
235
|
+
'. + [{port:$port,actif:$actif,application:$app}]' <<<"$json")"
|
|
236
|
+
done
|
|
237
|
+
printf '%s\n' "$json"
|
|
238
|
+
}
|
|
239
|
+
|
|
214
240
|
case "${1:-}" in
|
|
215
|
-
'' | liste)
|
|
241
|
+
'' | liste)
|
|
242
|
+
if [ "${2:-}" = "--json" ]; then liste_json; else liste; fi
|
|
243
|
+
;;
|
|
216
244
|
ouvrir) ouvrir "${2:-}" ;;
|
|
217
245
|
fermer | --fermer) fermer "${2:-}" ;;
|
|
218
246
|
relancer) relancer ;;
|