devzone 2.0.0 → 3.0.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.
- package/.devcontainer/agent-errors.sh +6 -6
- package/.devcontainer/agent-pod-manifest.sh +4 -4
- package/.devcontainer/agent-session.sh +2 -2
- package/.devcontainer/agent-state-json.sh +2 -2
- package/.devcontainer/agent-workspace.sh +1 -1
- package/.devcontainer/agent.sh +7 -7
- package/.devcontainer/ai/host-models.sh +2 -2
- package/.devcontainer/ai/plugins/devzone-guard-v2.js +3 -3
- package/.devcontainer/ai/plugins/devzone-guard.js +3 -3
- package/.devcontainer/argocd/argocd.sh +90 -89
- package/.devcontainer/argocd/catalog-argocd.sh +2 -2
- package/.devcontainer/argocd/services-hook.sh +3 -3
- package/.devcontainer/argocd/services.sh +1 -1
- package/.devcontainer/catalog/app.sh +114 -116
- package/.devcontainer/catalog/catalog-watcher.sh +62 -62
- package/.devcontainer/catalog/mysql/app.conf +1 -1
- package/.devcontainer/catalog/mysql/install.sh +40 -40
- package/.devcontainer/catalog/mysql/mysql.sh +141 -141
- package/.devcontainer/catalog/mysql/volume.sh +39 -39
- package/.devcontainer/catalog.sh +112 -112
- package/.devcontainer/chart-direct.sh +1 -1
- package/.devcontainer/cluster.sh +216 -218
- package/.devcontainer/clusters.sh +41 -41
- package/.devcontainer/devzone +92 -1495
- package/.devcontainer/devzone-ai-guard.sh +76 -0
- package/.devcontainer/devzone-ai.sh +201 -0
- package/.devcontainer/devzone-cluster.sh +210 -0
- package/.devcontainer/devzone-modules.sh +126 -0
- package/.devcontainer/devzone-platform.sh +189 -0
- package/.devcontainer/devzone-repair.sh +94 -0
- package/.devcontainer/devzone-services.sh +241 -0
- package/.devcontainer/devzone-skill.sh +97 -0
- package/.devcontainer/devzone-status.sh +140 -0
- package/.devcontainer/devzone-version.sh +78 -0
- package/.devcontainer/git-identity.sh +28 -0
- package/.devcontainer/gitlab/chart.sh +2 -2
- package/.devcontainer/gitlab/gitlab.sh +81 -82
- package/.devcontainer/gitlab/installation.sh +109 -109
- package/.devcontainer/gitlab/secrets.sh +47 -47
- package/.devcontainer/gitlab/seed.sh +77 -77
- package/.devcontainer/gitlab/test-gitlab.sh +242 -243
- package/.devcontainer/help.sh +1 -1
- package/.devcontainer/isolation.sh +30 -30
- package/.devcontainer/kind-wrapper.sh +17 -17
- package/.devcontainer/kube-account.sh +112 -113
- package/.devcontainer/kube-config.sh +45 -46
- package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
- package/.devcontainer/kube-reachable.sh +40 -40
- package/.devcontainer/memory.sh +1 -1
- package/.devcontainer/metrics-server.sh +2 -2
- package/.devcontainer/opencode.jsonc +2 -2
- package/.devcontainer/packages.sh +136 -135
- package/.devcontainer/password.sh +1 -1
- package/.devcontainer/ports-auto.sh +152 -153
- package/.devcontainer/ports-json.sh +16 -15
- package/.devcontainer/ports.sh +126 -122
- package/.devcontainer/post-create.sh +52 -52
- package/.devcontainer/postgres/postgres.sh +174 -174
- package/.devcontainer/rename-legacy-files.sh +103 -0
- package/.devcontainer/services-admin.sh +3 -3
- package/.devcontainer/skills/devzone/SKILL.md +40 -41
- package/.devcontainer/startup.sh +48 -49
- package/.devcontainer/state-gitops.sh +1 -1
- package/.devcontainer/state-json.sh +36 -62
- package/.devcontainer/state.sh +2 -2
- package/.devcontainer/workspace-init.sh +16 -2
- package/Makefile +1 -1
- package/README.md +195 -194
- package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
- package/manage/devzone +5 -7
- package/manage/scripts/argocd-workspace.sh +1 -1
- package/manage/scripts/check-names.sh +6 -5
- package/manage/scripts/create-cluster.sh +1 -1
- package/manage/scripts/create-mode.sh +2 -2
- package/manage/scripts/devzone-create.sh +3 -3
- package/manage/scripts/devzone-manifest.sh +1 -1
- package/manage/scripts/devzone-update.sh +12 -8
- package/manage/scripts/launch.sh +7 -48
- package/manage/scripts/migrate-revert.sh +3 -3
- package/manage/scripts/migrate.sh +7 -13
- package/manage/scripts/ports-apps.sh +1 -1
- package/manage/scripts/ports-workspace.sh +7 -7
- package/manage/scripts/uninstall.sh +8 -8
- package/manage/scripts/workspace-egress.sh +2 -2
- package/manage/scripts/workspace-update.sh +5 -2
- package/manage/scripts/workspace-wait.sh +2 -2
- package/package.json +1 -1
- package/.devcontainer/docker-relay.sh +0 -149
- package/.devcontainer/docker-without-host.sh +0 -12
- package/.devcontainer/git-identite.sh +0 -28
package/.devcontainer/devzone
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
2
|
+
# shellcheck disable=SC2034 # shared variables, read by the sourced devzone-*.sh
|
|
3
|
+
# devzone help (devzone --help): .devcontainer/help.sh, sourced below.
|
|
3
4
|
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# global (~/.config/devzone/modules) est repris une fois
|
|
5
|
+
# Per-instance state: $RACINE/.devzone.modules (a folder mounted from the host,
|
|
6
|
+
# survives rebuilds), one line "module=on|off"; the chosen platform is kept
|
|
7
|
+
# there too (platform=, gitlab_url=), and the services cluster (cluster=, see
|
|
8
|
+
# cluster.sh); the old global state (~/.config/devzone/modules) is read once
|
|
9
9
|
set -euo pipefail
|
|
10
10
|
|
|
11
|
-
#
|
|
12
|
-
#
|
|
11
|
+
# Script folder, symbolic links followed by hand: readlink -f does not exist
|
|
12
|
+
# on macOS (tests under bash 3.2).
|
|
13
13
|
SOURCE="${BASH_SOURCE[0]}"
|
|
14
14
|
while [ -L "$SOURCE" ]; do
|
|
15
15
|
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
@@ -24,10 +24,10 @@ ICI="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
|
24
24
|
# shellcheck disable=SC1091
|
|
25
25
|
. "$ICI/help.sh"
|
|
26
26
|
VERSIONS="$ICI/../manage/scripts/versions.sh"
|
|
27
|
-
#
|
|
28
|
-
RACINE="${
|
|
29
|
-
#
|
|
30
|
-
ETAT="${
|
|
27
|
+
# devzone folder (/workspaces/devzone); DEVZONE_ROOT for the tests
|
|
28
|
+
RACINE="${DEVZONE_ROOT:-$(dirname "$ICI")}"
|
|
29
|
+
# Default state of the instance; DEVZONE_STATE takes precedence (tests, CI)
|
|
30
|
+
ETAT="${DEVZONE_STATE:-$RACINE/.devzone.modules}"
|
|
31
31
|
MODULES=(ia kubernetes gitlab postgres argocd mysql)
|
|
32
32
|
# shellcheck source=SCRIPTDIR/cluster.sh
|
|
33
33
|
# shellcheck disable=SC1091
|
|
@@ -59,1463 +59,60 @@ fi
|
|
|
59
59
|
# shellcheck disable=SC1091
|
|
60
60
|
. "$ICI/ai/host-check.sh"
|
|
61
61
|
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
#
|
|
62
|
+
# AI assistants, pinned versions: update here, then devzone apply (or Rebuild
|
|
63
|
+
# Container). One line per package, separated by a line that does not change:
|
|
64
|
+
# two simultaneous bumps (versions workflow) merge without conflict, git only
|
|
65
|
+
# reporting neighbouring lines changed.
|
|
66
66
|
# Claude Code
|
|
67
|
-
IA_CLAUDE=@anthropic-ai/claude-code@2.1.
|
|
67
|
+
IA_CLAUDE=@anthropic-ai/claude-code@2.1.330
|
|
68
68
|
# opencode
|
|
69
69
|
IA_OPENCODE=opencode-ai@1.19.6
|
|
70
70
|
IA_PAQUETS=("$IA_CLAUDE" "$IA_OPENCODE")
|
|
71
71
|
IA_NOMS=("${IA_CLAUDE%@*}" "${IA_OPENCODE%@*}")
|
|
72
72
|
|
|
73
|
-
# glab (CLI
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
#
|
|
73
|
+
# glab (GitLab CLI), installed only when the gitlab platform is chosen: binary
|
|
74
|
+
# of the official release (gitlab.com/gitlab-org/cli) in ~/.local/bin, SHA-256
|
|
75
|
+
# sum of its archive checked; removed when going back to github. All its calls
|
|
76
|
+
# go through this path (never PATH: ~/.local/bin is not necessarily in it); the
|
|
77
|
+
# state and the login too.
|
|
78
78
|
GLAB="$HOME/.local/bin/glab"
|
|
79
79
|
GLAB_VERSION=v1.126.0
|
|
80
80
|
GLAB_SOMME_ARM64=de5e92c9c8b306eeebb19daa854d48101b78328850e7b9cd677ecd6f98cd4391
|
|
81
81
|
GLAB_SOMME_AMD64=f386519ba83e9482979992ee7f60eeebee4d95b950f95f4fe7289e0a1b1ea74c
|
|
82
|
-
#
|
|
82
|
+
# gitlab module instance: its default URL and the root token of its seed
|
|
83
83
|
GITLAB_URL_MODULE=http://gitlab.localhost:8929
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
#
|
|
103
|
-
|
|
104
|
-
#
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
echo on
|
|
117
|
-
return 0
|
|
118
|
-
fi
|
|
119
|
-
[ "$v" = on ] && echo on || echo off
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
# Verrou tenu de l'initialisation à l'écriture (#417) : l'état n'est jamais
|
|
123
|
-
# recréé à vide entre les deux
|
|
124
|
-
ecrire() {
|
|
125
|
-
state_lock_take || return 1
|
|
126
|
-
if ! initialiser || ! state_write "$1" "$2"; then
|
|
127
|
-
state_lock_release
|
|
128
|
-
return 1
|
|
129
|
-
fi
|
|
130
|
-
state_lock_release
|
|
131
|
-
return 0
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
# Retire une clé du fichier d'état : la configuration d'un service n'existe
|
|
135
|
-
# que pendant qu'il est choisi (#242)
|
|
136
|
-
retirer_cle() {
|
|
137
|
-
state_lock_take || return 1
|
|
138
|
-
if ! initialiser || ! state_remove "$1"; then
|
|
139
|
-
state_lock_release
|
|
140
|
-
return 1
|
|
141
|
-
fi
|
|
142
|
-
state_lock_release
|
|
143
|
-
return 0
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
# Vrai si le fichier ne contient que la clé $schema (créé d'office par opencode)
|
|
147
|
-
contient_seulement_schema() {
|
|
148
|
-
local autres
|
|
149
|
-
autres="$(grep -vcE '^[[:space:]]*([{}]|"?[$]schema"?[[:space:]]*:.*)?[[:space:]]*$' "$1" || true)"
|
|
150
|
-
[ "$autres" -eq 0 ] && grep -qF "\$schema" "$1"
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
# Configuration opencode par défaut (modèle versionné) : écrite au premier
|
|
154
|
-
# usage, mise à jour tant qu'elle garde le repère devzone, personnalisée sinon.
|
|
155
|
-
config_opencode() {
|
|
156
|
-
local modele="$ICI/opencode.jsonc" repere cible
|
|
157
|
-
repere='// devzone : configuration opencode par défaut'
|
|
158
|
-
if [ -f "$HOME/.config/opencode/opencode.jsonc" ]; then
|
|
159
|
-
cible="$HOME/.config/opencode/opencode.jsonc"
|
|
160
|
-
elif [ -f "$HOME/.config/opencode/opencode.json" ]; then
|
|
161
|
-
cible="$HOME/.config/opencode/opencode.json"
|
|
162
|
-
else
|
|
163
|
-
cible="$HOME/.config/opencode/opencode.jsonc"
|
|
164
|
-
fi
|
|
165
|
-
mkdir -p "$(dirname "$cible")"
|
|
166
|
-
if [ ! -f "$cible" ]; then
|
|
167
|
-
cp "$modele" "$cible"
|
|
168
|
-
echo "opencode : configuration par défaut écrite"
|
|
169
|
-
elif grep -qF "$repere" "$cible"; then
|
|
170
|
-
if ! cmp -s "$modele" "$cible"; then
|
|
171
|
-
cp "$modele" "$cible"
|
|
172
|
-
echo "opencode : configuration par défaut mise à jour"
|
|
173
|
-
fi
|
|
174
|
-
elif contient_seulement_schema "$cible"; then
|
|
175
|
-
cp "$modele" "$cible"
|
|
176
|
-
echo "opencode : configuration par défaut mise à jour"
|
|
177
|
-
else
|
|
178
|
-
echo "opencode : configuration personnalisée, gardée"
|
|
179
|
-
fi
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
# Retire la configuration opencode écrite par devzone si elle porte encore son
|
|
183
|
-
# repère et n'a pas été modifiée ; une config personnalisée (sans repère ou
|
|
184
|
-
# modifiée) est gardée. Symétrique de config_opencode.
|
|
185
|
-
retirer_config_opencode() {
|
|
186
|
-
local repere modele cible
|
|
187
|
-
repere='// devzone : configuration opencode par défaut'
|
|
188
|
-
modele="$ICI/opencode.jsonc"
|
|
189
|
-
if [ -f "$HOME/.config/opencode/opencode.jsonc" ]; then
|
|
190
|
-
cible="$HOME/.config/opencode/opencode.jsonc"
|
|
191
|
-
elif [ -f "$HOME/.config/opencode/opencode.json" ]; then
|
|
192
|
-
cible="$HOME/.config/opencode/opencode.json"
|
|
193
|
-
else
|
|
194
|
-
return 0
|
|
195
|
-
fi
|
|
196
|
-
if grep -qF "$repere" "$cible" && cmp -s "$modele" "$cible"; then
|
|
197
|
-
rm -f "$cible"
|
|
198
|
-
echo "opencode : configuration par défaut retirée"
|
|
199
|
-
else
|
|
200
|
-
echo "opencode : configuration personnalisée, gardée"
|
|
201
|
-
fi
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
# Repère de la skill devzone : posée si absente, mise à jour si elle porte le
|
|
205
|
-
# repère et n'a pas été modifiée, gardée si personnalisée (#161, règle opencode).
|
|
206
|
-
SKILL_REPERE='<!-- devzone : skill posée par devzone enable ia -->'
|
|
207
|
-
# Empreinte de la version posée, à côté de SKILL.md : elle distingue une skill
|
|
208
|
-
# non modifiée d'une skill personnalisée qui garde encore le repère.
|
|
209
|
-
SKILL_EMPREINTE='.devzone-empreinte'
|
|
210
|
-
|
|
211
|
-
# Dossiers de la skill devzone, dans les volumes de Claude Code et opencode.
|
|
212
|
-
skill_dossiers() {
|
|
213
|
-
echo "$HOME/.claude/skills/devzone"
|
|
214
|
-
echo "$HOME/.config/opencode/skills/devzone"
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
# Somme sha256 d'un fichier (sha256sum sous Linux, shasum sous macOS).
|
|
218
|
-
skill_somme() {
|
|
219
|
-
if command -v sha256sum >/dev/null 2>&1; then
|
|
220
|
-
sha256sum "$1" | cut -d' ' -f1
|
|
221
|
-
else
|
|
222
|
-
shasum -a 256 "$1" | cut -d' ' -f1
|
|
223
|
-
fi
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
# Vrai si la skill cible est encore celle posée : empreinte enregistrée, ou à
|
|
227
|
-
# défaut contenu identique au modèle.
|
|
228
|
-
skill_inchangee() {
|
|
229
|
-
local cible="$1" empreinte="$2" modele="$3"
|
|
230
|
-
if [ -n "$empreinte" ]; then
|
|
231
|
-
[ "$(skill_somme "$cible")" = "$empreinte" ]
|
|
232
|
-
else
|
|
233
|
-
cmp -s "$modele" "$cible"
|
|
234
|
-
fi
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
# Pose la skill devzone (modèle versionné) : écrite si absente, mise à jour
|
|
238
|
-
# tant qu'elle garde le repère et l'empreinte posée, gardée si personnalisée.
|
|
239
|
-
poser_skill_devzone() {
|
|
240
|
-
local modele="$ICI/skills/devzone/SKILL.md" repere cible d empreinte
|
|
241
|
-
repere="$SKILL_REPERE"
|
|
242
|
-
for d in $(skill_dossiers); do
|
|
243
|
-
mkdir -p "$d"
|
|
244
|
-
cible="$d/SKILL.md"
|
|
245
|
-
if [ ! -f "$cible" ]; then
|
|
246
|
-
cp "$modele" "$cible"
|
|
247
|
-
skill_somme "$cible" >"$d/$SKILL_EMPREINTE"
|
|
248
|
-
echo "devzone : skill devzone posée dans $d"
|
|
249
|
-
continue
|
|
250
|
-
fi
|
|
251
|
-
empreinte=""
|
|
252
|
-
if [ -f "$d/$SKILL_EMPREINTE" ]; then
|
|
253
|
-
empreinte="$(cat "$d/$SKILL_EMPREINTE")"
|
|
254
|
-
fi
|
|
255
|
-
if grep -qF "$repere" "$cible" && skill_inchangee "$cible" "$empreinte" "$modele"; then
|
|
256
|
-
if ! cmp -s "$modele" "$cible"; then
|
|
257
|
-
cp "$modele" "$cible"
|
|
258
|
-
echo "devzone : skill devzone mise à jour dans $d"
|
|
259
|
-
fi
|
|
260
|
-
skill_somme "$cible" >"$d/$SKILL_EMPREINTE"
|
|
261
|
-
else
|
|
262
|
-
echo "devzone : skill devzone personnalisée dans $d, gardée"
|
|
263
|
-
fi
|
|
264
|
-
done
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
# Retire la skill devzone écrite par devzone si elle porte encore son repère
|
|
268
|
-
# et n'a pas été modifiée ; une skill personnalisée est gardée. Symétrique de
|
|
269
|
-
# poser_skill_devzone.
|
|
270
|
-
retirer_skill_devzone() {
|
|
271
|
-
local repere modele cible d empreinte
|
|
272
|
-
repere="$SKILL_REPERE"
|
|
273
|
-
modele="$ICI/skills/devzone/SKILL.md"
|
|
274
|
-
for d in $(skill_dossiers); do
|
|
275
|
-
cible="$d/SKILL.md"
|
|
276
|
-
if [ ! -f "$cible" ]; then
|
|
277
|
-
rm -f "$d/$SKILL_EMPREINTE"
|
|
278
|
-
continue
|
|
279
|
-
fi
|
|
280
|
-
empreinte=""
|
|
281
|
-
if [ -f "$d/$SKILL_EMPREINTE" ]; then
|
|
282
|
-
empreinte="$(cat "$d/$SKILL_EMPREINTE")"
|
|
283
|
-
fi
|
|
284
|
-
if grep -qF "$repere" "$cible" && skill_inchangee "$cible" "$empreinte" "$modele"; then
|
|
285
|
-
rm -f "$cible" "$d/$SKILL_EMPREINTE"
|
|
286
|
-
echo "devzone : skill devzone retirée de $d"
|
|
287
|
-
else
|
|
288
|
-
echo "devzone : skill devzone personnalisée dans $d, gardée"
|
|
289
|
-
fi
|
|
290
|
-
done
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
# Lance une commande longue en écrivant « toujours en cours » toutes les
|
|
294
|
-
# DEVZONE_PROGRESSION s sur stderr : une installation muette semble bloquée (#195)
|
|
295
|
-
avec_progression() {
|
|
296
|
-
local pas="${DEVZONE_PROGRESSION:-30}" ecoule=0 pid code=0
|
|
297
|
-
"$@" &
|
|
298
|
-
pid=$!
|
|
299
|
-
while kill -0 "$pid" 2>/dev/null; do
|
|
300
|
-
sleep 1
|
|
301
|
-
ecoule=$((ecoule + 1))
|
|
302
|
-
if [ $((ecoule % pas)) -eq 0 ] && kill -0 "$pid" 2>/dev/null; then
|
|
303
|
-
echo "devzone : … toujours en cours (${ecoule} s)" >&2
|
|
304
|
-
fi
|
|
305
|
-
done
|
|
306
|
-
wait "$pid" || code=$?
|
|
307
|
-
return "$code"
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
# Fichier qui marque un module actif en échec (contenu : où regarder) ; à côté
|
|
311
|
-
# de l'état, dans son volume : l'état l'affiche à chaque démarrage
|
|
312
|
-
fichier_echec() {
|
|
313
|
-
echo "$ETAT-echec-$1"
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
# Services in the Kubernetes workspace pod (#528): gitlab, postgres and argocd
|
|
317
|
-
# live in the cluster, installed from the workstation (devzone workspace
|
|
318
|
-
# services). The pod has no kubeconfig and a limited account (#430): their
|
|
319
|
-
# presence is the cluster DNS (like #515), never an installer failure marker.
|
|
320
|
-
dans_pod() {
|
|
321
|
-
[ "${DEVZONE_WORKSPACE:-}" = kubernetes ]
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
service_module() {
|
|
325
|
-
case "$1" in
|
|
326
|
-
gitlab | postgres | argocd) return 0 ;;
|
|
327
|
-
esac
|
|
328
|
-
return 1
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
# DNS name of the service of a module: <service>.<namespace>.svc
|
|
332
|
-
service_dns() {
|
|
333
|
-
case "$1" in
|
|
334
|
-
gitlab) echo "gitlab-webservice-default.devzone-gitlab${INSTANCE_SUFFIX}.svc" ;;
|
|
335
|
-
postgres) echo "postgres.devzone-postgres.svc" ;;
|
|
336
|
-
argocd) echo "argocd-server.devzone-argocd.svc" ;;
|
|
337
|
-
esac
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
service_present() {
|
|
341
|
-
getent hosts "$(service_dns "$1")" >/dev/null 2>&1
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
# Status line of a service module in the pod: present → active; absent → the
|
|
345
|
-
# workstation command that installs it
|
|
346
|
-
service_ligne_pod() {
|
|
347
|
-
local m="$1"
|
|
348
|
-
if service_present "$m"; then
|
|
349
|
-
printf ' ✔ module %-10s active: %s (%s)\n' "$m" "$(description "$m")" "$(service_dns "$m")"
|
|
350
|
-
elif [ "$(valeur "$m")" = on ]; then
|
|
351
|
-
printf ' ⚠ module %-10s not in the cluster: on the workstation, devzone workspace services enable %s\n' "$m" "$m"
|
|
352
|
-
else
|
|
353
|
-
printf ' ○ module %-10s optional, %s: on the workstation, devzone workspace services enable %s\n' "$m" "$(description "$m")" "$m"
|
|
354
|
-
fi
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
# devzone apply of a service module: in the Kubernetes workspace pod nothing
|
|
358
|
-
# is installed (the workstation does it, #528) and the failure marker of an
|
|
359
|
-
# earlier start is cleared; elsewhere, the installer of the module
|
|
360
|
-
appliquer_service() {
|
|
361
|
-
if dans_pod; then
|
|
362
|
-
rm -f "$(fichier_echec "$1")"
|
|
363
|
-
echo "devzone: $1 is installed from the workstation (devzone workspace services enable $1): nothing to do in the pod"
|
|
364
|
-
return 0
|
|
365
|
-
fi
|
|
366
|
-
"appliquer_$1" on
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
# Journal du dernier npm (son chemin est à donner en cas d'échec), ou son
|
|
370
|
-
# dossier ; noms horodatés : le dernier dans l'ordre du glob est le plus récent
|
|
371
|
-
dernier_journal_npm() {
|
|
372
|
-
local journal="" f
|
|
373
|
-
for f in "$HOME"/.npm/_logs/*-debug-0.log; do
|
|
374
|
-
if [ -f "$f" ]; then journal="$f"; fi
|
|
375
|
-
done
|
|
376
|
-
echo "${journal:-$HOME/.npm/_logs}"
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
# Installs each pinned AI assistant with its own npm command (3 tries each),
|
|
380
|
-
# then checks its binary: npm silently drops a platform binary it failed to
|
|
381
|
-
# download (#194), and one assistant failing must not block the other.
|
|
382
|
-
installer_ia() {
|
|
383
|
-
local package binary attempt
|
|
384
|
-
IA_FAILED=()
|
|
385
|
-
for package in "${IA_PAQUETS[@]}"; do
|
|
386
|
-
case "$package" in
|
|
387
|
-
opencode-ai@*) binary=opencode ;;
|
|
388
|
-
*) binary=claude ;;
|
|
389
|
-
esac
|
|
390
|
-
for attempt in 1 2 3; do
|
|
391
|
-
if avec_progression npm install -g --no-fund --no-audit --loglevel=error "$package" >/dev/null &&
|
|
392
|
-
"$binary" --version >/dev/null 2>&1; then
|
|
393
|
-
break
|
|
394
|
-
fi
|
|
395
|
-
if [ "$attempt" -lt 3 ]; then
|
|
396
|
-
echo "devzone : installation de ${package%@*} incomplète, nouvel essai ($((attempt + 1))/3)…" >&2
|
|
397
|
-
else
|
|
398
|
-
IA_FAILED+=("$package")
|
|
399
|
-
fi
|
|
400
|
-
done
|
|
401
|
-
done
|
|
402
|
-
[ "${#IA_FAILED[@]}" -eq 0 ]
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
# Docker guard for the folders that are not this repository: a Claude Code
|
|
406
|
-
# PreToolUse hook in the global settings and the two opencode plugins in the
|
|
407
|
-
# global plugins folder. Idempotent, other user settings and hooks preserved.
|
|
408
|
-
poser_garde_docker() {
|
|
409
|
-
local script="$ICI/ai/docker-guard.sh" config="$HOME/.claude/settings.json"
|
|
410
|
-
local src="$ICI/ai/plugins" dst="$HOME/.config/opencode/plugins"
|
|
411
|
-
local tmp f
|
|
412
|
-
if ! command -v jq >/dev/null 2>&1; then
|
|
413
|
-
echo "devzone : jq absent : garde-fou docker non posé pour Claude Code" >&2
|
|
414
|
-
elif [ ! -f "$config" ]; then
|
|
415
|
-
echo "devzone : $config absent : garde-fou docker non posé pour Claude Code" >&2
|
|
416
|
-
elif ! jq -e . "$config" >/dev/null 2>&1; then
|
|
417
|
-
echo "devzone : $config illisible (JSON invalide) : garde-fou docker non posé pour Claude Code" >&2
|
|
418
|
-
else
|
|
419
|
-
tmp="$(mktemp)"
|
|
420
|
-
if jq --arg cmd "bash \"$script\" --format claude" '
|
|
421
|
-
.hooks = (.hooks // {}) |
|
|
422
|
-
.hooks.PreToolUse = (.hooks.PreToolUse // []) |
|
|
423
|
-
if ([.hooks.PreToolUse[]? | .hooks[]? | (.command // "")] | any(contains("docker-guard.sh")))
|
|
424
|
-
then .
|
|
425
|
-
else .hooks.PreToolUse += [{"matcher": "Bash", "hooks": [{"type": "command", "command": $cmd}]}]
|
|
426
|
-
end
|
|
427
|
-
' "$config" >"$tmp" 2>/dev/null; then
|
|
428
|
-
mv "$tmp" "$config"
|
|
429
|
-
else
|
|
430
|
-
rm -f "$tmp"
|
|
431
|
-
echo "devzone : $config inchangé : garde-fou docker non posé pour Claude Code" >&2
|
|
432
|
-
fi
|
|
433
|
-
fi
|
|
434
|
-
mkdir -p "$dst"
|
|
435
|
-
for f in devzone-guard.js devzone-guard-v2.js; do
|
|
436
|
-
[ -f "$src/$f" ] || continue
|
|
437
|
-
sed "s|__DEVZONE_DOCKER_GARDE__|$script|g" "$src/$f" >"$dst/$f"
|
|
438
|
-
done
|
|
439
|
-
echo "devzone : garde-fou docker actif pour Claude Code et opencode"
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
# Removes only the Docker guard entries (commands containing docker-guard.sh)
|
|
443
|
-
# and the two plugins; the rest of settings.json and of the plugins is kept.
|
|
444
|
-
retirer_garde_docker() {
|
|
445
|
-
local config="$HOME/.claude/settings.json" tmp
|
|
446
|
-
if [ -f "$config" ] && jq -e . "$config" >/dev/null 2>&1; then
|
|
447
|
-
tmp="$(mktemp)"
|
|
448
|
-
if jq '
|
|
449
|
-
if (.hooks.PreToolUse // null) != null then
|
|
450
|
-
.hooks.PreToolUse = [
|
|
451
|
-
.hooks.PreToolUse[] |
|
|
452
|
-
if (.hooks // null) != null then
|
|
453
|
-
.hooks = [ .hooks[] | select(((.command // "") | contains("docker-guard.sh")) | not) ] |
|
|
454
|
-
select((.hooks | length) > 0)
|
|
455
|
-
else
|
|
456
|
-
select(((.command // "") | contains("docker-guard.sh")) | not)
|
|
457
|
-
end
|
|
458
|
-
] |
|
|
459
|
-
if (.hooks.PreToolUse | length) == 0 then del(.hooks.PreToolUse) else . end |
|
|
460
|
-
if ((.hooks // {}) | keys | length) == 0 then del(.hooks) else . end
|
|
461
|
-
else . end
|
|
462
|
-
' "$config" >"$tmp" 2>/dev/null; then
|
|
463
|
-
if [ "$(cat "$tmp")" = "{}" ]; then
|
|
464
|
-
rm -f "$tmp" "$config"
|
|
465
|
-
else
|
|
466
|
-
mv "$tmp" "$config"
|
|
467
|
-
fi
|
|
468
|
-
else
|
|
469
|
-
rm -f "$tmp"
|
|
470
|
-
fi
|
|
471
|
-
fi
|
|
472
|
-
rm -f "$HOME/.config/opencode/plugins/devzone-guard.js" \
|
|
473
|
-
"$HOME/.config/opencode/plugins/devzone-guard-v2.js"
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
appliquer_ia() {
|
|
477
|
-
local journal tmp detectes
|
|
478
|
-
if [ "$1" = on ]; then
|
|
479
|
-
echo "devzone : installation de Claude Code et opencode (quelques minutes)…"
|
|
480
|
-
if ! installer_ia; then
|
|
481
|
-
journal="$(dernier_journal_npm)"
|
|
482
|
-
echo "journal npm : $journal" >"$(fichier_echec ia)"
|
|
483
|
-
echo "devzone : échec de l'installation de ${IA_FAILED[*]} (npm install -g, 3 essais) ; journal npm : $journal ; réessayer : devzone apply" >&2
|
|
484
|
-
return 1
|
|
485
|
-
fi
|
|
486
|
-
rm -f "$(fichier_echec ia)"
|
|
487
|
-
echo "devzone : Claude Code et opencode installés"
|
|
488
|
-
# Garde-fou repowarden (hook PreToolUse de Claude Code, plugin opencode) :
|
|
489
|
-
# agent arrêté avant de modifier main/develop, de commiter sans
|
|
490
|
-
# repowarden cc ou de contourner les hooks. Global, dans les volumes
|
|
491
|
-
# ~/.claude et ~/.config/opencode : gardé aux rebuilds ; relancé, rien ne change
|
|
492
|
-
if command -v repowarden >/dev/null 2>&1 && repowarden agents init --global >/dev/null 2>&1; then
|
|
493
|
-
echo "devzone : garde-fou repowarden actif pour Claude Code et opencode"
|
|
494
|
-
else
|
|
495
|
-
echo "devzone : garde-fou repowarden non branché (repowarden 4.10 ou plus requis) : repowarden agents init --global" >&2
|
|
496
|
-
fi
|
|
497
|
-
poser_garde_docker
|
|
498
|
-
config_opencode
|
|
499
|
-
# Remove the provider of the removed llm module from old configs (#669).
|
|
500
|
-
if [ -f "$HOME/.config/opencode/config.json" ] && command -v jq >/dev/null 2>&1; then
|
|
501
|
-
tmp="$(mktemp)"
|
|
502
|
-
if jq '
|
|
503
|
-
if .provider then del(.provider["devzone-llm"]) | (if .provider == {} then del(.provider) else . end) else . end
|
|
504
|
-
' "$HOME/.config/opencode/config.json" >"$tmp" 2>/dev/null; then
|
|
505
|
-
if [ "$(cat "$tmp")" = "{}" ] || [ "$(jq -c 'del(."$schema") | length' "$tmp" 2>/dev/null)" = 0 ]; then
|
|
506
|
-
rm -f "$tmp" "$HOME/.config/opencode/config.json"
|
|
507
|
-
else
|
|
508
|
-
mv "$tmp" "$HOME/.config/opencode/config.json"
|
|
509
|
-
fi
|
|
510
|
-
else
|
|
511
|
-
rm -f "$tmp"
|
|
512
|
-
fi
|
|
513
|
-
fi
|
|
514
|
-
# Provider opencode des modèles de l'hôte (Ollama), détection à chaud :
|
|
515
|
-
# silencieux et sans effet si Ollama ne répond pas.
|
|
516
|
-
set_provider || true
|
|
517
|
-
# Signale l'état de la détection (succès dans les deux cas).
|
|
518
|
-
detectes="$(modeles 2>/dev/null || true)"
|
|
519
|
-
if [ -n "$detectes" ]; then
|
|
520
|
-
printf "devzone : %s modèle(s) de l'hôte (Ollama) branché(s)\n" "$(printf '%s\n' "$detectes" | grep -c .)"
|
|
521
|
-
else
|
|
522
|
-
printf "devzone : aucun modèle Ollama détecté sur %s (modèles de l'hôte non branchés)\n" "$URL"
|
|
523
|
-
fi
|
|
524
|
-
# Skill devzone : posée si absente, mise à jour si inchangée, gardée si personnalisée.
|
|
525
|
-
poser_skill_devzone
|
|
526
|
-
echo "devzone : ia actif : claude (puis /login), opencode auth login"
|
|
527
|
-
else
|
|
528
|
-
npm uninstall -g "${IA_NOMS[@]}" >/dev/null 2>&1 || true
|
|
529
|
-
rm -f "$(fichier_echec ia)"
|
|
530
|
-
# Garde-fou repowarden : retiré à la désactivation (symétrique de
|
|
531
|
-
# l'activation). repowarden le fait lui-même s'il est présent ; sinon
|
|
532
|
-
# retrait par jq des seules entrées PreToolUse qui appellent le garde-fou,
|
|
533
|
-
# le reste de settings.json intact. Le garde-fou s'appelle « repowarden
|
|
534
|
-
# guard » depuis repowarden 4.17.3 ; « repowarden garde » est son ancien
|
|
535
|
-
# nom, toujours alias côté repowarden et reconnu ici.
|
|
536
|
-
if command -v repowarden >/dev/null 2>&1; then
|
|
537
|
-
repowarden agents retirer --global >/dev/null 2>&1 || true
|
|
538
|
-
elif [ -f "$HOME/.claude/settings.json" ]; then
|
|
539
|
-
tmp="$(mktemp)"
|
|
540
|
-
if jq '
|
|
541
|
-
if (.hooks.PreToolUse // null) != null then
|
|
542
|
-
.hooks.PreToolUse = [
|
|
543
|
-
.hooks.PreToolUse[] |
|
|
544
|
-
if (.hooks // null) != null then
|
|
545
|
-
.hooks = [ .hooks[] | select(((.command // "") | (contains("repowarden garde") or contains("repowarden guard"))) | not) ] |
|
|
546
|
-
select((.hooks | length) > 0)
|
|
547
|
-
else
|
|
548
|
-
select(((.command // "") | (contains("repowarden garde") or contains("repowarden guard"))) | not)
|
|
549
|
-
end
|
|
550
|
-
] |
|
|
551
|
-
if (.hooks.PreToolUse | length) == 0 then del(.hooks.PreToolUse) else . end |
|
|
552
|
-
if ((.hooks // {}) | keys | length) == 0 then del(.hooks) else . end
|
|
553
|
-
else . end
|
|
554
|
-
' "$HOME/.claude/settings.json" >"$tmp" 2>/dev/null; then
|
|
555
|
-
mv "$tmp" "$HOME/.claude/settings.json"
|
|
556
|
-
else
|
|
557
|
-
rm -f "$tmp"
|
|
558
|
-
fi
|
|
559
|
-
fi
|
|
560
|
-
# Plugin opencode du garde-fou (retiré aussi par repowarden ci-dessus)
|
|
561
|
-
rm -f "$HOME/.config/opencode/plugins/repowarden-garde.js" \
|
|
562
|
-
"$HOME/.config/opencode/plugins/repowarden-garde-v2.js"
|
|
563
|
-
# Garde-fou docker : seules ses entrées et ses plugins sont retirés.
|
|
564
|
-
retirer_garde_docker
|
|
565
|
-
# Configuration opencode : retirée seulement si elle porte le repère devzone
|
|
566
|
-
# et n'a pas été modifiée ; personnalisée → gardée.
|
|
567
|
-
retirer_config_opencode
|
|
568
|
-
# Retire le fournisseur opencode des modèles de l'hôte, garde le reste du fichier.
|
|
569
|
-
unset_provider || true
|
|
570
|
-
# Skill devzone : retirée seulement si non modifiée ; personnalisée → gardée.
|
|
571
|
-
retirer_skill_devzone
|
|
572
|
-
# État de devzone agent : gardé dans le volume partagé (désactivation
|
|
573
|
-
# dans l'une des devzone ne supprime pas l'état des autres).
|
|
574
|
-
echo "devzone : ia désactivé (connexions et état de devzone agent gardés dans leurs volumes ; journaux workspace/.agents/ gardés)"
|
|
575
|
-
fi
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
appliquer_kubernetes() {
|
|
579
|
-
if [ "$1" = on ]; then
|
|
580
|
-
bash "$ICI/kube-config.sh"
|
|
581
|
-
else
|
|
582
|
-
rm -f "$HOME/.kube/hote.config"
|
|
583
|
-
# metrics-server retiré des clusters où devzone l'a installé (marqueur
|
|
584
|
-
# devzone=installe posé par metrics-server.sh) ; via sa sous-commande
|
|
585
|
-
bash "$ICI/metrics-server.sh" retirer || true
|
|
586
|
-
echo "devzone : kubernetes désactivé"
|
|
587
|
-
fi
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
appliquer_gitlab() {
|
|
591
|
-
local etat_courant
|
|
592
|
-
if [ "$1" = on ]; then
|
|
593
|
-
# Saut si l'état est prêt et le runner en ligne ; sinon installer reprend
|
|
594
|
-
etat_courant="$(bash "$ICI/gitlab/gitlab.sh" status)"
|
|
595
|
-
if [[ "$etat_courant" == *"prêt"* && "$etat_courant" == *"runner en ligne"* ]]; then
|
|
596
|
-
echo "devzone : gitlab déjà actif, rien à faire."
|
|
597
|
-
# /etc/hosts régénéré par Docker : gitlab.localhost re-pose ici aussi
|
|
598
|
-
bash "$ICI/gitlab/gitlab.sh" hote-poser
|
|
599
|
-
# Échec d'un ancien passage effacé : gitlab est prêt (#366)
|
|
600
|
-
rm -f "$(fichier_echec gitlab)"
|
|
601
|
-
else
|
|
602
|
-
echo "devzone : gitlab activation via installer…"
|
|
603
|
-
if ! bash "$ICI/gitlab/gitlab.sh" install; then
|
|
604
|
-
echo "gitlab" > "$(fichier_echec gitlab)"
|
|
605
|
-
return 1
|
|
606
|
-
fi
|
|
607
|
-
rm -f "$(fichier_echec gitlab)"
|
|
608
|
-
fi
|
|
609
|
-
else
|
|
610
|
-
# Désactiver gitlab seulement si son namespace existe encore
|
|
611
|
-
if bash "$ICI/gitlab/gitlab.sh" installe; then
|
|
612
|
-
echo "devzone : gitlab désactivation…"
|
|
613
|
-
if [ -n "${SUPPRIMER_DONNEES:-}" ]; then
|
|
614
|
-
bash "$ICI/gitlab/gitlab.sh" uninstall --yes
|
|
615
|
-
else
|
|
616
|
-
bash "$ICI/gitlab/gitlab.sh" uninstall
|
|
617
|
-
fi
|
|
618
|
-
else
|
|
619
|
-
echo "devzone : gitlab déjà désactivé (aucun namespace devzone-gitlab)."
|
|
620
|
-
fi
|
|
621
|
-
fi
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
# PostgreSQL partagé (#280) : installé sur le cluster de devzone, choisi à la
|
|
625
|
-
# première activation (--context, menu en terminal, kind dédié sinon)
|
|
626
|
-
appliquer_postgres() {
|
|
627
|
-
local voulu="" confirmer="" attendre="" arg ctx actuel etat_courant
|
|
628
|
-
if [ "$1" = on ]; then
|
|
629
|
-
for arg in "${@:2}"; do
|
|
630
|
-
if [ -n "$attendre" ]; then
|
|
631
|
-
case "$attendre" in
|
|
632
|
-
contexte) voulu="$arg" ;;
|
|
633
|
-
confirmer) confirmer="$arg" ;;
|
|
634
|
-
esac
|
|
635
|
-
attendre=""
|
|
636
|
-
continue
|
|
637
|
-
fi
|
|
638
|
-
case "$arg" in
|
|
639
|
-
--context) attendre=contexte ;;
|
|
640
|
-
--confirm) attendre=confirmer ;;
|
|
641
|
-
*) echo "devzone : argument inconnu : $arg (devzone enable postgres --context CTX [--confirm CTX])" >&2; ecrire postgres off; return 2 ;;
|
|
642
|
-
esac
|
|
643
|
-
done
|
|
644
|
-
if [ -n "$attendre" ]; then
|
|
645
|
-
echo "devzone : $attendre attend un contexte" >&2
|
|
646
|
-
ecrire postgres off
|
|
647
|
-
return 2
|
|
648
|
-
fi
|
|
649
|
-
actuel="$(cluster_lu)"
|
|
650
|
-
if [ -n "$voulu" ] && [ -n "$actuel" ] && [ "$voulu" != "$actuel" ]; then
|
|
651
|
-
echo "devzone : les services de devzone sont sur $actuel ; pour en changer : devzone cluster $voulu" >&2
|
|
652
|
-
ecrire postgres off
|
|
653
|
-
return 2
|
|
654
|
-
fi
|
|
655
|
-
if [ -n "$confirmer" ]; then
|
|
656
|
-
ctx="$(cluster_choisir "$voulu" --confirm "$confirmer")" || { ecrire postgres off; return 2; }
|
|
657
|
-
else
|
|
658
|
-
ctx="$(cluster_choisir "$voulu")" || { ecrire postgres off; return 2; }
|
|
659
|
-
fi
|
|
660
|
-
# Choix gardé avant l'installation : une reprise vise le même cluster
|
|
661
|
-
cluster_ecrire "$ctx"
|
|
662
|
-
etat_courant="$(bash "$ICI/postgres/postgres.sh" status)"
|
|
663
|
-
# « relais arrêté » d'abord : cette ligne commence aussi par « prêt sur »
|
|
664
|
-
if [[ "$etat_courant" == *"relais arrêté"* ]]; then
|
|
665
|
-
bash "$ICI/postgres/postgres.sh" relay-start
|
|
666
|
-
echo "devzone : postgres : relais relancé"
|
|
667
|
-
elif [[ "$etat_courant" == "prêt sur"* ]]; then
|
|
668
|
-
echo "devzone : postgres déjà actif, rien à faire."
|
|
669
|
-
elif ! bash "$ICI/postgres/postgres.sh" install; then
|
|
670
|
-
echo "postgres" >"$(fichier_echec postgres)"
|
|
671
|
-
return 1
|
|
672
|
-
fi
|
|
673
|
-
rm -f "$(fichier_echec postgres)"
|
|
674
|
-
else
|
|
675
|
-
bash "$ICI/postgres/postgres.sh" uninstall
|
|
676
|
-
rm -f "$(fichier_echec postgres)"
|
|
677
|
-
fi
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
# Argo CD (#411) : installé dans le cluster des services, accès par le relais
|
|
681
|
-
# 127.0.0.1:8443 ; un échec est marqué dans l'état et repris par devzone apply
|
|
682
|
-
appliquer_argocd() {
|
|
683
|
-
local etat_courant
|
|
684
|
-
if [ "$1" = on ]; then
|
|
685
|
-
etat_courant="$(bash "$ICI/argocd/argocd.sh" status)"
|
|
686
|
-
# « relais arrêté » d'abord : cette ligne commence aussi par « prêt »
|
|
687
|
-
if [[ "$etat_courant" == *"relais arrêté"* ]]; then
|
|
688
|
-
bash "$ICI/argocd/argocd.sh" relay-start
|
|
689
|
-
echo "devzone : argocd : relais relancé"
|
|
690
|
-
elif [[ "$etat_courant" == "prêt"* ]]; then
|
|
691
|
-
echo "devzone : argocd déjà actif, rien à faire."
|
|
692
|
-
elif ! bash "$ICI/argocd/argocd.sh" install; then
|
|
693
|
-
echo "argocd" >"$(fichier_echec argocd)"
|
|
694
|
-
return 1
|
|
695
|
-
fi
|
|
696
|
-
rm -f "$(fichier_echec argocd)"
|
|
697
|
-
else
|
|
698
|
-
bash "$ICI/argocd/argocd.sh" uninstall
|
|
699
|
-
rm -f "$(fichier_echec argocd)"
|
|
700
|
-
fi
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
# MySQL du catalogue (#414) : même logique que postgres (relais relancé s'il
|
|
704
|
-
# est arrêté), installation déléguée à mysql.sh
|
|
705
|
-
appliquer_mysql() {
|
|
706
|
-
local etat_courant ctx
|
|
707
|
-
if [ "$1" = on ]; then
|
|
708
|
-
ctx="$(cluster_lu)"
|
|
709
|
-
if [ -z "$ctx" ]; then
|
|
710
|
-
echo "devzone : mysql : aucun cluster choisi : devzone enable mysql" >&2
|
|
711
|
-
ecrire mysql off
|
|
712
|
-
echo mysql >"$(fichier_echec mysql)"
|
|
713
|
-
return 2
|
|
714
|
-
fi
|
|
715
|
-
etat_courant="$(bash "$ICI/catalog/mysql/mysql.sh" status)"
|
|
716
|
-
# « relais arrêté » d'abord : cette ligne commence aussi par « prêt sur »
|
|
717
|
-
if [[ "$etat_courant" == *"relais arrêté"* ]]; then
|
|
718
|
-
bash "$ICI/catalog/mysql/mysql.sh" relay-start
|
|
719
|
-
echo "devzone : mysql : relais relancé"
|
|
720
|
-
elif [[ "$etat_courant" == "prêt sur"* ]]; then
|
|
721
|
-
echo "devzone : mysql déjà actif, rien à faire."
|
|
722
|
-
elif ! bash "$ICI/catalog/mysql/mysql.sh" install; then
|
|
723
|
-
echo mysql >"$(fichier_echec mysql)"
|
|
724
|
-
return 1
|
|
725
|
-
fi
|
|
726
|
-
rm -f "$(fichier_echec mysql)"
|
|
727
|
-
else
|
|
728
|
-
# Retrait sans suppression des données : volume gardé (#441) ; les
|
|
729
|
-
# bases ne partent qu'avec un oui (confirmer_suppression)
|
|
730
|
-
bash "$ICI/catalog.sh" remove mysql
|
|
731
|
-
if [ -n "${SUPPRIMER_DONNEES:-}" ]; then
|
|
732
|
-
bash "$ICI/catalog/mysql/mysql.sh" delete-data --yes
|
|
733
|
-
fi
|
|
734
|
-
rm -f "$(fichier_echec mysql)"
|
|
735
|
-
fi
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
# Toutes les bases disparaissent : confirmation en terminal (sans terminal, la
|
|
739
|
-
# commande est explicite) ; un oui ou --yes marque SUPPRIMER_DONNEES, lu par
|
|
740
|
-
# appliquer_mysql pour lancer delete-data (#441). Les arguments passent
|
|
741
|
-
# par reject_renamed : --oui est refusé avant d'arriver ici, seul --yes passe (#695).
|
|
742
|
-
confirmer_suppression() {
|
|
743
|
-
local app="$1" reponse arg
|
|
744
|
-
SUPPRIMER_DONNEES=""
|
|
745
|
-
[ "$(valeur "$app")" = on ] || return 0
|
|
746
|
-
for arg in "${@:2}"; do
|
|
747
|
-
case "$arg" in --yes) SUPPRIMER_DONNEES=1 ;; esac
|
|
748
|
-
done
|
|
749
|
-
[ -z "$SUPPRIMER_DONNEES" ] || return 0
|
|
750
|
-
cluster_interactif || return 0
|
|
751
|
-
# mysql : la question porte sur le namespace (volume et bases restent) ;
|
|
752
|
-
# postgres : tout part, le refus annule ; gitlab : le secret Rails reste,
|
|
753
|
-
# sa suppression n'a lieu que sur une désinstallation complète voulue
|
|
754
|
-
if [ "$app" = mysql ]; then
|
|
755
|
-
printf 'Désactiver mysql retire le serveur, le volume et les bases restent. Supprimer aussi le namespace devzone-mysql et ses volumes ? [o/N] ' >&2
|
|
756
|
-
elif [ "$app" = gitlab ]; then
|
|
757
|
-
printf 'Désactiver gitlab garde le secret Rails (sessions du navigateur valides à la réinstallation). Supprimer aussi le secret Rails ? [o/N] ' >&2
|
|
758
|
-
else
|
|
759
|
-
printf 'Désactiver %s supprime toutes ses bases. Continuer ? [o/N] ' "$app" >&2
|
|
760
|
-
fi
|
|
761
|
-
read -r reponse || reponse=""
|
|
762
|
-
case "$reponse" in
|
|
763
|
-
o | O | oui) SUPPRIMER_DONNEES=1; return 0 ;;
|
|
764
|
-
esac
|
|
765
|
-
# refus : mysql et gitlab désactivent quand même (données gardées), postgres annule
|
|
766
|
-
case "$app" in
|
|
767
|
-
mysql | gitlab) return 0 ;;
|
|
768
|
-
*) echo "Abandon : rien n'a été supprimé."; return 1 ;;
|
|
769
|
-
esac
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
# devzone cluster [CTX] [--yes] : affiche le cluster des services, ou les y
|
|
773
|
-
# déplace (désinstallés de l'ancien, installés sur le nouveau : données non
|
|
774
|
-
# migrées, d'où la confirmation)
|
|
775
|
-
changer_cluster() {
|
|
776
|
-
local voulu="" oui="" confirmer="" attendre="" arg actuel nouveau reponse ctx_ancien ctx_new NS
|
|
777
|
-
NS=devzone-postgres
|
|
778
|
-
for arg in "$@"; do
|
|
779
|
-
if [ -n "$attendre" ]; then
|
|
780
|
-
confirmer="$arg"
|
|
781
|
-
attendre=""
|
|
782
|
-
continue
|
|
783
|
-
fi
|
|
784
|
-
case "$arg" in
|
|
785
|
-
--yes) oui=1 ;;
|
|
786
|
-
--confirm) attendre=1 ;;
|
|
787
|
-
-*) echo "devzone : argument inconnu : $arg (devzone cluster [CTX] [--yes] [--confirm CTX])" >&2; return 2 ;;
|
|
788
|
-
*) voulu="$arg" ;;
|
|
789
|
-
esac
|
|
790
|
-
done
|
|
791
|
-
if [ -n "$attendre" ]; then
|
|
792
|
-
echo "devzone : --confirm attend un contexte" >&2
|
|
793
|
-
return 2
|
|
794
|
-
fi
|
|
795
|
-
actuel="$(cluster_lu)"
|
|
796
|
-
if [ -z "$voulu" ]; then
|
|
797
|
-
if [ -z "$actuel" ]; then
|
|
798
|
-
echo "devzone : aucun cluster choisi (fixé à l'activation d'un module : devzone enable postgres)"
|
|
799
|
-
elif cluster_est_dedie "$actuel"; then
|
|
800
|
-
echo "devzone : cluster $actuel (kind dédié, dans le conteneur)"
|
|
801
|
-
else
|
|
802
|
-
echo "devzone : cluster $actuel (cluster de l'hôte)"
|
|
803
|
-
fi
|
|
804
|
-
echo " possibles : $(cluster_candidats | tr '\n' ' ')"
|
|
805
|
-
return 0
|
|
806
|
-
fi
|
|
807
|
-
if [ -n "$confirmer" ]; then
|
|
808
|
-
nouveau="$(cluster_choisir "$voulu" --confirm "$confirmer")" || return 2
|
|
809
|
-
else
|
|
810
|
-
nouveau="$(cluster_choisir "$voulu")" || return 2
|
|
811
|
-
fi
|
|
812
|
-
if [ "$nouveau" = "$actuel" ]; then
|
|
813
|
-
echo "devzone : déjà sur $nouveau, rien à faire."
|
|
814
|
-
return 0
|
|
815
|
-
fi
|
|
816
|
-
ctx_ancien="$actuel"
|
|
817
|
-
ctx_new="$nouveau"
|
|
818
|
-
if [ "$(valeur postgres)" = on ]; then
|
|
819
|
-
if [ -z "$oui" ]; then
|
|
820
|
-
if ! cluster_interactif; then
|
|
821
|
-
echo "devzone : les bases postgres seront supprimées de $ctx_ancien (non migrées) : devzone cluster $ctx_new --yes" >&2
|
|
822
|
-
return 1
|
|
823
|
-
fi
|
|
824
|
-
printf 'postgres sera réinstallé sur %s, ses bases supprimées de %s (non migrées). Continuer ? [o/N] ' "$ctx_new" "$ctx_ancien" >&2
|
|
825
|
-
read -r reponse || reponse=""
|
|
826
|
-
case "$reponse" in
|
|
827
|
-
o | O | oui) ;;
|
|
828
|
-
*) echo "Abandon : rien n'a changé."; return 0 ;;
|
|
829
|
-
esac
|
|
830
|
-
fi
|
|
831
|
-
# Retire PostgreSQL de l'ancien cluster (contexte explicite) ;
|
|
832
|
-
# namespace et RoleBinding par l'administrateur (#430)
|
|
833
|
-
export KUBECONFIG="$HOME/.kube/config:$HOME/.kube/hote.config"
|
|
834
|
-
compte_retirer "$ctx_ancien" "$NS" >/dev/null 2>&1 || true
|
|
835
|
-
compte_admin "$ctx_ancien" delete namespace "$NS" --wait=true >/dev/null 2>&1 || true
|
|
836
|
-
cluster_liberer "$ctx_ancien"
|
|
837
|
-
# Le nouveau cluster devient le contexte devzone
|
|
838
|
-
cluster_ecrire "$ctx_new"
|
|
839
|
-
# Pose le contexte devzone sur le nouveau cluster (cluster + user :
|
|
840
|
-
# commande importante, échec affiché et rendu #396)
|
|
841
|
-
if ! contexte_devzone_poser "$ctx_new"; then
|
|
842
|
-
echo "devzone : impossible de poser le contexte devzone sur $ctx_new" >&2
|
|
843
|
-
return 1
|
|
844
|
-
fi
|
|
845
|
-
# Installe PostgreSQL sur le nouveau cluster (via --context devzone qui pointe maintenant dessus)
|
|
846
|
-
bash "$ICI/postgres/postgres.sh" install
|
|
847
|
-
else
|
|
848
|
-
cluster_ecrire "$ctx_new"
|
|
849
|
-
# Pose le contexte devzone sur le nouveau cluster (cluster + user :
|
|
850
|
-
# commande importante, échec affiché et rendu #396)
|
|
851
|
-
if ! contexte_devzone_poser "$ctx_new"; then
|
|
852
|
-
echo "devzone : impossible de poser le contexte devzone sur $ctx_new" >&2
|
|
853
|
-
return 1
|
|
854
|
-
fi
|
|
855
|
-
fi
|
|
856
|
-
echo "devzone : cluster des services : $ctx_new"
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
# ---- Plateforme : GitHub (défaut) ou GitLab (#240) ----
|
|
860
|
-
# Choix gardé dans le fichier d'état (plateforme=, gitlab_url=), propre à
|
|
861
|
-
# chaque instance ; la configuration d'un service n'existe que pendant qu'il
|
|
862
|
-
# est choisi (#242) : glab et l'URL disparaissent au retour à github.
|
|
863
|
-
|
|
864
|
-
# Plateforme courante : github en l'absence de ligne (défaut)
|
|
865
|
-
plateforme_lue() {
|
|
866
|
-
local v
|
|
867
|
-
v="$(grep -E '^plateforme=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2 || true)"
|
|
868
|
-
[ "$v" = gitlab ] && echo gitlab || echo github
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
# URL de l'instance GitLab, rien si absente
|
|
872
|
-
url_gitlab_lue() {
|
|
873
|
-
grep -E '^gitlab_url=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2- || true
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
# Hôte d'une URL, sans son protocole (glab --hostname)
|
|
877
|
-
hote_de() {
|
|
878
|
-
echo "$1" | sed -E 's#^[a-z]+://##; s#/$##'
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
# Retire glab et sa configuration (retour à github)
|
|
882
|
-
retirer_glab() {
|
|
883
|
-
rm -f "$GLAB"
|
|
884
|
-
rm -rf "$HOME/.config/glab-cli"
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
# Ligne de l'état pour la plateforme : github par défaut, ou l'instance GitLab
|
|
888
|
-
# avec son instance connectée (glab) sur la commande de connexion sinon
|
|
889
|
-
ligne_plateforme() {
|
|
890
|
-
local url hote
|
|
891
|
-
if [ "$(plateforme_lue)" = gitlab ]; then
|
|
892
|
-
url="$(url_gitlab_lue)"
|
|
893
|
-
hote="$(hote_de "$url")"
|
|
894
|
-
if [ -x "$GLAB" ] && "$GLAB" auth status --hostname "$hote" >/dev/null 2>&1; then
|
|
895
|
-
printf ' ✔ plateforme gitlab : %s, glab connecté\n' "$url"
|
|
896
|
-
else
|
|
897
|
-
printf ' ⚠ plateforme gitlab : %s, glab non connecté : glab auth login --hostname %s\n' "$url" "$hote"
|
|
898
|
-
fi
|
|
899
|
-
else
|
|
900
|
-
echo " ✔ plateforme github"
|
|
901
|
-
fi
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
# Affichage simple de la plateforme (devzone platform)
|
|
905
|
-
resume_plateforme() {
|
|
906
|
-
local url hote
|
|
907
|
-
if [ "$(plateforme_lue)" = gitlab ]; then
|
|
908
|
-
url="$(url_gitlab_lue)"
|
|
909
|
-
hote="$(hote_de "$url")"
|
|
910
|
-
if [ -x "$GLAB" ] && "$GLAB" auth status --hostname "$hote" >/dev/null 2>&1; then
|
|
911
|
-
echo "devzone : plateforme gitlab : $url, glab connecté"
|
|
912
|
-
else
|
|
913
|
-
echo "devzone : plateforme gitlab : $url, glab non connecté : glab auth login --hostname $hote"
|
|
914
|
-
fi
|
|
915
|
-
else
|
|
916
|
-
echo "devzone : plateforme github (défaut)"
|
|
917
|
-
fi
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
# Installe glab (release officielle, somme SHA-256 vérifiée), rien s'il est
|
|
921
|
-
# déjà là ; le binaire finit dans ~/.local/bin (retirer_glab l'enlève)
|
|
922
|
-
installer_glab() {
|
|
923
|
-
local arch="" somme archive dossier glab_tmp
|
|
924
|
-
if [ -x "$GLAB" ] && "$GLAB" --version >/dev/null 2>&1; then
|
|
925
|
-
return 0
|
|
926
|
-
fi
|
|
927
|
-
case "$(uname -m)" in
|
|
928
|
-
arm64 | aarch64) arch=arm64 somme="$GLAB_SOMME_ARM64" ;;
|
|
929
|
-
*) arch=amd64 somme="$GLAB_SOMME_AMD64" ;;
|
|
930
|
-
esac
|
|
931
|
-
echo "devzone : téléchargement de glab $GLAB_VERSION (somme SHA-256 vérifiée)…"
|
|
932
|
-
archive="$(mktemp)"
|
|
933
|
-
if ! curl -fsSL -o "$archive" "https://gitlab.com/gitlab-org/cli/-/releases/$GLAB_VERSION/downloads/glab_${GLAB_VERSION#v}_linux_${arch}.tar.gz"; then
|
|
934
|
-
rm -f "$archive"
|
|
935
|
-
echo "devzone : téléchargement de glab impossible (release officielle de gitlab.com) ; réessayer : devzone platform gitlab --url URL" >&2
|
|
936
|
-
return 1
|
|
937
|
-
fi
|
|
938
|
-
if [ "$(sha256sum "$archive" | cut -d' ' -f1)" != "$somme" ]; then
|
|
939
|
-
rm -f "$archive"
|
|
940
|
-
echo "devzone : somme SHA-256 de glab inattendue, abandon ; archive refusée" >&2
|
|
941
|
-
return 1
|
|
942
|
-
fi
|
|
943
|
-
dossier="$(mktemp -d)"
|
|
944
|
-
glab_tmp="$dossier/bin/glab"
|
|
945
|
-
if ! tar -xzf "$archive" -C "$dossier" || [ ! -f "$glab_tmp" ]; then
|
|
946
|
-
glab_tmp="$dossier/glab"
|
|
947
|
-
fi
|
|
948
|
-
if [ ! -f "$glab_tmp" ]; then
|
|
949
|
-
rm -rf "$dossier" "$archive"
|
|
950
|
-
echo "devzone : binaire glab absent de l'archive, abandon" >&2
|
|
951
|
-
return 1
|
|
952
|
-
fi
|
|
953
|
-
mkdir -p "$HOME/.local/bin"
|
|
954
|
-
mv "$glab_tmp" "$GLAB"
|
|
955
|
-
chmod +x "$GLAB"
|
|
956
|
-
rm -rf "$dossier" "$archive"
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
# Connexion à l'instance GitLab : instance du module gitlab → jeton root du
|
|
960
|
-
# module (protocole http, jamais affiché) ; autre instance → interactive, un
|
|
961
|
-
# navigateur demandant le code de connexion. Vérifie : code de sortie de
|
|
962
|
-
# l'auth login, puis auth status --hostname ; sans contrôle, pas « connecté ».
|
|
963
|
-
connexion_glab() {
|
|
964
|
-
local hote="$1" url="$2" jeton
|
|
965
|
-
if [ "$url" = "$GITLAB_URL_MODULE" ]; then
|
|
966
|
-
if [ ! -f "$RACINE/workspace/.gitlab/root-token" ]; then
|
|
967
|
-
echo "devzone : jeton root du module gitlab introuvable ($RACINE/workspace/.gitlab/root-token) : devzone enable gitlab, ou à la main : glab auth login --hostname $hote" >&2
|
|
968
|
-
return 1
|
|
969
|
-
fi
|
|
970
|
-
jeton="$(cat "$RACINE/workspace/.gitlab/root-token")"
|
|
971
|
-
if ! "$GLAB" auth login --hostname "$hote" --api-protocol http --git-protocol http --token "$jeton"; then
|
|
972
|
-
echo "devzone : connexion à l'instance gitlab impossible : devzone enable gitlab, ou à la main : glab auth login --hostname $hote" >&2
|
|
973
|
-
return 1
|
|
974
|
-
fi
|
|
975
|
-
elif ! "$GLAB" auth login --hostname "$hote"; then
|
|
976
|
-
echo "devzone : connexion à l'instance gitlab impossible : glab auth login --hostname $hote" >&2
|
|
977
|
-
return 1
|
|
978
|
-
fi
|
|
979
|
-
if ! "$GLAB" auth status --hostname "$hote" >/dev/null 2>&1; then
|
|
980
|
-
echo "devzone : verification de la connexion impossible : glab auth status --hostname $hote" >&2
|
|
981
|
-
return 1
|
|
982
|
-
fi
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
# Change la plateforme : github (par défaut, comportement actuel) ou gitlab
|
|
986
|
-
changer_plateforme() {
|
|
987
|
-
local cible="${1:-}" url="" attendre="" arg hote
|
|
988
|
-
case "$cible" in
|
|
989
|
-
github)
|
|
990
|
-
# Retire le réglage credential du dernier hôte gitlab, s'il y en a un
|
|
991
|
-
if [ -n "$(url_gitlab_lue)" ]; then
|
|
992
|
-
git config --global --unset-all "credential.$(url_gitlab_lue).helper" 2>/dev/null || true
|
|
993
|
-
fi
|
|
994
|
-
retirer_glab
|
|
995
|
-
retirer_cle plateforme
|
|
996
|
-
retirer_cle gitlab_url
|
|
997
|
-
echo "devzone : plateforme github (défaut) : contrôles gh ; glab et sa configuration retirés s'ils étaient installés"
|
|
998
|
-
;;
|
|
999
|
-
gitlab)
|
|
1000
|
-
for arg in "${@:2}"; do
|
|
1001
|
-
if [ -n "$attendre" ]; then url="$arg"; attendre=""; continue; fi
|
|
1002
|
-
case "$arg" in
|
|
1003
|
-
--url) attendre=1 ;;
|
|
1004
|
-
*) echo "devzone : argument inconnu : $arg (devzone platform gitlab --url URL)" >&2; return 1 ;;
|
|
1005
|
-
esac
|
|
1006
|
-
done
|
|
1007
|
-
if [ -n "$attendre" ]; then
|
|
1008
|
-
echo "devzone : --url attend une URL" >&2
|
|
1009
|
-
return 1
|
|
1010
|
-
fi
|
|
1011
|
-
if [ -z "$url" ]; then
|
|
1012
|
-
if [ "$(valeur gitlab)" = on ]; then
|
|
1013
|
-
url="$GITLAB_URL_MODULE"
|
|
1014
|
-
else
|
|
1015
|
-
echo "devzone : URL manquante : devzone platform gitlab --url URL (ou un module gitlab actif pour l'instance locale)" >&2
|
|
1016
|
-
return 1
|
|
1017
|
-
fi
|
|
1018
|
-
fi
|
|
1019
|
-
hote="$(hote_de "$url")"
|
|
1020
|
-
if ! installer_glab; then
|
|
1021
|
-
return 1
|
|
1022
|
-
fi
|
|
1023
|
-
if ! connexion_glab "$hote" "$url"; then
|
|
1024
|
-
echo "devzone : connexion à refaire : glab auth login --hostname $hote" >&2
|
|
1025
|
-
return 1
|
|
1026
|
-
fi
|
|
1027
|
-
if ! git config --global "credential.$url.helper" "!$GLAB auth git-credential"; then
|
|
1028
|
-
echo "devzone : réglage git credential impossible" >&2
|
|
1029
|
-
return 1
|
|
1030
|
-
fi
|
|
1031
|
-
ecrire plateforme gitlab
|
|
1032
|
-
ecrire gitlab_url "$url"
|
|
1033
|
-
echo "devzone : plateforme gitlab : $url, glab connecté"
|
|
1034
|
-
;;
|
|
1035
|
-
*)
|
|
1036
|
-
echo "devzone : plateforme inconnue : ${cible:-(aucune)} ; choix : github (défaut) ou gitlab [--url URL]" >&2
|
|
1037
|
-
return 1
|
|
1038
|
-
;;
|
|
1039
|
-
esac
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
# Lignes « paquet figée installée » des outils en retard ; échoue si le script
|
|
1043
|
-
# versions.sh est absent ou ne peut pas répondre (l'état omet alors la ligne)
|
|
1044
|
-
outils_retard() {
|
|
1045
|
-
[ -f "$VERSIONS" ] || return 1
|
|
1046
|
-
bash "$VERSIONS" --installees 2>/dev/null
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
# Remet repowarden à la version figée s'il en diffère, comme post-create.sh
|
|
1050
|
-
# (il installe les hooks git globaux)
|
|
1051
|
-
appliquer_repowarden() {
|
|
1052
|
-
local ligne figee installee paquet=repowarden
|
|
1053
|
-
[ -f "$VERSIONS" ] || return 0
|
|
1054
|
-
ligne="$(bash "$VERSIONS" --installees 2>/dev/null | awk '$1 == "repowarden"' || true)"
|
|
1055
|
-
[ -n "$ligne" ] || return 0
|
|
1056
|
-
read -r _ figee installee <<<"$ligne"
|
|
1057
|
-
echo "devzone : installation de repowarden ${figee}…"
|
|
1058
|
-
npm install -g "$paquet@$figee" >/dev/null
|
|
1059
|
-
repowarden install --global --lang fr
|
|
1060
|
-
echo "devzone : repowarden $installee → $figee"
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
# Chemins des worktrees du dépôt devzone et des dépôts du workspace absents
|
|
1064
|
-
# ici : créés de l'autre côté (hôte), un git worktree prune les casserait.
|
|
1065
|
-
# Lecture seule : rien n'est supprimé ni réparé.
|
|
1066
|
-
worktrees_absents() {
|
|
1067
|
-
local depot ligne chemin
|
|
1068
|
-
{
|
|
1069
|
-
[ -e "$RACINE/.git" ] && echo "$RACINE"
|
|
1070
|
-
find "$RACINE/workspace" -mindepth 2 -maxdepth 3 -name .git -type d 2>/dev/null | sed 's|/\.git$||'
|
|
1071
|
-
} | while IFS= read -r depot; do
|
|
1072
|
-
{ git -C "$depot" worktree list --porcelain 2>/dev/null || true; } | while IFS= read -r ligne; do
|
|
1073
|
-
case "$ligne" in
|
|
1074
|
-
"worktree "*)
|
|
1075
|
-
chemin="${ligne#worktree }"
|
|
1076
|
-
[ -d "$chemin" ] || echo "$chemin"
|
|
1077
|
-
;;
|
|
1078
|
-
esac
|
|
1079
|
-
done
|
|
1080
|
-
done || true
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
# Version du dossier devzone (manifeste écrit par la CLI du poste), rien si
|
|
1084
|
-
# le dossier vient d'avant le manifeste
|
|
1085
|
-
version_du_dossier() {
|
|
1086
|
-
local v
|
|
1087
|
-
[ -f "$RACINE/.devzone.version" ] || return 1
|
|
1088
|
-
v="$(sed -n '1s/^version //p' "$RACINE/.devzone.version" 2>/dev/null | head -1 || true)"
|
|
1089
|
-
[ -n "$v" ] || return 1
|
|
1090
|
-
printf '%s\n' "$v"
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
# Vrai si la première version est plus récente que la seconde
|
|
1094
|
-
version_plus_recente() {
|
|
1095
|
-
awk -v a="$1" -v b="$2" 'BEGIN {
|
|
1096
|
-
na = split(a, x, ".")
|
|
1097
|
-
nb = split(b, y, ".")
|
|
1098
|
-
n = (na > nb ? na : nb)
|
|
1099
|
-
for (i = 1; i <= n; i++) {
|
|
1100
|
-
p = (i <= na ? x[i] : 0) + 0
|
|
1101
|
-
q = (i <= nb ? y[i] : 0) + 0
|
|
1102
|
-
if (p > q) exit 0
|
|
1103
|
-
if (p < q) exit 1
|
|
1104
|
-
}
|
|
1105
|
-
exit 1
|
|
1106
|
-
}'
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
# Version publiée sur npm, au plus une fois par jour, en cache sous
|
|
1110
|
-
# ~/.cache/devzone/ ; 5 s au plus, silencieux hors ligne
|
|
1111
|
-
version_publiee() {
|
|
1112
|
-
local cache jour npm v temporal pid attente
|
|
1113
|
-
cache="$HOME/.cache/devzone/version-publiee"
|
|
1114
|
-
jour="$(date +%Y-%m-%d)"
|
|
1115
|
-
if [ -f "$cache" ] && [ "$(sed -n '1p' "$cache" 2>/dev/null || true)" = "$jour" ]; then
|
|
1116
|
-
sed -n '2p' "$cache" 2>/dev/null || true
|
|
1117
|
-
return 0
|
|
1118
|
-
fi
|
|
1119
|
-
npm="${DEVZONE_NPM:-npm}"
|
|
1120
|
-
v=""
|
|
1121
|
-
if command -v "$npm" >/dev/null 2>&1; then
|
|
1122
|
-
mkdir -p "$(dirname "$cache")" 2>/dev/null || true
|
|
1123
|
-
temporal="$cache.$$"
|
|
1124
|
-
"$npm" view devzone version >"$temporal" 2>/dev/null &
|
|
1125
|
-
pid=$!
|
|
1126
|
-
attente=0
|
|
1127
|
-
while kill -0 "$pid" 2>/dev/null; do
|
|
1128
|
-
sleep 1
|
|
1129
|
-
attente=$((attente + 1))
|
|
1130
|
-
if [ "$attente" -ge 5 ]; then
|
|
1131
|
-
kill "$pid" 2>/dev/null || true
|
|
1132
|
-
break
|
|
1133
|
-
fi
|
|
1134
|
-
done
|
|
1135
|
-
wait "$pid" 2>/dev/null || true
|
|
1136
|
-
v="$(sed -n '1p' "$temporal" 2>/dev/null | tr -d '[:space:]' || true)"
|
|
1137
|
-
rm -f "$temporal"
|
|
1138
|
-
fi
|
|
1139
|
-
mkdir -p "$(dirname "$cache")" 2>/dev/null || true
|
|
1140
|
-
printf '%s\n%s\n' "$jour" "$v" >"$cache" 2>/dev/null || true
|
|
1141
|
-
[ -n "$v" ] && printf '%s\n' "$v"
|
|
1142
|
-
return 0
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
ligne_version_disponible() {
|
|
1146
|
-
local dossier publiee
|
|
1147
|
-
dossier="$(version_du_dossier)" || return 0
|
|
1148
|
-
publiee="$(version_publiee)" || return 0
|
|
1149
|
-
publiee="${publiee#v}"
|
|
1150
|
-
[ -n "$publiee" ] || return 0
|
|
1151
|
-
if version_plus_recente "$publiee" "$dossier"; then
|
|
1152
|
-
printf ' ○ devzone %s available: on the workstation, devzone update\n' "$publiee"
|
|
1153
|
-
fi
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
# Réparation (#341) : reprend la suite de startup.sh sans l'identité git ni
|
|
1157
|
-
# les clusters. Chaque élément est réparé pour de vrai ; ✔ ou ✖ avec la raison.
|
|
1158
|
-
reparer_element() {
|
|
1159
|
-
local nom="$1" sortie code raison
|
|
1160
|
-
shift
|
|
1161
|
-
if sortie="$("$@" 2>&1)"; then
|
|
1162
|
-
echo "✔ $nom"
|
|
1163
|
-
else
|
|
1164
|
-
code=$?
|
|
1165
|
-
raison="$(printf '%s\n' "$sortie" | sed '/^[[:space:]]*$/d' | tail -1)"
|
|
1166
|
-
[ -n "$raison" ] || raison="échec (code $code)"
|
|
1167
|
-
echo "✖ $nom : $raison"
|
|
1168
|
-
reparer_echec=1
|
|
1169
|
-
fi
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
# Réparations de l'application (#341) : relais Docker, services actifs, ports
|
|
1173
|
-
# et identifiants ; un échec n'empêche pas les suivants.
|
|
1174
|
-
reparer() {
|
|
1175
|
-
reparer_echec=0
|
|
1176
|
-
reparer_element "relais Docker" env DEVZONE_RELAIS_REEL=oui bash "$ICI/docker-relay.sh"
|
|
1177
|
-
# Jeton du compte Kubernetes limité (#430) : 24 h, renouvelé ici ; sans
|
|
1178
|
-
# module kubernetes et sans cluster des services, rien à faire
|
|
1179
|
-
if [ "$(valeur kubernetes)" = on ] || [ -n "$(cluster_lu)" ]; then
|
|
1180
|
-
reparer_element "compte kubernetes" bash "$ICI/kube-account.sh" jeton
|
|
1181
|
-
fi
|
|
1182
|
-
if [ "$(valeur gitlab)" = on ]; then
|
|
1183
|
-
reparer_element "nom gitlab" bash "$ICI/gitlab/gitlab.sh" hote-poser
|
|
1184
|
-
reparer_element "relais gitlab" bash "$ICI/gitlab/gitlab.sh" relay-start
|
|
1185
|
-
fi
|
|
1186
|
-
if [ "$(valeur postgres)" = on ]; then
|
|
1187
|
-
reparer_element "relais postgres" bash "$ICI/postgres/postgres.sh" relay-start
|
|
1188
|
-
fi
|
|
1189
|
-
if [ "$(valeur argocd)" = on ]; then
|
|
1190
|
-
reparer_element "relais argocd" bash "$ICI/argocd/argocd.sh" relay-start
|
|
1191
|
-
fi
|
|
1192
|
-
if [ "$(valeur mysql)" = on ]; then
|
|
1193
|
-
reparer_element "relais mysql" bash "$ICI/catalog/mysql/mysql.sh" relay-start
|
|
1194
|
-
fi
|
|
1195
|
-
reparer_element "relais de ports" bash "$ICI/ports.sh" restart
|
|
1196
|
-
# Kubernetes workspace (#517): no automatic port watcher
|
|
1197
|
-
if ! dans_pod; then
|
|
1198
|
-
reparer_element "veilleur ports auto" env DEVZONE_PORTS_AUTO_REEL=oui bash "$ICI/ports-auto.sh" demarrer
|
|
1199
|
-
fi
|
|
1200
|
-
reparer_element "veilleur catalogue" env DEVZONE_CATALOGUE_REEL=oui bash "$ICI/catalog/catalog-watcher.sh" demarrer
|
|
1201
|
-
reparer_element "identifiants" bash "$ICI/password.sh" regenerer
|
|
1202
|
-
return "$reparer_echec"
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
# Bascule le cluster de travail de l'utilisateur (#341). Ne touche jamais au
|
|
1206
|
-
# cluster des services de devzone : aucun cluster_ecrire, aucune ligne
|
|
1207
|
-
# cluster= dans l'état.
|
|
1208
|
-
utiliser() {
|
|
1209
|
-
local ctx="" confirmer="" namespace="" reponse arg courant
|
|
1210
|
-
while [ "$#" -gt 0 ]; do
|
|
1211
|
-
arg="$1"
|
|
1212
|
-
shift
|
|
1213
|
-
case "$arg" in
|
|
1214
|
-
-n | --namespace)
|
|
1215
|
-
if [ "$#" -eq 0 ]; then
|
|
1216
|
-
echo "devzone : -n attend un namespace" >&2
|
|
1217
|
-
return 2
|
|
1218
|
-
fi
|
|
1219
|
-
namespace="$1"
|
|
1220
|
-
shift
|
|
1221
|
-
;;
|
|
1222
|
-
--namespace=*) namespace="${arg#*=}" ;;
|
|
1223
|
-
--confirm)
|
|
1224
|
-
if [ "$#" -eq 0 ]; then
|
|
1225
|
-
echo "devzone : --confirm attend un contexte" >&2
|
|
1226
|
-
return 2
|
|
1227
|
-
fi
|
|
1228
|
-
confirmer="$1"
|
|
1229
|
-
shift
|
|
1230
|
-
;;
|
|
1231
|
-
--confirm=*) confirmer="${arg#*=}" ;;
|
|
1232
|
-
-*)
|
|
1233
|
-
echo "devzone : argument inconnu : $arg (devzone use CTX [-n NS] [--confirm CTX])" >&2
|
|
1234
|
-
return 2
|
|
1235
|
-
;;
|
|
1236
|
-
*)
|
|
1237
|
-
if [ -n "$ctx" ]; then
|
|
1238
|
-
echo "devzone : argument inconnu : $arg (devzone use CTX [-n NS] [--confirm CTX])" >&2
|
|
1239
|
-
return 2
|
|
1240
|
-
fi
|
|
1241
|
-
ctx="$arg"
|
|
1242
|
-
;;
|
|
1243
|
-
esac
|
|
1244
|
-
done
|
|
1245
|
-
if [ -z "$ctx" ]; then
|
|
1246
|
-
if [ -z "$namespace" ]; then
|
|
1247
|
-
echo "devzone : contexte manquant : devzone use CTX" >&2
|
|
1248
|
-
return 2
|
|
1249
|
-
fi
|
|
1250
|
-
courant="$(kubectl config current-context 2>/dev/null || true)"
|
|
1251
|
-
if [ -z "$courant" ]; then
|
|
1252
|
-
echo "devzone : aucun contexte courant" >&2
|
|
1253
|
-
return 2
|
|
1254
|
-
fi
|
|
1255
|
-
ctx="$courant"
|
|
1256
|
-
fi
|
|
1257
|
-
if ! kubectl config get-contexts -o name 2>/dev/null | grep -qxF -- "$ctx"; then
|
|
1258
|
-
echo "devzone : contexte inconnu : $ctx (voir kubectl config get-contexts)" >&2
|
|
1259
|
-
return 2
|
|
1260
|
-
fi
|
|
1261
|
-
courant="$(kubectl config current-context 2>/dev/null || true)"
|
|
1262
|
-
if [ "$ctx" != "$courant" ]; then
|
|
1263
|
-
if ! cluster_est_local "$ctx"; then
|
|
1264
|
-
if [ -n "$confirmer" ]; then
|
|
1265
|
-
if [ "$confirmer" != "$ctx" ]; then
|
|
1266
|
-
echo "devzone : cluster distant refusé : $ctx (--confirm $ctx)" >&2
|
|
1267
|
-
return 2
|
|
1268
|
-
fi
|
|
1269
|
-
elif cluster_interactif; then
|
|
1270
|
-
printf 'cluster distant : %s ; tape son nom pour confirmer : ' "$ctx" >&2
|
|
1271
|
-
read -r reponse || reponse=""
|
|
1272
|
-
if [ "$reponse" != "$ctx" ]; then
|
|
1273
|
-
echo "devzone : cluster distant refusé : $ctx (--confirm $ctx)" >&2
|
|
1274
|
-
return 2
|
|
1275
|
-
fi
|
|
1276
|
-
else
|
|
1277
|
-
echo "devzone : cluster distant refusé : $ctx (--confirm $ctx)" >&2
|
|
1278
|
-
return 2
|
|
1279
|
-
fi
|
|
1280
|
-
fi
|
|
1281
|
-
kubectl config use-context "$ctx" >/dev/null
|
|
1282
|
-
fi
|
|
1283
|
-
if [ -n "$namespace" ]; then
|
|
1284
|
-
kubectl config set-context "$ctx" --namespace "$namespace" >/dev/null
|
|
1285
|
-
fi
|
|
1286
|
-
echo "cluster de travail : $ctx"
|
|
1287
|
-
[ -z "$namespace" ] || echo "namespace : $namespace"
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
# État complet : ✔ prêt, ✖ nécessaire, ○ facultatif, ⚠ à corriger ; chaque
|
|
1291
|
-
# point à faire avec sa commande (affiché à chaque démarrage)
|
|
1292
|
-
etat() {
|
|
1293
|
-
local nom email statut m retards chemin ports_etat relais_marque ctx_travail ctx_hote paquets_marque paquets_noms argocd_repo
|
|
1294
|
-
echo "devzone: state (devzone to show it again)"
|
|
1295
|
-
ligne_version_disponible
|
|
1296
|
-
nom="$(git config --get user.name || true)"
|
|
1297
|
-
email="$(git config --get user.email || true)"
|
|
1298
|
-
if [ -n "$nom" ] && [ -n "$email" ]; then
|
|
1299
|
-
echo " ✔ git identity $nom <$email>"
|
|
1300
|
-
else
|
|
1301
|
-
echo " ✖ git identity needed to commit: gh auth login -s workflow (automatic),"
|
|
1302
|
-
echo " ou git config --file ~/.config/git/config user.name \"<nom>\" et user.email \"<email>\""
|
|
1303
|
-
fi
|
|
1304
|
-
if [ "$(plateforme_lue)" = gitlab ]; then
|
|
1305
|
-
# Plateforme gitlab : l'instance et glab, puis les lignes propres à
|
|
1306
|
-
# GitHub (contrôles gh) signalées comme non applicables ici, en
|
|
1307
|
-
# attendant le support GitLab de repowarden (#531)
|
|
1308
|
-
ligne_plateforme
|
|
1309
|
-
url="$(url_gitlab_lue)"
|
|
1310
|
-
if git config --global --get "credential.$url.helper" 2>/dev/null | grep -q 'glab auth git-credential'; then
|
|
1311
|
-
echo " ✔ git via glab"
|
|
1312
|
-
else
|
|
1313
|
-
echo " ⚠ git via glab to set: devzone platform gitlab"
|
|
1314
|
-
fi
|
|
1315
|
-
echo " ○ GitHub inutile ici (plateforme gitlab choisie)"
|
|
1316
|
-
echo " ⚠ repowarden reste sur GitHub (bots et tickets) : support GitLab à venir (simdevWarden/repowarden#531)"
|
|
1317
|
-
else
|
|
1318
|
-
ligne_plateforme
|
|
1319
|
-
if ! statut="$(gh auth status 2>&1)"; then
|
|
1320
|
-
echo " ○ GitHub optional (push and PR, repowarden tickets) : gh auth login -s workflow"
|
|
1321
|
-
elif grep -q "Token scopes:" <<<"$statut" && ! grep -q "'workflow'" <<<"$statut"; then
|
|
1322
|
-
echo " ⚠ GitHub connecté, sans permission workflow (push de .github/workflows/ refusé) : gh auth refresh -h github.com -s workflow"
|
|
1323
|
-
else
|
|
1324
|
-
echo " ✔ GitHub connecté"
|
|
1325
|
-
fi
|
|
1326
|
-
fi
|
|
1327
|
-
if retards="$(outils_retard)"; then
|
|
1328
|
-
if [ -z "$retards" ]; then
|
|
1329
|
-
echo " ✔ tools pinned versions"
|
|
1330
|
-
else
|
|
1331
|
-
while read -r paquet figee installee; do
|
|
1332
|
-
[ -n "$paquet" ] || continue
|
|
1333
|
-
echo " ⚠ tools $paquet $installee installed, $figee pinned: devzone apply"
|
|
1334
|
-
done <<<"$retards"
|
|
1335
|
-
fi
|
|
1336
|
-
fi
|
|
1337
|
-
while IFS= read -r chemin; do
|
|
1338
|
-
[ -n "$chemin" ] || continue
|
|
1339
|
-
echo " ⚠ worktree $chemin absent ici (créé hors du conteneur ?) : le gérer de ce côté-là, jamais git worktree prune ici (manage/docs/reference.md, Worktrees git)"
|
|
1340
|
-
done < <(worktrees_absents)
|
|
1341
|
-
for m in "${MODULES[@]}"; do
|
|
1342
|
-
if dans_pod && service_module "$m"; then
|
|
1343
|
-
# Kubernetes workspace pod (#528): presence by the cluster DNS
|
|
1344
|
-
service_ligne_pod "$m"
|
|
1345
|
-
elif [ "$(valeur "$m")" = on ] && [ -f "$(fichier_echec "$m")" ]; then
|
|
1346
|
-
printf ' ✖ module %-10s failed: incomplete install (%s): devzone apply\n' "$m" "$(cat "$(fichier_echec "$m")")"
|
|
1347
|
-
elif [ "$(valeur "$m")" = on ] && [ "$m" = gitlab ]; then
|
|
1348
|
-
# GitLab actif : son état réel (prêt, runner, en échec)
|
|
1349
|
-
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/gitlab/gitlab.sh" status)"
|
|
1350
|
-
elif [ "$(valeur "$m")" = on ] && [ "$m" = postgres ]; then
|
|
1351
|
-
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/$m/$m.sh" status)"
|
|
1352
|
-
elif [ "$(valeur "$m")" = on ] && [ "$m" = argocd ]; then
|
|
1353
|
-
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/argocd/argocd.sh" status)"
|
|
1354
|
-
elif [ "$(valeur "$m")" = on ] && [ "$m" = mysql ]; then
|
|
1355
|
-
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/catalog/mysql/mysql.sh" status)"
|
|
1356
|
-
elif [ "$(valeur "$m")" = on ]; then
|
|
1357
|
-
printf ' ✔ module %-10s active: %s\n' "$m" "$(description "$m")"
|
|
1358
|
-
else
|
|
1359
|
-
printf ' ○ module %-10s optional, %s: devzone enable %s\n' "$m" "$(description "$m")" "$m"
|
|
1360
|
-
fi
|
|
1361
|
-
done
|
|
1362
|
-
# GitOps repository of the instance (#539): the designation of .argocd.conf
|
|
1363
|
-
argocd_repo="$(conf_get argocd repo)"
|
|
1364
|
-
if [ -n "$argocd_repo" ] && [ "$argocd_repo" != none ]; then
|
|
1365
|
-
printf ' ○ argocd GitOps repository: %s\n' "$argocd_repo"
|
|
1366
|
-
elif dans_pod; then
|
|
1367
|
-
gitops_state_line
|
|
1368
|
-
else
|
|
1369
|
-
printf ' ○ argocd no GitOps repository: devzone argocd init\n'
|
|
1370
|
-
fi
|
|
1371
|
-
# Socket Docker de l'hôte (#432) : l'avertissement montre l'état réel,
|
|
1372
|
-
# le socket monté (même variable que docker-relay.sh), pas l'option :
|
|
1373
|
-
# le montage ne change qu'au make rebuild (faux rassurant en attendant)
|
|
1374
|
-
# In the Kubernetes workspace (DEVZONE_WORKSPACE=kubernetes), the pod has
|
|
1375
|
-
# no Docker host socket: no alert, the service account is the cluster access
|
|
1376
|
-
if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
|
|
1377
|
-
printf ' ✔ workspace Kubernetes pod, service account access only (no Docker socket)\n'
|
|
1378
|
-
else
|
|
1379
|
-
relais_source="${DEVZONE_RELAIS_SOURCE:-/var/run/docker-host.sock}"
|
|
1380
|
-
if [ -e "$relais_source" ] && [ "$(valeur docker-hote)" = on ]; then
|
|
1381
|
-
printf ' ⚠ socket Docker de l hôte partagé (agents compris)\n'
|
|
1382
|
-
elif [ -e "$relais_source" ]; then
|
|
1383
|
-
printf ' ⚠ socket Docker de l hôte encore partagé : make rebuild sur le poste\n'
|
|
1384
|
-
elif [ "$(valeur docker-hote)" = on ]; then
|
|
1385
|
-
printf ' ⚠ socket Docker de l hôte absent : make rebuild sur le poste\n'
|
|
1386
|
-
fi
|
|
1387
|
-
fi
|
|
1388
|
-
# Applications du catalogue (#414)
|
|
1389
|
-
if [ -d "$ICI/catalog" ]; then
|
|
1390
|
-
bash "$ICI/catalog.sh" resume
|
|
1391
|
-
fi
|
|
1392
|
-
# Secret Rails GitLab (#347) : avertissement si les secrets ont été perdus
|
|
1393
|
-
if [ "$(valeur gitlab)" = on ] && [ ! -f "$RACINE/workspace/.gitlab/rails-secret.yaml" ]; then
|
|
1394
|
-
echo " ⚠ gitlab GitLab réinstallé : si le navigateur affiche 422, supprimez les données de site de gitlab.localhost"
|
|
1395
|
-
fi
|
|
1396
|
-
# Cluster de devzone distant : avertissement dans le récapitulatif
|
|
1397
|
-
cluster_actuel="$(cluster_lu)"
|
|
1398
|
-
if [ -n "$cluster_actuel" ] && ! cluster_est_local "$cluster_actuel"; then
|
|
1399
|
-
printf ' ⚠ cluster remote: %s — services on a remote cluster\n' "$cluster_actuel"
|
|
1400
|
-
fi
|
|
1401
|
-
# Ancien cluster kind-gitlab encore présent : inviter à migrer (#396)
|
|
1402
|
-
if kind get clusters 2>/dev/null | grep -qx "gitlab${INSTANCE_SUFFIX}"; then
|
|
1403
|
-
printf ' ⚠ old kind-gitlab cluster%s: devzone gitlab migrate\n' "$INSTANCE_SUFFIX"
|
|
1404
|
-
fi
|
|
1405
|
-
# Cluster de travail interne (kind) : avertissement dans le recapitulatif
|
|
1406
|
-
ctx_travail="$(kubectl config current-context 2>/dev/null || true)"
|
|
1407
|
-
case "$ctx_travail" in
|
|
1408
|
-
kind-gitlab* | kind-devzone*)
|
|
1409
|
-
ctx_hote="$(KUBECONFIG="${DEVZONE_KUBE_HOTE:-$HOME/.kube/hote.config}" kubectl config current-context 2>/dev/null || true)"
|
|
1410
|
-
if [ -n "$ctx_hote" ] && cluster_joignable "$ctx_hote"; then
|
|
1411
|
-
printf ' ⚠ cluster de travail : %s (cluster interne de devzone) ; revenir : devzone use %s\n' "$ctx_travail" "$ctx_hote"
|
|
1412
|
-
fi
|
|
1413
|
-
;;
|
|
1414
|
-
esac
|
|
1415
|
-
# Contrôle RBAC : vérification d'accès aux secrets PostgreSQL
|
|
1416
|
-
ctx_rbac="$(kubectl auth can-i --as=system:serviceaccount:default:default get secrets -n devzone-postgres 2>/dev/null || true)"
|
|
1417
|
-
if [ "$ctx_rbac" = "yes" ]; then
|
|
1418
|
-
printf ' ⚠ rbac : accès aux secrets devzone-postgres non restreint\n'
|
|
1419
|
-
fi
|
|
1420
|
-
ports_etat="$(bash "$ICI/ports.sh" resume 2>/dev/null || true)"
|
|
1421
|
-
case "$ports_etat" in
|
|
1422
|
-
none*) printf ' ○ ports to the workstation %s\n' "$ports_etat" ;;
|
|
1423
|
-
*) printf ' ✔ ports to the workstation %s\n' "$ports_etat" ;;
|
|
1424
|
-
esac
|
|
1425
|
-
# Identifiants regroupés (#332) : le chemin seulement, jamais le contenu
|
|
1426
|
-
if [ -f "$RACINE/.password" ]; then
|
|
1427
|
-
printf ' ○ credentials: %s\n' "$RACINE/.password"
|
|
1428
|
-
fi
|
|
1429
|
-
# Marque posée par docker-relay.sh au démarrage (#293) : docker exec
|
|
1430
|
-
# longs coupés, kind et modules en échec
|
|
1431
|
-
relais_marque="${DEVZONE_RELAIS_MARQUE:-/tmp/devzone-relais-docker.echec}"
|
|
1432
|
-
if [ -f "$relais_marque" ]; then
|
|
1433
|
-
printf ' ⚠ Docker relay %s: devzone repair\n' "$(head -1 "$relais_marque")"
|
|
1434
|
-
fi
|
|
1435
|
-
# Marque posee par packages.sh a l echec de reapplication (351) : noms des paquets non installes
|
|
1436
|
-
paquets_marque="${DEVZONE_PAQUETS_MARQUE:-/tmp/devzone-paquets.echec}"
|
|
1437
|
-
if [ -f "$paquets_marque" ]; then
|
|
1438
|
-
paquets_noms=""
|
|
1439
|
-
while IFS= read -r n; do
|
|
1440
|
-
if [ -n "$n" ]; then
|
|
1441
|
-
paquets_noms="${paquets_noms:+$paquets_noms, }$n"
|
|
1442
|
-
fi
|
|
1443
|
-
done < "$paquets_marque"
|
|
1444
|
-
echo " ⚠ packages $paquets_noms: devzone packages"
|
|
1445
|
-
fi
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
# Message for the removed llm module (migration, #669).
|
|
1449
|
-
llm_retire_msg() {
|
|
1450
|
-
echo "devzone : module llm retiré : devzone n'héberge plus de modèle ; les modèles de l'hôte (Ollama) sont détectés à la place (devzone ai). Pour libérer le disque : kubectl delete namespace devzone-llm"
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
# Drops the llm= state line when present and reports the removal once (#669).
|
|
1454
|
-
migrer_llm() {
|
|
1455
|
-
[ -f "$ETAT" ] || return 0
|
|
1456
|
-
grep -qE '^llm=' "$ETAT" 2>/dev/null || return 0
|
|
1457
|
-
state_remove llm
|
|
1458
|
-
llm_retire_msg
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
changer() {
|
|
1462
|
-
local m="${2:-}"
|
|
1463
|
-
if [ -z "$m" ]; then
|
|
1464
|
-
echo "devzone : module inconnu : (aucun) ; modules : ${MODULES[*]}" >&2
|
|
1465
|
-
exit 1
|
|
1466
|
-
fi
|
|
1467
|
-
# llm removed (#669): migration message, never unknown module.
|
|
1468
|
-
if [ "$m" = llm ]; then
|
|
1469
|
-
initialiser 2>/dev/null || true
|
|
1470
|
-
if [ -f "$ETAT" ] && grep -qE '^llm=' "$ETAT" 2>/dev/null; then
|
|
1471
|
-
state_remove llm
|
|
1472
|
-
fi
|
|
1473
|
-
llm_retire_msg
|
|
1474
|
-
return 1
|
|
1475
|
-
fi
|
|
1476
|
-
migrer_llm
|
|
1477
|
-
# Option docker-hote (#432) : le socket de l'hôte, partagé par défaut.
|
|
1478
|
-
# Le choix ne s'applique qu'à la création du conteneur ; sans rebuild,
|
|
1479
|
-
# le conteneur courant garde son montage.
|
|
1480
|
-
if [ "$m" = docker-hote ]; then
|
|
1481
|
-
ecrire docker-hote "$1"
|
|
1482
|
-
if [ "$1" = on ]; then
|
|
1483
|
-
echo "devzone : socket Docker de l'hôte partagé après reconstruction"
|
|
1484
|
-
else
|
|
1485
|
-
echo "devzone : socket Docker de l'hôte non partagé après reconstruction"
|
|
1486
|
-
fi
|
|
1487
|
-
echo "devzone : reconstruction nécessaire : sur le poste, make rebuild"
|
|
1488
|
-
return 0
|
|
1489
|
-
fi
|
|
1490
|
-
if ! connu "$m"; then
|
|
1491
|
-
# Une application du catalogue : on écrit la ligne, on applique
|
|
1492
|
-
if [ -f "$ICI/catalog/$m/app.conf" ]; then
|
|
1493
|
-
ecrire "$m" "$1"
|
|
1494
|
-
bash "$ICI/catalog.sh" apply
|
|
1495
|
-
return
|
|
1496
|
-
fi
|
|
1497
|
-
echo "devzone : module inconnu : $m ; modules : ${MODULES[*]}" >&2
|
|
1498
|
-
exit 1
|
|
1499
|
-
fi
|
|
1500
|
-
# In the Kubernetes workspace pod the services are installed from the
|
|
1501
|
-
# workstation (#528): the pod has no administrator access to the cluster.
|
|
1502
|
-
# DEVZONE_SERVICES_ADMIN=1: run by services-admin.sh with a temporary one.
|
|
1503
|
-
if dans_pod && service_module "$m" && [ -z "${DEVZONE_SERVICES_ADMIN:-}" ]; then
|
|
1504
|
-
if [ "$1" = on ]; then
|
|
1505
|
-
echo "devzone: in the workspace pod, $m is installed from the workstation: devzone workspace services enable $m" >&2
|
|
1506
|
-
else
|
|
1507
|
-
echo "devzone: in the workspace pod, $m is removed from the workstation: devzone workspace services disable $m" >&2
|
|
1508
|
-
fi
|
|
1509
|
-
return 2
|
|
1510
|
-
fi
|
|
1511
|
-
if [ "$1" = off ] && { [ "$m" = postgres ] || [ "$m" = mysql ] || [ "$m" = gitlab ]; }; then
|
|
1512
|
-
confirmer_suppression "$m" "${@:3}" || return 0
|
|
1513
|
-
fi
|
|
1514
|
-
ecrire "$m" "$1"
|
|
1515
|
-
# Services held by Argo CD (#559): 0 done, 3 helm direct as before, else failed
|
|
1516
|
-
if DEVZONE_ETAT="$ETAT" bash "$ICI/argocd/services-hook.sh" "$m" "$1" "${@:3}"; then return 0; elif [ $? -ne 3 ]; then return 1; fi
|
|
1517
|
-
"appliquer_$m" "$1" "${@:3}"
|
|
1518
|
-
}
|
|
85
|
+
# Functions of devzone, by topic (sourced here, defined before any command runs)
|
|
86
|
+
# shellcheck source=SCRIPTDIR/devzone-modules.sh
|
|
87
|
+
# shellcheck disable=SC1091
|
|
88
|
+
. "$ICI/devzone-modules.sh"
|
|
89
|
+
# shellcheck source=SCRIPTDIR/devzone-ai.sh
|
|
90
|
+
# shellcheck disable=SC1091
|
|
91
|
+
. "$ICI/devzone-ai.sh"
|
|
92
|
+
# shellcheck source=SCRIPTDIR/devzone-ai-guard.sh
|
|
93
|
+
# shellcheck disable=SC1091
|
|
94
|
+
. "$ICI/devzone-ai-guard.sh"
|
|
95
|
+
# shellcheck source=SCRIPTDIR/devzone-skill.sh
|
|
96
|
+
# shellcheck disable=SC1091
|
|
97
|
+
. "$ICI/devzone-skill.sh"
|
|
98
|
+
# shellcheck source=SCRIPTDIR/devzone-services.sh
|
|
99
|
+
# shellcheck disable=SC1091
|
|
100
|
+
. "$ICI/devzone-services.sh"
|
|
101
|
+
# shellcheck source=SCRIPTDIR/devzone-cluster.sh
|
|
102
|
+
# shellcheck disable=SC1091
|
|
103
|
+
. "$ICI/devzone-cluster.sh"
|
|
104
|
+
# shellcheck source=SCRIPTDIR/devzone-repair.sh
|
|
105
|
+
# shellcheck disable=SC1091
|
|
106
|
+
. "$ICI/devzone-repair.sh"
|
|
107
|
+
# shellcheck source=SCRIPTDIR/devzone-platform.sh
|
|
108
|
+
# shellcheck disable=SC1091
|
|
109
|
+
. "$ICI/devzone-platform.sh"
|
|
110
|
+
# shellcheck source=SCRIPTDIR/devzone-version.sh
|
|
111
|
+
# shellcheck disable=SC1091
|
|
112
|
+
. "$ICI/devzone-version.sh"
|
|
113
|
+
# shellcheck source=SCRIPTDIR/devzone-status.sh
|
|
114
|
+
# shellcheck disable=SC1091
|
|
115
|
+
. "$ICI/devzone-status.sh"
|
|
1519
116
|
|
|
1520
117
|
# shellcheck source=state-json.sh
|
|
1521
118
|
# shellcheck disable=SC1091
|
|
@@ -1530,28 +127,28 @@ if command -v reject_renamed >/dev/null 2>&1; then
|
|
|
1530
127
|
fi
|
|
1531
128
|
|
|
1532
129
|
case "${1:-}" in
|
|
1533
|
-
"" | status | modules) if [ "${2:-}" = "--json" ]; then state_json; else
|
|
1534
|
-
enable)
|
|
1535
|
-
disable)
|
|
130
|
+
"" | status | modules) if [ "${2:-}" = "--json" ]; then state_json; else show_state; fi ;;
|
|
131
|
+
enable) change_module on "${2:-}" "${@:3}" ;;
|
|
132
|
+
disable) change_module off "${2:-}" "${@:3}" ;;
|
|
1536
133
|
apply)
|
|
1537
|
-
|
|
1538
|
-
#
|
|
1539
|
-
#
|
|
134
|
+
migrate_llm
|
|
135
|
+
# The user confirms the current state (#417, step 4): the watchers
|
|
136
|
+
# may uninstall again
|
|
1540
137
|
state_recovery_confirm
|
|
1541
|
-
|
|
1542
|
-
[ "$(
|
|
138
|
+
apply_repowarden
|
|
139
|
+
[ "$(value_of ia)" = off ] || apply_ia on
|
|
1543
140
|
# gitlab, postgres, argocd: installed from the workstation in the
|
|
1544
141
|
# Kubernetes workspace pod (#528), by their installer elsewhere
|
|
1545
|
-
[ "$(
|
|
1546
|
-
[ "$(
|
|
1547
|
-
[ "$(
|
|
1548
|
-
[ "$(
|
|
142
|
+
[ "$(value_of gitlab)" = off ] || apply_service gitlab
|
|
143
|
+
[ "$(value_of postgres)" = off ] || apply_service postgres
|
|
144
|
+
[ "$(value_of mysql)" = off ] || apply_mysql on
|
|
145
|
+
[ "$(value_of argocd)" = off ] || apply_service argocd
|
|
1549
146
|
;;
|
|
1550
147
|
is-enabled)
|
|
1551
|
-
|
|
1552
|
-
#
|
|
1553
|
-
#
|
|
1554
|
-
[ "$(
|
|
148
|
+
is_known "${2:-}" || { echo "devzone : unknown module : ${2:-(none)}" >&2; exit 2; }
|
|
149
|
+
# Silent test, called by the startup scripts: code 0 if the module is
|
|
150
|
+
# active, 1 otherwise, without writing anything (kube-config.sh:16)
|
|
151
|
+
[ "$(value_of "$2")" = on ]
|
|
1555
152
|
;;
|
|
1556
153
|
agent)
|
|
1557
154
|
bash "$ICI/agent.sh" "${@:2}"
|
|
@@ -1568,16 +165,16 @@ case "${1:-}" in
|
|
|
1568
165
|
;;
|
|
1569
166
|
*)
|
|
1570
167
|
# Read-only: lists the host (Ollama) models detected and the default model.
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
if [ -z "$
|
|
1574
|
-
echo "devzone :
|
|
168
|
+
models_list="$(modeles)"
|
|
169
|
+
default_model="$(premier)"
|
|
170
|
+
if [ -z "$models_list" ]; then
|
|
171
|
+
echo "devzone : no Ollama model detected on ${URL} (answer on /api/tags)"
|
|
1575
172
|
else
|
|
1576
|
-
echo "devzone :
|
|
173
|
+
echo "devzone : models detected on the host (Ollama):"
|
|
1577
174
|
while IFS= read -r m; do
|
|
1578
175
|
[ -n "$m" ] && printf ' %s\n' "$m"
|
|
1579
|
-
done <<<"$
|
|
1580
|
-
echo "
|
|
176
|
+
done <<<"$models_list"
|
|
177
|
+
echo "default model: ${default_model:-none}"
|
|
1581
178
|
fi
|
|
1582
179
|
;;
|
|
1583
180
|
esac
|
|
@@ -1586,37 +183,37 @@ case "${1:-}" in
|
|
|
1586
183
|
build)
|
|
1587
184
|
bash "$ICI/workspace-build.sh" "${@:2}"
|
|
1588
185
|
;;
|
|
1589
|
-
repair)
|
|
186
|
+
repair) repair_workstation ;;
|
|
1590
187
|
start) bash "$ICI/startup.sh" ;;
|
|
1591
188
|
metrics) bash "$ICI/metrics-server.sh" "${@:2}" ;;
|
|
1592
|
-
use)
|
|
1593
|
-
clusters)
|
|
1594
|
-
cluster)
|
|
1595
|
-
postgres)
|
|
1596
|
-
mysql)
|
|
1597
|
-
gitlab)
|
|
1598
|
-
catalog)
|
|
1599
|
-
argocd)
|
|
1600
|
-
port)
|
|
189
|
+
use) use_cluster "${@:2}" ;;
|
|
190
|
+
clusters) DEVZONE_STATE="$ETAT" bash "$ICI/clusters.sh" "${@:2}" ;;
|
|
191
|
+
cluster) change_cluster "${@:2}" ;;
|
|
192
|
+
postgres) DEVZONE_STATE="$ETAT" bash "$ICI/postgres/postgres.sh" "${@:2}" ;;
|
|
193
|
+
mysql) DEVZONE_STATE="$ETAT" bash "$ICI/catalog/mysql/mysql.sh" "${@:2}" ;;
|
|
194
|
+
gitlab) DEVZONE_STATE="$ETAT" bash "$ICI/gitlab/gitlab.sh" "${@:2}" ;;
|
|
195
|
+
catalog) DEVZONE_STATE="$ETAT" bash "$ICI/catalog.sh" list ;;
|
|
196
|
+
argocd) DEVZONE_STATE="$ETAT" bash "$ICI/argocd/argocd.sh" "${@:2}" ;;
|
|
197
|
+
port) DEVZONE_STATE="$ETAT" bash "$ICI/ports.sh" "${@:2}" ;;
|
|
1601
198
|
packages) bash "$ICI/packages.sh" "${@:2}" ;;
|
|
1602
199
|
passwords)
|
|
1603
200
|
bash "$ICI/password.sh" regenerer ||
|
|
1604
|
-
echo "devzone :
|
|
201
|
+
echo "devzone : grouped credentials not updated" >&2
|
|
1605
202
|
bash "$ICI/password.sh" chemin
|
|
1606
203
|
;;
|
|
1607
204
|
-h | --help | help) devzone_aide ;;
|
|
1608
205
|
-v | --version) echo "devzone ${DEVZONE_VERSION:-unknown}" ;;
|
|
1609
206
|
test-bash32) bash "$RACINE/manage/test/bash32.sh" ;;
|
|
1610
|
-
test-gitlab)
|
|
207
|
+
test-gitlab) DEVZONE_STATE="$ETAT" bash "$ICI/gitlab/test-gitlab.sh" "${@:2}" ;;
|
|
1611
208
|
platform)
|
|
1612
209
|
if [ -n "${2:-}" ]; then
|
|
1613
|
-
|
|
210
|
+
change_platform "${@:2}"
|
|
1614
211
|
else
|
|
1615
|
-
|
|
212
|
+
platform_summary
|
|
1616
213
|
fi
|
|
1617
214
|
;;
|
|
1618
215
|
*)
|
|
1619
|
-
echo "devzone :
|
|
216
|
+
echo "devzone : unknown command : $1 (devzone --help)" >&2
|
|
1620
217
|
exit 1
|
|
1621
218
|
;;
|
|
1622
219
|
esac
|