devzone 7.1.1 → 7.3.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/Dockerfile +14 -14
- package/.devcontainer/ai/host-check.message +12 -12
- package/.devcontainer/ai/host-check.sh +1 -1
- package/.devcontainer/catalog/catalog-watcher.sh +9 -12
- package/.devcontainer/catalog.sh +5 -28
- package/.devcontainer/cluster.sh +1 -4
- package/.devcontainer/devzone +27 -25
- package/.devcontainer/devzone-ai.sh +1 -1
- package/.devcontainer/devzone-cluster.sh +1 -2
- package/.devcontainer/devzone-modules.sh +9 -20
- package/.devcontainer/devzone-repair.sh +3 -3
- package/.devcontainer/devzone-services.sh +2 -2
- package/.devcontainer/devzone-status.sh +1 -1
- package/.devcontainer/gitlab/demo/.gitlab-ci.yml +1 -1
- package/.devcontainer/help.sh +0 -1
- package/.devcontainer/packages.sh +1 -1
- package/.devcontainer/password.sh +5 -6
- package/.devcontainer/ports.sh +3 -6
- package/.devcontainer/services-admin.sh +5 -8
- package/.devcontainer/workspace-init.sh +0 -7
- package/Makefile +3 -3
- package/README.md +1 -13
- package/bin/SHA256SUMS +6 -6
- package/bin/devzone-darwin-amd64 +0 -0
- package/bin/devzone-darwin-arm64 +0 -0
- package/bin/devzone-linux-amd64 +0 -0
- package/bin/devzone-linux-arm64 +0 -0
- package/bin/devzone-windows-amd64.exe +0 -0
- package/bin/devzone-windows-arm64.exe +0 -0
- package/manage/devzone +6 -17
- package/manage/scripts/ci/check-names.sh +5 -6
- package/manage/scripts/ci/ticket-protocol.txt +7 -0
- package/manage/scripts/ci/versions-tools-plan.sh +1 -1
- package/manage/scripts/devzone-create.sh +4 -4
- package/manage/scripts/devzone-update.sh +18 -22
- package/manage/scripts/workspace/argocd-services.sh +1 -1
- package/manage/scripts/workspace/argocd-workspace.sh +2 -2
- package/manage/scripts/workspace/ports-workspace.sh +5 -5
- package/manage/scripts/workspace/services-workspace.sh +3 -3
- package/manage/scripts/workspace/workspace-update.sh +0 -3
- package/manage/workspace.sh +0 -14
- package/package.json +1 -1
- package/.devcontainer/command-aliases.sh +0 -234
- package/.devcontainer/rename-legacy-files.sh +0 -172
- package/.devcontainer/rename-legacy-ports.sh +0 -119
- package/.devcontainer/state-gitops.sh +0 -23
- package/.devcontainer/state-json.sh +0 -282
- package/.devcontainer/state-lock.sh +0 -53
- package/.devcontainer/state.sh +0 -219
- package/manage/scripts/ci/check-english.sh +0 -57
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Renamed names of the devzone CLI (#695): the French names of the commands,
|
|
3
|
-
# subcommands and options are no longer accepted, they are refused. Each old
|
|
4
|
-
# name prints « ✖ « old » was renamed: devzone new » on stderr, exits with
|
|
5
|
-
# code 1 and does nothing (no folder is created: « devzone stop » creates ./stop,
|
|
6
|
-
# « devzone mettre-a-jour » must not create ./mettre-a-jour).
|
|
7
|
-
#
|
|
8
|
-
# renamed_command <name> : English name of a renamed command, or 1
|
|
9
|
-
# renamed_subcommand <command> <name> : English name of a renamed subcommand, or 1
|
|
10
|
-
# renamed_option <option> : English name of a renamed option, or 1
|
|
11
|
-
# renamed_module <name> : new name of a renamed module (argument of
|
|
12
|
-
# enable, disable, is-enabled, apply), or 1
|
|
13
|
-
# reject_renamed <command> <args...> : refuses the first renamed name of a call
|
|
14
|
-
# (command, first word that is not an
|
|
15
|
-
# option, then each option); 0 if none
|
|
16
|
-
#
|
|
17
|
-
# bash 3.2 (macOS): case only, no associative array.
|
|
18
|
-
|
|
19
|
-
# English name of a renamed command, or return 1.
|
|
20
|
-
renamed_command() {
|
|
21
|
-
case "${1:-}" in
|
|
22
|
-
actif) echo is-enabled ;;
|
|
23
|
-
activer) echo enable ;;
|
|
24
|
-
desactiver) echo disable ;;
|
|
25
|
-
ia) echo ai ;;
|
|
26
|
-
aide) echo help ;;
|
|
27
|
-
appliquer) echo apply ;;
|
|
28
|
-
catalogue) echo catalog ;;
|
|
29
|
-
demarrer) echo start ;;
|
|
30
|
-
arreter) echo stop ;;
|
|
31
|
-
etat) echo status ;;
|
|
32
|
-
mots-de-passe) echo passwords ;;
|
|
33
|
-
paquets) echo packages ;;
|
|
34
|
-
plateforme) echo platform ;;
|
|
35
|
-
reparer) echo repair ;;
|
|
36
|
-
utiliser) echo use ;;
|
|
37
|
-
mettre-a-jour) echo update ;;
|
|
38
|
-
desinstaller) echo uninstall ;;
|
|
39
|
-
copier-vers) echo copy-to ;;
|
|
40
|
-
copier-depuis) echo copy-from ;;
|
|
41
|
-
*) return 1 ;;
|
|
42
|
-
esac
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
# English name of a renamed subcommand of <command> (English name), or return 1.
|
|
46
|
-
renamed_subcommand() {
|
|
47
|
-
local command="${1:-}" word="${2:-}"
|
|
48
|
-
case "$command" in
|
|
49
|
-
postgres | mysql)
|
|
50
|
-
case "$word" in
|
|
51
|
-
creer) echo create ;;
|
|
52
|
-
liste) echo list ;;
|
|
53
|
-
supprimer) echo delete ;;
|
|
54
|
-
supprimer-donnees) echo delete-data ;;
|
|
55
|
-
etat) echo status ;;
|
|
56
|
-
installer) echo install ;;
|
|
57
|
-
desinstaller) echo uninstall ;;
|
|
58
|
-
relais-lancer) echo relay-start ;;
|
|
59
|
-
relais-arreter) echo relay-stop ;;
|
|
60
|
-
autoriser) echo authorize ;;
|
|
61
|
-
interdire) echo forbid ;;
|
|
62
|
-
*) return 1 ;;
|
|
63
|
-
esac
|
|
64
|
-
;;
|
|
65
|
-
gitlab)
|
|
66
|
-
case "$word" in
|
|
67
|
-
migrer) echo migrate ;;
|
|
68
|
-
nouveau-mdp) echo new-password ;;
|
|
69
|
-
etat) echo status ;;
|
|
70
|
-
installer) echo install ;;
|
|
71
|
-
desinstaller) echo uninstall ;;
|
|
72
|
-
relais-lancer) echo relay-start ;;
|
|
73
|
-
relais-arreter) echo relay-stop ;;
|
|
74
|
-
relais-etat) echo relay-status ;;
|
|
75
|
-
*) return 1 ;;
|
|
76
|
-
esac
|
|
77
|
-
;;
|
|
78
|
-
argocd)
|
|
79
|
-
case "$word" in
|
|
80
|
-
etat) echo status ;;
|
|
81
|
-
installer) echo install ;;
|
|
82
|
-
desinstaller) echo uninstall ;;
|
|
83
|
-
relais-lancer) echo relay-start ;;
|
|
84
|
-
relais-arreter) echo relay-stop ;;
|
|
85
|
-
*) return 1 ;;
|
|
86
|
-
esac
|
|
87
|
-
;;
|
|
88
|
-
packages)
|
|
89
|
-
case "$word" in
|
|
90
|
-
ajouter) echo add ;;
|
|
91
|
-
retirer) echo remove ;;
|
|
92
|
-
appliquer) echo apply ;;
|
|
93
|
-
lister) echo list ;;
|
|
94
|
-
*) return 1 ;;
|
|
95
|
-
esac
|
|
96
|
-
;;
|
|
97
|
-
catalog)
|
|
98
|
-
case "$word" in
|
|
99
|
-
synchroniser) echo sync ;;
|
|
100
|
-
appliquer) echo apply ;;
|
|
101
|
-
lister) echo list ;;
|
|
102
|
-
desinstaller) echo remove ;;
|
|
103
|
-
*) return 1 ;;
|
|
104
|
-
esac
|
|
105
|
-
;;
|
|
106
|
-
port)
|
|
107
|
-
case "$word" in
|
|
108
|
-
ouvrir) echo open ;;
|
|
109
|
-
fermer) echo close ;;
|
|
110
|
-
liste) echo list ;;
|
|
111
|
-
relancer) echo restart ;;
|
|
112
|
-
exclure) echo exclude ;;
|
|
113
|
-
inclure) echo include ;;
|
|
114
|
-
*) return 1 ;;
|
|
115
|
-
esac
|
|
116
|
-
;;
|
|
117
|
-
workspace)
|
|
118
|
-
case "$word" in
|
|
119
|
-
demarrer) echo start ;;
|
|
120
|
-
mettre-a-jour) echo update ;;
|
|
121
|
-
arreter) echo stop ;;
|
|
122
|
-
etat) echo status ;;
|
|
123
|
-
copier-vers) echo copy-to ;;
|
|
124
|
-
copier-depuis) echo copy-from ;;
|
|
125
|
-
aide) echo help ;;
|
|
126
|
-
*) return 1 ;;
|
|
127
|
-
esac
|
|
128
|
-
;;
|
|
129
|
-
"workspace ports")
|
|
130
|
-
case "$word" in
|
|
131
|
-
demarrer) echo start ;;
|
|
132
|
-
arreter) echo stop ;;
|
|
133
|
-
etat) echo status ;;
|
|
134
|
-
*) return 1 ;;
|
|
135
|
-
esac
|
|
136
|
-
;;
|
|
137
|
-
agent)
|
|
138
|
-
case "$word" in
|
|
139
|
-
etat) echo state ;;
|
|
140
|
-
liberer) echo release ;;
|
|
141
|
-
aide) echo help ;;
|
|
142
|
-
*) return 1 ;;
|
|
143
|
-
esac
|
|
144
|
-
;;
|
|
145
|
-
*) return 1 ;;
|
|
146
|
-
esac
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
# English name of a renamed option, or return 1.
|
|
150
|
-
renamed_option() {
|
|
151
|
-
case "${1:-}" in
|
|
152
|
-
--fermer) echo --close ;;
|
|
153
|
-
--supprimer) echo --delete ;;
|
|
154
|
-
--nouveau-mdp) echo --new-password ;;
|
|
155
|
-
--oui) echo --yes ;;
|
|
156
|
-
--confirmer) echo --confirm ;;
|
|
157
|
-
--contexte) echo --context ;;
|
|
158
|
-
--modele) echo --model ;;
|
|
159
|
-
--tous) echo --all ;;
|
|
160
|
-
--sans-reconstruire) echo --no-rebuild ;;
|
|
161
|
-
*) return 1 ;;
|
|
162
|
-
esac
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
# New name of a renamed module, or return 1. Modules are not commands: the
|
|
166
|
-
# message names the module only (« ia » was renamed: ai).
|
|
167
|
-
renamed_module() {
|
|
168
|
-
case "${1:-}" in
|
|
169
|
-
ia) echo ai ;;
|
|
170
|
-
*) return 1 ;;
|
|
171
|
-
esac
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
# Names removed in 3.0 (#735): refused with the same exit code, with a notice
|
|
175
|
-
# that names no former feature and never creates a folder.
|
|
176
|
-
removed_notice() {
|
|
177
|
-
echo "✖ this command or option was removed in devzone 3.0 (see manage/docs/migrating-to-3.md)" >&2
|
|
178
|
-
return 1
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
# reject_renamed <command> <args...> : checks the command itself (top level),
|
|
182
|
-
# the first word of <args> that is not an option (subcommand), then every
|
|
183
|
-
# option. The first renamed name prints its message on stderr and returns 1;
|
|
184
|
-
# nothing is run. Returns 0 when no name is renamed.
|
|
185
|
-
reject_renamed() {
|
|
186
|
-
local command="${1:-}" word new
|
|
187
|
-
if [ "$#" -gt 0 ]; then shift; fi
|
|
188
|
-
case "$command" in
|
|
189
|
-
migrer | revenir | nettoyer-docker) removed_notice; return 1 ;;
|
|
190
|
-
esac
|
|
191
|
-
if new="$(renamed_command "$command")"; then
|
|
192
|
-
# these commands only exist under « devzone workspace »
|
|
193
|
-
case "$command" in
|
|
194
|
-
copier-vers | copier-depuis) new="workspace $new" ;;
|
|
195
|
-
esac
|
|
196
|
-
printf '✖ « %s » was renamed: devzone %s\n' "$command" "$new" >&2
|
|
197
|
-
return 1
|
|
198
|
-
fi
|
|
199
|
-
for word in "$@"; do
|
|
200
|
-
case "$word" in
|
|
201
|
-
-*) continue ;;
|
|
202
|
-
esac
|
|
203
|
-
if [ "$command" = workspace ]; then
|
|
204
|
-
case "$word" in
|
|
205
|
-
migrer | revenir | nettoyer-docker) removed_notice; return 1 ;;
|
|
206
|
-
esac
|
|
207
|
-
fi
|
|
208
|
-
case "$command" in
|
|
209
|
-
enable | disable | is-enabled | apply)
|
|
210
|
-
if new="$(renamed_module "$word")"; then
|
|
211
|
-
printf '✖ « %s » was renamed: %s\n' "$word" "$new" >&2
|
|
212
|
-
return 1
|
|
213
|
-
fi
|
|
214
|
-
;;
|
|
215
|
-
esac
|
|
216
|
-
if new="$(renamed_subcommand "$command" "$word")"; then
|
|
217
|
-
printf '✖ « %s » was renamed: devzone %s %s\n' "$word" "$command" "$new" >&2
|
|
218
|
-
return 1
|
|
219
|
-
fi
|
|
220
|
-
break
|
|
221
|
-
done
|
|
222
|
-
for word in "$@"; do
|
|
223
|
-
case "$word" in
|
|
224
|
-
--rapatrier) removed_notice; return 1 ;;
|
|
225
|
-
-*)
|
|
226
|
-
if new="$(renamed_option "$word")"; then
|
|
227
|
-
printf '✖ « %s » was renamed: %s\n' "$word" "$new" >&2
|
|
228
|
-
return 1
|
|
229
|
-
fi
|
|
230
|
-
;;
|
|
231
|
-
esac
|
|
232
|
-
done
|
|
233
|
-
return 0
|
|
234
|
-
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck shell=bash
|
|
3
|
-
# Renames the files and folders that devzone wrote under their former French
|
|
4
|
-
# names to their English names (#733, lot 3), and the state keys plateforme= to
|
|
5
|
-
# platform= (lot 4) and ia= to ai= (#774, lot 3). #774, lot 4 adds the folders of the
|
|
6
|
-
# port watcher, the state backup, the AI measures file and the packages marker.
|
|
7
|
-
# #774, lot 5 adds the ports folder cap, the key ports_exclus=, the state files of
|
|
8
|
-
# the port automation, the locks of the agent, of the catalog watcher and of the
|
|
9
|
-
# state (rename-legacy-ports.sh).
|
|
10
|
-
# Called by the pod startup, by the workspace init, and on the
|
|
11
|
-
# workstation by devzone update and workspace update.
|
|
12
|
-
# Idempotent: a name is renamed only when the old one exists and the new one
|
|
13
|
-
# does not, so a second run does nothing. Two folders with both names are
|
|
14
|
-
# merged, the old one emptied and removed. An existing file is never
|
|
15
|
-
# overwritten. One line per rename or merge on stdout, exit 0. No alias of the
|
|
16
|
-
# old names is kept after this migration. bash 3.2 (macOS).
|
|
17
|
-
# DEVZONE_ROOT devzone folder (default: the parent of this .devcontainer)
|
|
18
|
-
# DEVZONE_TMP_DIR temporary folder (default: /tmp), set by the tests
|
|
19
|
-
# DEVZONE_PORTS_AUTO_DIR, DEVZONE_AGENT_STATE state folders of the port automation
|
|
20
|
-
# and of the agent (defaults: devzone-ports-auto of the temporary folder, ~/.local/state/oc-lancer)
|
|
21
|
-
|
|
22
|
-
ROOT="${DEVZONE_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
|
|
23
|
-
TMP_DIR="${DEVZONE_TMP_DIR:-/tmp}"
|
|
24
|
-
|
|
25
|
-
# is_real_dir PATH: true for a folder that is not a symbolic link
|
|
26
|
-
is_real_dir() {
|
|
27
|
-
[ -d "$1" ] && [ ! -L "$1" ]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
# merge_legacy OLD NEW: both are folders. Each entry of OLD that NEW does not
|
|
31
|
-
# have is moved into NEW; an entry present on both sides is never overwritten,
|
|
32
|
-
# it stays in OLD and a message on stderr names it. OLD is removed (rmdir) only
|
|
33
|
-
# when it is left empty, and then the merge is announced on stdout. Hidden
|
|
34
|
-
# entries are merged too. The shell options live in a subshell, so they do not
|
|
35
|
-
# reach the other migrations.
|
|
36
|
-
merge_legacy() {
|
|
37
|
-
local old="$1" new="$2"
|
|
38
|
-
(
|
|
39
|
-
shopt -s dotglob nullglob
|
|
40
|
-
local entry target
|
|
41
|
-
for entry in "$old"/*; do
|
|
42
|
-
target="$new/${entry##*/}"
|
|
43
|
-
if [ -e "$target" ] || [ -L "$target" ]; then
|
|
44
|
-
echo "devzone : $entry kept: $target already exists" >&2
|
|
45
|
-
elif ! mv -- "$entry" "$target"; then
|
|
46
|
-
echo "devzone : $entry not merged into $target" >&2
|
|
47
|
-
fi
|
|
48
|
-
done
|
|
49
|
-
if rmdir -- "$old" 2>/dev/null; then
|
|
50
|
-
echo "devzone : $old merged into $new"
|
|
51
|
-
fi
|
|
52
|
-
)
|
|
53
|
-
return 0
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
# rename_legacy OLD NEW: moves OLD to NEW when OLD exists and NEW does not.
|
|
57
|
-
# When both are folders, they are merged (see merge_legacy). Any other conflict
|
|
58
|
-
# is reported on stderr and both names are left as they are.
|
|
59
|
-
rename_legacy() {
|
|
60
|
-
local old="$1" new="$2"
|
|
61
|
-
if [ ! -e "$old" ] && [ ! -L "$old" ]; then
|
|
62
|
-
return 0
|
|
63
|
-
fi
|
|
64
|
-
if [ -e "$new" ] || [ -L "$new" ]; then
|
|
65
|
-
if is_real_dir "$old" && is_real_dir "$new"; then
|
|
66
|
-
merge_legacy "$old" "$new"
|
|
67
|
-
else
|
|
68
|
-
echo "devzone : $old kept, $new already exists" >&2
|
|
69
|
-
fi
|
|
70
|
-
return 0
|
|
71
|
-
fi
|
|
72
|
-
if mv -- "$old" "$new"; then
|
|
73
|
-
echo "devzone : $old renamed to $new"
|
|
74
|
-
else
|
|
75
|
-
echo "devzone : $old not renamed to $new" >&2
|
|
76
|
-
fi
|
|
77
|
-
return 0
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
# Failure markers of the modules: .devzone.modules-echec-<module> becomes
|
|
81
|
-
# .devzone.modules-failed-<module>, one rename per marker found
|
|
82
|
-
migrate_markers() {
|
|
83
|
-
local f base
|
|
84
|
-
for f in "$ROOT"/.devzone.modules-echec-*; do
|
|
85
|
-
if [ ! -e "$f" ] && [ ! -L "$f" ]; then
|
|
86
|
-
continue
|
|
87
|
-
fi
|
|
88
|
-
base="${f##*/}"
|
|
89
|
-
rename_legacy "$f" "$ROOT/.devzone.modules-failed-${base#.devzone.modules-echec-}"
|
|
90
|
-
done
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
# Folders and files of the devzone folder
|
|
94
|
-
migrate_root() {
|
|
95
|
-
rename_legacy "$ROOT/.devzone.paquets" "$ROOT/.devzone.packages"
|
|
96
|
-
rename_legacy "$ROOT/.devzone.sauvegarde" "$ROOT/.devzone.backup"
|
|
97
|
-
rename_legacy "$ROOT/.devzone.ports-workspace" "$ROOT/.devzone.workspace-ports"
|
|
98
|
-
rename_legacy "$ROOT/.devzone.etat" "$ROOT/.devzone.state"
|
|
99
|
-
rename_legacy "$ROOT/.devzone.catalogue-veilleur" "$ROOT/.devzone.catalog-watcher"
|
|
100
|
-
migrate_markers
|
|
101
|
-
# Failure marker of the AI module, renamed with it (#774)
|
|
102
|
-
rename_legacy "$ROOT/.devzone.modules-failed-ia" "$ROOT/.devzone.modules-failed-ai"
|
|
103
|
-
# Backup of the previous state (#774, lot 4)
|
|
104
|
-
rename_legacy "$ROOT/.devzone.modules.prec" "$ROOT/.devzone.modules.prev"
|
|
105
|
-
migrate_ports
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
# Port watcher, locks and state files of the port automation (#774, lot 5)
|
|
109
|
-
# shellcheck source=SCRIPTDIR/rename-legacy-ports.sh
|
|
110
|
-
# shellcheck disable=SC1091
|
|
111
|
-
. "$(dirname "$0")/rename-legacy-ports.sh"
|
|
112
|
-
|
|
113
|
-
# Fingerprint of the devzone skill, next to its SKILL.md in each assistant folder
|
|
114
|
-
migrate_skills() {
|
|
115
|
-
local d
|
|
116
|
-
[ -n "${HOME:-}" ] || return 0
|
|
117
|
-
for d in "$HOME/.claude/skills/devzone" "$HOME/.config/opencode/skills/devzone"; do
|
|
118
|
-
rename_legacy "$d/.devzone-empreinte" "$d/.devzone-fingerprint"
|
|
119
|
-
done
|
|
120
|
-
# Measures of the host models (#774, lot 4); DEVZONE_AI_MEASURES points to
|
|
121
|
-
# a file of the user, never renamed
|
|
122
|
-
rename_legacy "$HOME/.config/devzone/ia-mesures.json" "$HOME/.config/devzone/ai-measures.json"
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
# Markers written in the temporary folder by the packages check
|
|
126
|
-
migrate_tmp() {
|
|
127
|
-
rename_legacy "$TMP_DIR/devzone-paquets.echec" "$TMP_DIR/devzone-packages.failed"
|
|
128
|
-
rename_legacy "$TMP_DIR/devzone-paquets.maj" "$TMP_DIR/devzone-packages.updated"
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
# Key of the state file: the line <old>=<v> becomes <new>=<v>. When a <new>=
|
|
132
|
-
# line is already there, only the old line goes. The file is rewritten in a
|
|
133
|
-
# temporary file, then moved over it; the other lines are copied as they are.
|
|
134
|
-
# A file without the old key is left alone.
|
|
135
|
-
migrate_state_key() {
|
|
136
|
-
local old="$1" new="$2"
|
|
137
|
-
local f="$ROOT/.devzone.modules" tmp="$ROOT/.devzone.modules.tmp.$$"
|
|
138
|
-
[ -f "$f" ] || return 0
|
|
139
|
-
grep -q "^$old=" "$f" || return 0
|
|
140
|
-
if grep -q "^$new=" "$f"; then
|
|
141
|
-
sed "/^$old=/d" "$f" >"$tmp"
|
|
142
|
-
else
|
|
143
|
-
sed "s/^$old=/$new=/" "$f" >"$tmp"
|
|
144
|
-
fi || {
|
|
145
|
-
rm -f "$tmp"
|
|
146
|
-
echo "devzone : $old= not renamed to $new=" >&2
|
|
147
|
-
return 0
|
|
148
|
-
}
|
|
149
|
-
if mv -- "$tmp" "$f"; then
|
|
150
|
-
echo "devzone : $old= renamed to $new="
|
|
151
|
-
else
|
|
152
|
-
rm -f "$tmp"
|
|
153
|
-
echo "devzone : $old= not renamed to $new=" >&2
|
|
154
|
-
fi
|
|
155
|
-
return 0
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
# Keys of the state file: plateforme= (#733, lot 4), ia= (#774, lot 3), ports_exclus= (#774, lot 5)
|
|
159
|
-
migrate_state_keys() {
|
|
160
|
-
migrate_state_key plateforme platform
|
|
161
|
-
migrate_state_key ia ai
|
|
162
|
-
migrate_state_key ports_exclus excluded_ports
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
migrate_root
|
|
166
|
-
migrate_skills
|
|
167
|
-
migrate_tmp
|
|
168
|
-
migrate_ports_auto
|
|
169
|
-
migrate_agent_locks
|
|
170
|
-
migrate_state_lock
|
|
171
|
-
migrate_state_keys
|
|
172
|
-
exit 0
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck shell=bash
|
|
3
|
-
# Migration of the names of the port watcher, of the locks and of the state files
|
|
4
|
-
# of the port automation (#774, lot 5). Sourced by rename-legacy-files.sh, which
|
|
5
|
-
# defines ROOT, TMP_DIR, is_real_dir and rename_legacy: never run alone. bash 3.2.
|
|
6
|
-
#
|
|
7
|
-
# Rule for a lock: a lock held by a live process is never moved or removed, it
|
|
8
|
-
# is reported on stderr and the next run migrates it once its holder has gone.
|
|
9
|
-
|
|
10
|
-
# pid_alive PID: true when PID is a live process
|
|
11
|
-
pid_alive() {
|
|
12
|
-
[ -n "${1:-}" ] && kill -0 "$1" 2>/dev/null
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
# lock_held DIR: true when the lock folder DIR names a live process in DIR/pid
|
|
16
|
-
lock_held() {
|
|
17
|
-
pid_alive "$(cat "$1/pid" 2>/dev/null || true)"
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
# migrate_lock OLD NEW: the lock folder OLD becomes NEW, unless a live process
|
|
21
|
-
# holds it
|
|
22
|
-
migrate_lock() {
|
|
23
|
-
[ -e "$1" ] || [ -L "$1" ] || return 0
|
|
24
|
-
if lock_held "$1"; then
|
|
25
|
-
echo "devzone : $1 kept: held by a live process" >&2
|
|
26
|
-
return 0
|
|
27
|
-
fi
|
|
28
|
-
rename_legacy "$1" "$2"
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
# is_watcher PID: true when PID is a live port watcher (its command line names
|
|
32
|
-
# ports-workspace.sh, or is "workspace ports loop" of the Go watcher), so a pid
|
|
33
|
-
# file left by a dead watcher never makes us signal an unrelated process that
|
|
34
|
-
# reuses the number
|
|
35
|
-
is_watcher() {
|
|
36
|
-
[ -n "${1:-}" ] || return 1
|
|
37
|
-
kill -0 "$1" 2>/dev/null || return 1
|
|
38
|
-
ps -p "$1" -o command= 2>/dev/null | grep -Eq 'ports-workspace\.sh|workspace ports loop'
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
# Folders of the workstation port watcher (#774, lots 4 and 5): relais/ becomes
|
|
42
|
-
# relays/, pris/ taken/, verrou lock and plafond cap. A watcher that is running
|
|
43
|
-
# keeps the old folders and creates them again at each round, so it is stopped
|
|
44
|
-
# first: SIGTERM, and its own handler removes its relays, its lock and its pid.
|
|
45
|
-
# It is not restarted here (the files of the package are replaced after this
|
|
46
|
-
# script): the file restart is left in its folder as the signal that this
|
|
47
|
-
# migration, not the user, stopped it; devzone update starts it again once the
|
|
48
|
-
# files are replaced, and a start or a stop by the user removes the signal. If
|
|
49
|
-
# it does not stop within 2 s, nothing is renamed.
|
|
50
|
-
migrate_ports() {
|
|
51
|
-
local d="$ROOT/.devzone.workspace-ports" pid old n
|
|
52
|
-
is_real_dir "$d" || return 0
|
|
53
|
-
old=""
|
|
54
|
-
for n in relais pris verrou plafond; do
|
|
55
|
-
if [ -e "$d/$n" ] || [ -L "$d/$n" ]; then old=1; fi
|
|
56
|
-
done
|
|
57
|
-
[ -n "$old" ] || return 0
|
|
58
|
-
pid="$(cat "$d/pid" 2>/dev/null || true)"
|
|
59
|
-
if is_watcher "$pid"; then
|
|
60
|
-
kill "$pid" 2>/dev/null || true
|
|
61
|
-
for _ in 1 2 3 4 5 6 7 8 9 10; do
|
|
62
|
-
is_watcher "$pid" || break
|
|
63
|
-
sleep 0.2
|
|
64
|
-
done
|
|
65
|
-
if is_watcher "$pid"; then
|
|
66
|
-
echo "devzone : port watcher (pid $pid) still running, $d folders kept under their old names" >&2
|
|
67
|
-
return 0
|
|
68
|
-
fi
|
|
69
|
-
: >"$d/restart"
|
|
70
|
-
echo "devzone : port watcher stopped to rename its folders, restart it: devzone workspace ports start"
|
|
71
|
-
fi
|
|
72
|
-
rename_legacy "$d/relais" "$d/relays"
|
|
73
|
-
rename_legacy "$d/pris" "$d/taken"
|
|
74
|
-
rename_legacy "$d/verrou" "$d/lock"
|
|
75
|
-
rename_legacy "$d/plafond" "$d/cap"
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
# State of the port automation of the pod, one folder per instance in
|
|
79
|
-
# $DEVZONE_PORTS_AUTO_DIR (default: devzone-ports-auto of the temporary folder):
|
|
80
|
-
# verrou lock, occupes busy, actifs active, courant current. An instance whose
|
|
81
|
-
# lock is held by a live watcher is left whole: its files are in use.
|
|
82
|
-
migrate_ports_auto() {
|
|
83
|
-
local base="${DEVZONE_PORTS_AUTO_DIR:-$TMP_DIR/devzone-ports-auto}" d
|
|
84
|
-
for d in "$base"/*; do
|
|
85
|
-
is_real_dir "$d" || continue
|
|
86
|
-
if lock_held "$d/verrou"; then
|
|
87
|
-
echo "devzone : $d kept: its watcher is running" >&2
|
|
88
|
-
continue
|
|
89
|
-
fi
|
|
90
|
-
rename_legacy "$d/verrou" "$d/lock"
|
|
91
|
-
rename_legacy "$d/occupes" "$d/busy"
|
|
92
|
-
rename_legacy "$d/actifs" "$d/active"
|
|
93
|
-
rename_legacy "$d/courant" "$d/current"
|
|
94
|
-
done
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
# Locks of the agent (state folder of devzone agent) and of the catalog watcher
|
|
98
|
-
migrate_agent_locks() {
|
|
99
|
-
migrate_lock "${DEVZONE_AGENT_STATE:-${HOME:-/nonexistent}/.local/state/oc-lancer}/verrou" \
|
|
100
|
-
"${DEVZONE_AGENT_STATE:-${HOME:-/nonexistent}/.local/state/oc-lancer}/lock"
|
|
101
|
-
migrate_lock "$ROOT/.devzone.catalog-watcher/verrou" "$ROOT/.devzone.catalog-watcher/lock"
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
# Write lock of the state file: the folder .devzone.modules.verrou became
|
|
105
|
-
# .devzone.modules.lockdir. It is a transient mkdir lock without pid: it is
|
|
106
|
-
# not renamed, the old one is removed once it is older than 30 s, which is the
|
|
107
|
-
# age after which state-lock.sh itself takes a lock for abandoned. A younger
|
|
108
|
-
# one may belong to a write in progress: it is left for the next run.
|
|
109
|
-
migrate_state_lock() {
|
|
110
|
-
local old="$ROOT/.devzone.modules.verrou" t
|
|
111
|
-
is_real_dir "$old" || return 0
|
|
112
|
-
t="$(stat -c %Y "$old" 2>/dev/null || stat -f %m "$old" 2>/dev/null || true)"
|
|
113
|
-
[ -n "$t" ] && [ "$(($(date +%s) - t))" -gt 30 ] || return 0
|
|
114
|
-
if rm -rf -- "$old"; then
|
|
115
|
-
echo "devzone : $old removed (abandoned write lock, now .devzone.modules.lockdir)"
|
|
116
|
-
else
|
|
117
|
-
echo "devzone : $old not removed" >&2
|
|
118
|
-
fi
|
|
119
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# GitOps repository line of the state in the Kubernetes workspace pod (#639).
|
|
3
|
-
# The pod has no kubeconfig and its service account cannot read Applications
|
|
4
|
-
# today: one short read of the root Application tells whether Argo CD manages
|
|
5
|
-
# the cluster from Git; a refusal or an absence falls back to the workstation
|
|
6
|
-
# state. Sourced by devzone, called only when in_pod is true.
|
|
7
|
-
|
|
8
|
-
# Namespace of the Argo CD of devzone: GITOPS_NS when the includer knows it
|
|
9
|
-
# (argocd/gitops.sh), otherwise the namespace of the module.
|
|
10
|
-
: "${GITOPS_NS:=devzone-argocd}"
|
|
11
|
-
|
|
12
|
-
# State line of the GitOps repository: the URL of the root Application when
|
|
13
|
-
# the pod can read it, otherwise the workstation command that shows the state
|
|
14
|
-
gitops_state_line() {
|
|
15
|
-
local url
|
|
16
|
-
url="$(kubectl get application devzone -n "$GITOPS_NS" \
|
|
17
|
-
-o jsonpath='{.spec.source.repoURL}' --request-timeout=5s 2>/dev/null || true)"
|
|
18
|
-
if [ -n "$url" ]; then
|
|
19
|
-
printf ' ○ argocd GitOps repository: %s\n' "$url"
|
|
20
|
-
else
|
|
21
|
-
printf ' ○ argocd managed from the workstation: devzone workspace argocd status\n'
|
|
22
|
-
fi
|
|
23
|
-
}
|