devzone 7.5.4 → 7.6.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/devzone +1 -52
- 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/charts/devzone-workspace/templates/statefulset.yaml +4 -3
- package/charts/devzone-workspace/values.yaml +16 -5
- package/manage/devzone +7 -34
- package/manage/workspace.sh +25 -9
- package/package.json +1 -1
- package/.devcontainer/devzone-modules.sh +0 -125
- package/.devcontainer/devzone-platform.sh +0 -189
- package/.devcontainer/devzone-services.sh +0 -242
- package/manage/scripts/devzone-manifest.sh +0 -171
- package/manage/scripts/uninstall.sh +0 -234
- package/manage/scripts/workspace/argocd-services-svc.sh +0 -112
- package/manage/scripts/workspace/argocd-services.sh +0 -182
- package/manage/scripts/workspace/argocd-workspace.sh +0 -227
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck shell=bash
|
|
3
|
-
# devzone, services of the cluster and their apply functions.
|
|
4
|
-
# Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
|
|
5
|
-
# functions only, shared variables are defined in devzone.
|
|
6
|
-
|
|
7
|
-
# Runs a long command, writing "still running" every DEVZONE_PROGRESS s on
|
|
8
|
-
# stderr: a silent installation looks blocked (#195)
|
|
9
|
-
with_progress() {
|
|
10
|
-
local step="${DEVZONE_PROGRESS:-30}" elapsed=0 pid code=0
|
|
11
|
-
"$@" &
|
|
12
|
-
pid=$!
|
|
13
|
-
while kill -0 "$pid" 2>/dev/null; do
|
|
14
|
-
sleep 1
|
|
15
|
-
elapsed=$((elapsed + 1))
|
|
16
|
-
if [ $((elapsed % step)) -eq 0 ] && kill -0 "$pid" 2>/dev/null; then
|
|
17
|
-
echo "devzone : … still running (${elapsed} s)" >&2
|
|
18
|
-
fi
|
|
19
|
-
done
|
|
20
|
-
wait "$pid" || code=$?
|
|
21
|
-
return "$code"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
# File that marks an active module in failure (content: where to look); next to
|
|
25
|
-
# the state, in its volume: the state shows it at each startup
|
|
26
|
-
failure_marker_file() {
|
|
27
|
-
echo "$ETAT-failed-$1"
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
# Services in the Kubernetes workspace pod (#528): gitlab, postgres and argocd
|
|
31
|
-
# live in the cluster, installed from the workstation (devzone workspace
|
|
32
|
-
# services). The pod has no kubeconfig and a limited account (#430): their
|
|
33
|
-
# presence is the cluster DNS (like #515), never an installer failure marker.
|
|
34
|
-
in_pod() {
|
|
35
|
-
[ "${DEVZONE_WORKSPACE:-}" = kubernetes ]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
service_module() {
|
|
39
|
-
case "$1" in
|
|
40
|
-
gitlab | postgres | argocd) return 0 ;;
|
|
41
|
-
esac
|
|
42
|
-
return 1
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
# DNS name of the service of a module: <service>.<namespace>.svc
|
|
46
|
-
service_dns() {
|
|
47
|
-
case "$1" in
|
|
48
|
-
gitlab) echo "gitlab-webservice-default.devzone-gitlab${INSTANCE_SUFFIX}.svc" ;;
|
|
49
|
-
postgres) echo "postgres.devzone-postgres.svc" ;;
|
|
50
|
-
argocd) echo "argocd-server.devzone-argocd.svc" ;;
|
|
51
|
-
esac
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
service_present() {
|
|
55
|
-
getent hosts "$(service_dns "$1")" >/dev/null 2>&1
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
# Status line of a service module in the pod: present → active; absent → the
|
|
59
|
-
# workstation command that installs it
|
|
60
|
-
service_pod_line() {
|
|
61
|
-
local m="$1"
|
|
62
|
-
if service_present "$m"; then
|
|
63
|
-
printf ' ✔ module %-10s active: %s (%s)\n' "$m" "$(description "$m")" "$(service_dns "$m")"
|
|
64
|
-
elif [ "$(value_of "$m")" = on ]; then
|
|
65
|
-
printf ' ⚠ module %-10s not in the cluster: on the workstation, devzone workspace services enable %s\n' "$m" "$m"
|
|
66
|
-
else
|
|
67
|
-
printf ' ○ module %-10s optional, %s: on the workstation, devzone workspace services enable %s\n' "$m" "$(description "$m")" "$m"
|
|
68
|
-
fi
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
# devzone apply of a service module: in the Kubernetes workspace pod nothing
|
|
72
|
-
# is installed (the workstation does it, #528) and the failure marker of an
|
|
73
|
-
# earlier start is cleared; elsewhere, the installer of the module
|
|
74
|
-
apply_service() {
|
|
75
|
-
if in_pod; then
|
|
76
|
-
rm -f "$(failure_marker_file "$1")"
|
|
77
|
-
echo "devzone: $1 is installed from the workstation (devzone workspace services enable $1): nothing to do in the pod"
|
|
78
|
-
return 0
|
|
79
|
-
fi
|
|
80
|
-
"apply_$1" on
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
apply_kubernetes() {
|
|
84
|
-
if [ "$1" = on ]; then
|
|
85
|
-
# Clusters are connected from the workstation; no script to run here.
|
|
86
|
-
return 0
|
|
87
|
-
else
|
|
88
|
-
rm -f "$HOME/.kube/hote.config"
|
|
89
|
-
# metrics-server removed from the clusters where devzone installed it
|
|
90
|
-
# (devzone=installe marker set by the Go command); via its subcommand
|
|
91
|
-
"$ICI/devzone" metrics remove || true
|
|
92
|
-
echo "devzone : kubernetes disabled"
|
|
93
|
-
fi
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
apply_gitlab() {
|
|
97
|
-
local current_state
|
|
98
|
-
if [ "$1" = on ]; then
|
|
99
|
-
# Skip if the state is ready and the runner online; otherwise install resumes
|
|
100
|
-
current_state="$("$ICI/devzone" gitlab status)"
|
|
101
|
-
if [[ "$current_state" == *"ready"* && "$current_state" == *"runner online"* ]]; then
|
|
102
|
-
echo "devzone : gitlab already active, nothing to do."
|
|
103
|
-
# /etc/hosts regenerated by Docker: gitlab.localhost is set again here too
|
|
104
|
-
"$ICI/devzone" gitlab host-set
|
|
105
|
-
# Failure of an old run cleared: gitlab is ready (#366)
|
|
106
|
-
rm -f "$(failure_marker_file gitlab)"
|
|
107
|
-
else
|
|
108
|
-
echo "devzone : activating gitlab via its installer…"
|
|
109
|
-
if ! "$ICI/devzone" gitlab install; then
|
|
110
|
-
echo "gitlab" > "$(failure_marker_file gitlab)"
|
|
111
|
-
return 1
|
|
112
|
-
fi
|
|
113
|
-
rm -f "$(failure_marker_file gitlab)"
|
|
114
|
-
fi
|
|
115
|
-
else
|
|
116
|
-
# Disable gitlab only if its namespace still exists
|
|
117
|
-
if "$ICI/devzone" gitlab installed; then
|
|
118
|
-
echo "devzone : deactivating gitlab…"
|
|
119
|
-
if [ -n "${DELETE_DATA:-}" ]; then
|
|
120
|
-
"$ICI/devzone" gitlab uninstall --yes
|
|
121
|
-
else
|
|
122
|
-
"$ICI/devzone" gitlab uninstall
|
|
123
|
-
fi
|
|
124
|
-
else
|
|
125
|
-
echo "devzone : gitlab already deactivated (no devzone-gitlab namespace)."
|
|
126
|
-
fi
|
|
127
|
-
fi
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
# Shared PostgreSQL (#280): installed on the devzone cluster, chosen at the
|
|
131
|
-
# first activation (--context, terminal menu, dedicated kind otherwise)
|
|
132
|
-
apply_postgres() {
|
|
133
|
-
local wanted="" confirm_ctx="" expect="" arg ctx actual current_state
|
|
134
|
-
if [ "$1" = on ]; then
|
|
135
|
-
for arg in "${@:2}"; do
|
|
136
|
-
if [ -n "$expect" ]; then
|
|
137
|
-
case "$expect" in
|
|
138
|
-
context) wanted="$arg" ;;
|
|
139
|
-
confirm) confirm_ctx="$arg" ;;
|
|
140
|
-
esac
|
|
141
|
-
expect=""
|
|
142
|
-
continue
|
|
143
|
-
fi
|
|
144
|
-
case "$arg" in
|
|
145
|
-
--context) expect=context ;;
|
|
146
|
-
--confirm) expect=confirm ;;
|
|
147
|
-
*) echo "devzone : unknown argument: $arg (devzone enable postgres --context CTX [--confirm CTX])" >&2; write_value postgres off; return 2 ;;
|
|
148
|
-
esac
|
|
149
|
-
done
|
|
150
|
-
if [ -n "$expect" ]; then
|
|
151
|
-
echo "devzone : $expect expects a context" >&2
|
|
152
|
-
write_value postgres off
|
|
153
|
-
return 2
|
|
154
|
-
fi
|
|
155
|
-
actual="$("$ICI/devzone" kube saved)"
|
|
156
|
-
if [ -n "$wanted" ] && [ -n "$actual" ] && [ "$wanted" != "$actual" ]; then
|
|
157
|
-
echo "devzone : devzone services are on $actual; to change: devzone cluster $wanted" >&2
|
|
158
|
-
write_value postgres off
|
|
159
|
-
return 2
|
|
160
|
-
fi
|
|
161
|
-
if [ -n "$confirm_ctx" ]; then
|
|
162
|
-
ctx="$("$ICI/devzone" kube choose "$wanted" --confirm "$confirm_ctx")" || { write_value postgres off; return 2; }
|
|
163
|
-
else
|
|
164
|
-
ctx="$("$ICI/devzone" kube choose "$wanted")" || { write_value postgres off; return 2; }
|
|
165
|
-
fi
|
|
166
|
-
# Choice kept before the installation: a resume targets the same cluster
|
|
167
|
-
"$ICI/devzone" kube save "$ctx"
|
|
168
|
-
current_state="$("$ICI/devzone" postgres status)"
|
|
169
|
-
# "relay stopped" first: this line also starts with "ready on"
|
|
170
|
-
if [[ "$current_state" == *"relay stopped"* ]]; then
|
|
171
|
-
"$ICI/devzone" postgres relay-start
|
|
172
|
-
echo "devzone : postgres : relay restarted"
|
|
173
|
-
elif [[ "$current_state" == "ready on"* ]]; then
|
|
174
|
-
echo "devzone : postgres already active, nothing to do."
|
|
175
|
-
elif ! "$ICI/devzone" postgres install; then
|
|
176
|
-
echo "postgres" >"$(failure_marker_file postgres)"
|
|
177
|
-
return 1
|
|
178
|
-
fi
|
|
179
|
-
rm -f "$(failure_marker_file postgres)"
|
|
180
|
-
else
|
|
181
|
-
"$ICI/devzone" postgres uninstall
|
|
182
|
-
rm -f "$(failure_marker_file postgres)"
|
|
183
|
-
fi
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
# Argo CD (#411): installed in the services cluster, access through the relay
|
|
187
|
-
# 127.0.0.1:8443; a failure is marked in the state and resumed by devzone apply
|
|
188
|
-
apply_argocd() {
|
|
189
|
-
local current_state
|
|
190
|
-
if [ "$1" = on ]; then
|
|
191
|
-
current_state="$("$ICI/devzone" argocd status)"
|
|
192
|
-
# "relay stopped" first: this line also starts with "ready"
|
|
193
|
-
if [[ "$current_state" == *"relay stopped"* ]]; then
|
|
194
|
-
"$ICI/devzone" argocd relay-start
|
|
195
|
-
echo "devzone : argocd : relay restarted"
|
|
196
|
-
elif [[ "$current_state" == "ready"* ]]; then
|
|
197
|
-
echo "devzone : argocd already active, nothing to do."
|
|
198
|
-
elif ! "$ICI/devzone" argocd install; then
|
|
199
|
-
echo "argocd" >"$(failure_marker_file argocd)"
|
|
200
|
-
return 1
|
|
201
|
-
fi
|
|
202
|
-
rm -f "$(failure_marker_file argocd)"
|
|
203
|
-
else
|
|
204
|
-
"$ICI/devzone" argocd uninstall
|
|
205
|
-
rm -f "$(failure_marker_file argocd)"
|
|
206
|
-
fi
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
# Catalog MySQL (#414): same logic as postgres (relay restarted if stopped),
|
|
210
|
-
# installation delegated to the Go module
|
|
211
|
-
apply_mysql() {
|
|
212
|
-
local current_state ctx
|
|
213
|
-
if [ "$1" = on ]; then
|
|
214
|
-
ctx="$(cluster_saved)"
|
|
215
|
-
if [ -z "$ctx" ]; then
|
|
216
|
-
echo "devzone : mysql: no cluster chosen: devzone enable mysql" >&2
|
|
217
|
-
write_value mysql off
|
|
218
|
-
echo mysql >"$(failure_marker_file mysql)"
|
|
219
|
-
return 2
|
|
220
|
-
fi
|
|
221
|
-
current_state="$("$ICI/devzone" mysql status)"
|
|
222
|
-
# "relay stopped" first: this line also starts with "ready on"
|
|
223
|
-
if [[ "$current_state" == *"relay stopped"* ]]; then
|
|
224
|
-
"$ICI/devzone" mysql relay-start
|
|
225
|
-
echo "devzone : mysql: relay restarted"
|
|
226
|
-
elif [[ "$current_state" == "ready on"* ]]; then
|
|
227
|
-
echo "devzone : mysql already active, nothing to do."
|
|
228
|
-
elif ! "$ICI/devzone" mysql install; then
|
|
229
|
-
echo mysql >"$(failure_marker_file mysql)"
|
|
230
|
-
return 1
|
|
231
|
-
fi
|
|
232
|
-
rm -f "$(failure_marker_file mysql)"
|
|
233
|
-
else
|
|
234
|
-
# Removal without deleting the data: volume kept (#441); the databases
|
|
235
|
-
# only leave with a yes (confirm_removal)
|
|
236
|
-
DEVZONE_STATE="$ETAT" "$ICI/devzone" catalog remove mysql
|
|
237
|
-
if [ -n "${DELETE_DATA:-}" ]; then
|
|
238
|
-
"$ICI/devzone" mysql delete-data --yes
|
|
239
|
-
fi
|
|
240
|
-
rm -f "$(failure_marker_file mysql)"
|
|
241
|
-
fi
|
|
242
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Manifest of a devzone (.devzone.version) and the paths read back from it:
|
|
3
|
-
# checksum of each copied file, safe relative paths, the .gitignore lines of a
|
|
4
|
-
# devzone. Sourced by manage/devzone (update and create), which defines PAQUET
|
|
5
|
-
# (package folder), PACKAGE_ITEMS, GITIGNORE_LINES and version().
|
|
6
|
-
# shellcheck disable=SC2154 # PAQUET, PACKAGE_ITEMS, GITIGNORE_LINES: set by manage/devzone
|
|
7
|
-
|
|
8
|
-
# SHA-256 checksum of a file, computed by node (portable: macOS, Linux, Windows
|
|
9
|
-
# Git Bash); the path is passed as an argument, as for version()
|
|
10
|
-
checksum() {
|
|
11
|
-
node -e 'const fs = require("fs"), crypto = require("crypto"); const h = crypto.createHash("sha256"); h.update(fs.readFileSync(process.argv[1])); process.stdout.write(h.digest("hex"))' "$1"
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
# Files of the package copied into a devzone, absolute paths
|
|
15
|
-
package_files() {
|
|
16
|
-
local base
|
|
17
|
-
for base in "${PACKAGE_ITEMS[@]}"; do
|
|
18
|
-
if [ -d "$PAQUET/$base" ]; then
|
|
19
|
-
find "$PAQUET/$base" -type f -print
|
|
20
|
-
elif [ -f "$PAQUET/$base" ]; then
|
|
21
|
-
printf '%s\n' "$PAQUET/$base"
|
|
22
|
-
fi
|
|
23
|
-
done
|
|
24
|
-
if [ -d "$PAQUET/manage/scripts" ]; then
|
|
25
|
-
find "$PAQUET/manage/scripts" -type f -print
|
|
26
|
-
fi
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
# The same files, relative to the package, sorted
|
|
30
|
-
relative_package_files() {
|
|
31
|
-
local f
|
|
32
|
-
package_files | while IFS= read -r f; do
|
|
33
|
-
printf '%s\n' "${f#"$PAQUET"/}"
|
|
34
|
-
done | LC_ALL=C sort
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
# .devzone.version: version of the folder, then one checksum per copied file
|
|
38
|
-
write_manifest() {
|
|
39
|
-
local folder="$1" rel
|
|
40
|
-
{
|
|
41
|
-
printf 'version %s\n' "$(version)"
|
|
42
|
-
relative_package_files | while IFS= read -r rel; do
|
|
43
|
-
printf '%s %s\n' "$(checksum "$folder/$rel")" "$rel"
|
|
44
|
-
done
|
|
45
|
-
} >"$folder/.devzone.version"
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
# Version written in the manifest of a folder, 'inconnue' when there is none
|
|
49
|
-
folder_version() {
|
|
50
|
-
local folder="${1:-.}" v
|
|
51
|
-
if [ -f "$folder/.devzone.version" ]; then
|
|
52
|
-
v="$(sed -n '1s/^version //p' "$folder/.devzone.version" 2>/dev/null | head -1 || true)"
|
|
53
|
-
if [ -n "$v" ]; then
|
|
54
|
-
printf '%s\n' "$v"
|
|
55
|
-
return 0
|
|
56
|
-
fi
|
|
57
|
-
fi
|
|
58
|
-
printf 'inconnue\n'
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
# Checksum recorded in the manifest of a folder for one path; fails if absent
|
|
62
|
-
manifest_checksum() {
|
|
63
|
-
local folder="$1" target="$2" line h p
|
|
64
|
-
[ -f "$folder/.devzone.version" ] || return 1
|
|
65
|
-
while IFS= read -r line; do
|
|
66
|
-
case "$line" in
|
|
67
|
-
version\ * | '') continue ;;
|
|
68
|
-
esac
|
|
69
|
-
h="${line%% *}"
|
|
70
|
-
p="${line#* }"
|
|
71
|
-
if [ "$p" = "$target" ]; then
|
|
72
|
-
printf '%s\n' "$h"
|
|
73
|
-
return 0
|
|
74
|
-
fi
|
|
75
|
-
done <"$folder/.devzone.version"
|
|
76
|
-
return 1
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
# Paths listed in the manifest of a folder
|
|
80
|
-
manifest_files() {
|
|
81
|
-
local folder="$1" line
|
|
82
|
-
[ -f "$folder/.devzone.version" ] || return 0
|
|
83
|
-
while IFS= read -r line; do
|
|
84
|
-
case "$line" in
|
|
85
|
-
version\ * | '') continue ;;
|
|
86
|
-
esac
|
|
87
|
-
printf '%s\n' "${line#* }"
|
|
88
|
-
done <"$folder/.devzone.version"
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
# A path read from the manifest is accepted only if it is relative and simple
|
|
92
|
-
# (no '..', '.', '//', newline or tab), under a folder managed by the package
|
|
93
|
-
# or a file at its root. Otherwise it is refused.
|
|
94
|
-
path_allowed() {
|
|
95
|
-
local rel="$1"
|
|
96
|
-
case "$rel" in
|
|
97
|
-
'' | /* | *//* | *$'\n'* | *$'\t'*) return 1 ;;
|
|
98
|
-
esac
|
|
99
|
-
case "/$rel/" in
|
|
100
|
-
*/../* | */./*) return 1 ;;
|
|
101
|
-
esac
|
|
102
|
-
case "$rel" in
|
|
103
|
-
.devcontainer/* | manage/* | core/* | scripts/* | \
|
|
104
|
-
Makefile | README.md | LICENSE | .gitattributes) return 0 ;;
|
|
105
|
-
esac
|
|
106
|
-
return 1
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
# Defense in depth: the real parent folder must stay under the real devzone
|
|
110
|
-
# folder (pwd -P), so a symbolic link leading out of it is refused.
|
|
111
|
-
inside_folder() {
|
|
112
|
-
local folder="$1" rel="$2" root parent
|
|
113
|
-
root="$(cd "$folder" && pwd -P)" || return 1
|
|
114
|
-
parent="$(cd "$folder/$(dirname "$rel")" 2>/dev/null && pwd -P)" || return 1
|
|
115
|
-
case "$parent" in
|
|
116
|
-
"$root" | "$root"/*) return 0 ;;
|
|
117
|
-
esac
|
|
118
|
-
return 1
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
# Never touched by update, even when an old manifest lists them
|
|
122
|
-
is_protected() {
|
|
123
|
-
case "$1" in
|
|
124
|
-
workspace | workspace/* | .devzone.version | .devzone.modules | .devzone.modules-* | \
|
|
125
|
-
.devzone.packages | .password | .app | .devzone.log | .git | .git/*) return 0 ;;
|
|
126
|
-
esac
|
|
127
|
-
return 1
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
# True when the whole line $2 is in the file $1
|
|
131
|
-
in_list() {
|
|
132
|
-
grep -Fqx -- "$2" "$1"
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
# Old devzone layout (before manage/): core/ is recognized only by its marker
|
|
136
|
-
# files, scripts/ only by its two own files. Otherwise it is a folder of the
|
|
137
|
-
# user: never touched.
|
|
138
|
-
old_tree() {
|
|
139
|
-
local folder="$1" tree="$2"
|
|
140
|
-
case "$tree" in
|
|
141
|
-
core)
|
|
142
|
-
[ -f "$folder/core/devzone" ] || [ -f "$folder/core/scripts/uninstall.sh" ]
|
|
143
|
-
;;
|
|
144
|
-
scripts)
|
|
145
|
-
[ -f "$folder/scripts/uninstall.sh" ] && [ -f "$folder/scripts/launch.sh" ]
|
|
146
|
-
;;
|
|
147
|
-
*) return 1 ;;
|
|
148
|
-
esac
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
# File known from the old package: the names of manage/scripts/ moved into
|
|
152
|
-
# core/scripts/ or scripts/, core/devzone, and all of core/test/ and core/docs/.
|
|
153
|
-
known_old_file() {
|
|
154
|
-
local rel="$1" name
|
|
155
|
-
case "$rel" in
|
|
156
|
-
core/devzone | core/test/* | core/docs/*) return 0 ;;
|
|
157
|
-
core/scripts/*) name="${rel#core/scripts/}" ;;
|
|
158
|
-
scripts/*) name="${rel#scripts/}" ;;
|
|
159
|
-
*) return 1 ;;
|
|
160
|
-
esac
|
|
161
|
-
[ -f "$PAQUET/manage/scripts/$name" ]
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
# Adds the missing lines of GITIGNORE_LINES to the .gitignore of a folder
|
|
165
|
-
complete_gitignore() {
|
|
166
|
-
local folder="$1" line
|
|
167
|
-
touch "$folder/.gitignore"
|
|
168
|
-
for line in "${GITIGNORE_LINES[@]}"; do
|
|
169
|
-
grep -qxF -- "$line" "$folder/.gitignore" || printf '%s\n' "$line" >>"$folder/.gitignore"
|
|
170
|
-
done
|
|
171
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Full devzone uninstall, run on the host:
|
|
3
|
-
# make desinstaller everything, after confirmation
|
|
4
|
-
# make desinstaller KEEP=logins everything except logins (gh, git,
|
|
5
|
-
# Claude Code, opencode, modules)
|
|
6
|
-
# Removes: container, image, kind clusters of the instance and containers
|
|
7
|
-
# labeled devzone.instance on the host Docker (#291), former internal Docker
|
|
8
|
-
# volume (installs before #291), devzone-* volumes, metrics-server installed by
|
|
9
|
-
# devzone on host local clusters, namespace of devzone services (postgres
|
|
10
|
-
# module) on the chosen host cluster. Never touches: workspace/ (your projects),
|
|
11
|
-
# the base image, a metrics-server not installed by devzone.
|
|
12
|
-
# Without a terminal: CONFIRM=yes.
|
|
13
|
-
set -euo pipefail
|
|
14
|
-
|
|
15
|
-
# devzone folder: two levels above the script (manage/scripts/), so the command
|
|
16
|
-
# works when run from any folder
|
|
17
|
-
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
18
|
-
STATE="$HERE/.devzone.state"
|
|
19
|
-
KEEP="${KEEP:-${GARDER:-}}"
|
|
20
|
-
LOGINS=(gh git claude opencode-config opencode-data config)
|
|
21
|
-
LOCAL_CTX='^(kind-.*|docker-desktop|rancher-desktop|orbstack|minikube)$'
|
|
22
|
-
|
|
23
|
-
case "$KEEP" in "" | logins | connexions) ;; *)
|
|
24
|
-
echo "KEEP: unknown value: $KEEP (only value: logins)" >&2
|
|
25
|
-
exit 1
|
|
26
|
-
;;
|
|
27
|
-
esac
|
|
28
|
-
|
|
29
|
-
# Host engine first: without it every call would show its raw error. The check
|
|
30
|
-
# is the Go program's (#884), found through DEVZONE_HOST_BIN, exported by manage/devzone
|
|
31
|
-
"${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" host-check "${DEVZONE_COMMAND:-make desinstaller}" || exit 1
|
|
32
|
-
|
|
33
|
-
# .argocd.conf of the devzone folder: the GitOps repository is never removed
|
|
34
|
-
# with the devzone, only its designation can be changed later
|
|
35
|
-
# shellcheck disable=SC2034 # read by conf.sh
|
|
36
|
-
ARGOCD_CONF="$HERE/.argocd.conf"
|
|
37
|
-
# shellcheck source=SCRIPTDIR/../.devcontainer/argocd/conf.sh
|
|
38
|
-
# shellcheck disable=SC1091
|
|
39
|
-
. "$HERE/.devcontainer/argocd/conf.sh"
|
|
40
|
-
|
|
41
|
-
# Instance name: an instance name may contain a dash (my-devzone),
|
|
42
|
-
# so DEVZONE_VOLUMES is never split
|
|
43
|
-
DEVZONE_INSTANCE="${DEVZONE_VOLUMES:-devzone}"
|
|
44
|
-
INSTANCE_SUFFIX=""
|
|
45
|
-
if [ "$DEVZONE_INSTANCE" != "devzone" ]; then
|
|
46
|
-
INSTANCE_SUFFIX="-${DEVZONE_INSTANCE}"
|
|
47
|
-
fi
|
|
48
|
-
|
|
49
|
-
# Run INSIDE the container, docker talks to host Docker (#291): volumes, images
|
|
50
|
-
# and containers seen are those of the workstation, and the host instance name
|
|
51
|
-
# (DEVZONE_VOLUMES) is unknown here. Touching Docker from the container could
|
|
52
|
-
# remove another instance's resources (or the default instance): only the
|
|
53
|
-
# Kubernetes part is handled.
|
|
54
|
-
# DEVZONE_IN_CONTAINER=yes|no forces the mode (tests, which run inside a container)
|
|
55
|
-
case "${DEVZONE_IN_CONTAINER:-}" in
|
|
56
|
-
yes) INSIDE_CONTAINER=true ;;
|
|
57
|
-
no) INSIDE_CONTAINER=false ;;
|
|
58
|
-
*) INSIDE_CONTAINER=false; [ ! -f /.dockerenv ] || INSIDE_CONTAINER=true ;;
|
|
59
|
-
esac
|
|
60
|
-
|
|
61
|
-
# --- Inventory ---------------------------------------------------------------
|
|
62
|
-
echo "▶ Inventory (folder $HERE)"
|
|
63
|
-
containers=() images=() dind=() volumes=() kept=()
|
|
64
|
-
kind_containers="" labeled_containers=""
|
|
65
|
-
if [ "$INSIDE_CONTAINER" = true ]; then
|
|
66
|
-
echo "ℹ Inside the container: only metrics-server and devzone services are handled."
|
|
67
|
-
echo " Container, image, volumes and kind clusters: make desinstaller on your machine."
|
|
68
|
-
else
|
|
69
|
-
# Label set with the path as opened (VS Code, make): logical or physical path
|
|
70
|
-
# depending on symlinks; both are searched
|
|
71
|
-
ids="$(for path in "$HERE" "$(cd "$HERE" && pwd -P)"; do docker ps -aq --filter "label=devcontainer.local_folder=$path" 2>/dev/null || true; done | sort -u)"
|
|
72
|
-
for id in ${ids}; do
|
|
73
|
-
containers+=("$id")
|
|
74
|
-
images+=("$(docker inspect "$id" --format '{{.Config.Image}}')")
|
|
75
|
-
v="$(docker inspect "$id" --format '{{range .Mounts}}{{if eq .Destination "/var/lib/docker"}}{{.Name}}{{end}}{{end}}')"
|
|
76
|
-
[ -z "$v" ] || dind+=("$v")
|
|
77
|
-
done
|
|
78
|
-
# Container already removed: image and internal Docker noted then
|
|
79
|
-
if [ "${#containers[@]}" -eq 0 ] && [ -f "$STATE" ]; then
|
|
80
|
-
# Read only, never executed
|
|
81
|
-
IMAGE="$(sed -n 's/^IMAGE=//p' "$STATE")"
|
|
82
|
-
DIND="$(sed -n 's/^DIND=//p' "$STATE")"
|
|
83
|
-
[ -z "${IMAGE:-}" ] || ! docker image inspect "$IMAGE" >/dev/null 2>&1 || images+=("$IMAGE")
|
|
84
|
-
[ -z "${DIND:-}" ] || ! docker volume inspect "$DIND" >/dev/null 2>&1 || dind+=("$DIND")
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
# Containers of the instance kind clusters on host Docker: a kind cluster is
|
|
88
|
-
# nothing more than containers carrying this label
|
|
89
|
-
kind_containers_devzone="$(docker ps -aq --filter "label=io.x-k8s.kind.cluster=devzone${INSTANCE_SUFFIX}" 2>/dev/null | sort -u)"
|
|
90
|
-
kind_containers_gitlab="$(docker ps -aq --filter "label=io.x-k8s.kind.cluster=gitlab${INSTANCE_SUFFIX}" 2>/dev/null | sort -u)"
|
|
91
|
-
kind_containers="${kind_containers_devzone} ${kind_containers_gitlab}"
|
|
92
|
-
kind_containers="${kind_containers# }"
|
|
93
|
-
kind_containers="${kind_containers% }"
|
|
94
|
-
|
|
95
|
-
# Containers carrying label devzone.instance=<instance>
|
|
96
|
-
labeled_containers="$(docker ps -aq --filter "label=devzone.instance=$DEVZONE_INSTANCE" 2>/dev/null | sort -u)"
|
|
97
|
-
|
|
98
|
-
# Volumes: exact names from devcontainer.json (including DEVZONE_VOLUMES prefix)
|
|
99
|
-
config="$(npx -y @devcontainers/cli read-configuration --workspace-folder "$HERE" 2>/dev/null)" || {
|
|
100
|
-
echo "✖ cannot read .devcontainer/devcontainer.json (npx @devcontainers/cli)" >&2
|
|
101
|
-
exit 1
|
|
102
|
-
}
|
|
103
|
-
# shellcheck disable=SC2016 # ${m.source}: JavaScript template, not shell
|
|
104
|
-
for name in $(node -e '
|
|
105
|
-
const c = JSON.parse(require("fs").readFileSync(0, "utf8")).configuration;
|
|
106
|
-
for (const m of c.mounts || []) {
|
|
107
|
-
const s = typeof m === "string" ? m : `source=${m.source},type=${m.type}`;
|
|
108
|
-
if (/type=volume/.test(s)) { const r = /source=([^,]+)/.exec(s); if (r) console.log(r[1]); }
|
|
109
|
-
}' <<<"$config"); do
|
|
110
|
-
docker volume inspect "$name" >/dev/null 2>&1 || continue
|
|
111
|
-
keep=false
|
|
112
|
-
if [ "$KEEP" = logins ] || [ "$KEEP" = connexions ]; then
|
|
113
|
-
for c in "${LOGINS[@]}"; do [[ "$name" == *-"$c" ]] && keep=true; done
|
|
114
|
-
fi
|
|
115
|
-
if [ "$keep" = true ]; then kept+=("$name"); else volumes+=("$name"); fi
|
|
116
|
-
done
|
|
117
|
-
fi
|
|
118
|
-
|
|
119
|
-
# metrics-server installed by devzone (label devzone=installed), on reachable
|
|
120
|
-
# host local clusters; never another one
|
|
121
|
-
metrics=() foreign=()
|
|
122
|
-
if command -v kubectl >/dev/null 2>&1; then
|
|
123
|
-
for ctx in $(kubectl config get-contexts -o name 2>/dev/null | grep -E "$LOCAL_CTX" || true); do
|
|
124
|
-
k=(kubectl --context "$ctx" --request-timeout=5s)
|
|
125
|
-
"${k[@]}" get --raw /readyz >/dev/null 2>&1 || continue
|
|
126
|
-
mark="$("${k[@]}" -n kube-system get deployment metrics-server -o jsonpath='{.metadata.labels.devzone}' 2>/dev/null)" || continue
|
|
127
|
-
if [ "$mark" = installe ] || [ "$mark" = installed ]; then metrics+=("$ctx"); else foreign+=("$ctx"); fi
|
|
128
|
-
done
|
|
129
|
-
fi
|
|
130
|
-
|
|
131
|
-
# devzone services (postgres module, #280) on a host cluster: the namespace it
|
|
132
|
-
# created (label managed-by=devzone). On the dedicated kind, they go with that
|
|
133
|
-
# cluster (removed below). Read only, never executed.
|
|
134
|
-
services=()
|
|
135
|
-
CLUSTER="$(sed -n 's/^cluster=//p' "$HERE/.devzone.modules" 2>/dev/null | tail -1 || true)"
|
|
136
|
-
if [ -n "$CLUSTER" ] && [[ "$CLUSTER" != kind-* ]] && command -v kubectl >/dev/null 2>&1; then
|
|
137
|
-
for ns in $(kubectl --context "$CLUSTER" --request-timeout=5s get namespaces -l app.kubernetes.io/managed-by=devzone -o name 2>/dev/null || true); do
|
|
138
|
-
services+=("${ns#namespace/}")
|
|
139
|
-
done
|
|
140
|
-
fi
|
|
141
|
-
|
|
142
|
-
# --- Confirmation ------------------------------------------------------------
|
|
143
|
-
show_list() { if [ "$#" -eq 0 ]; then echo " (none)"; else printf ' %s\n' "$@"; fi; }
|
|
144
|
-
echo "To remove:"
|
|
145
|
-
echo " container(s):"; show_list ${containers[@]+"${containers[@]}"}
|
|
146
|
-
echo " image(s):"; show_list ${images[@]+"${images[@]}"}
|
|
147
|
-
echo " former internal Docker (installs before #291):"; show_list ${dind[@]+"${dind[@]}"}
|
|
148
|
-
echo " volumes:"; show_list ${volumes[@]+"${volumes[@]}"}
|
|
149
|
-
echo " metrics-server installed by devzone on:"; show_list ${metrics[@]+"${metrics[@]}"}
|
|
150
|
-
echo " devzone services (including postgres databases) on ${CLUSTER:-no cluster}:"; show_list ${services[@]+"${services[@]}"}
|
|
151
|
-
echo " kind clusters of the instance on host Docker:"
|
|
152
|
-
# shellcheck disable=SC2086
|
|
153
|
-
show_list ${kind_containers}
|
|
154
|
-
echo " containers labeled devzone.instance=$DEVZONE_INSTANCE:"
|
|
155
|
-
# shellcheck disable=SC2086
|
|
156
|
-
show_list ${labeled_containers}
|
|
157
|
-
[ "${#kept[@]}" -eq 0 ] || { echo "Kept (KEEP=logins):"; printf ' %s\n' "${kept[@]}"; }
|
|
158
|
-
if [ "$INSIDE_CONTAINER" = false ] && [ "${#containers[@]}" -eq 0 ] && [ ! -f "$STATE" ] && [ "${#images[@]}" -eq 0 ]; then
|
|
159
|
-
echo "ℹ No container and no image trace: if an older removal left them,"
|
|
160
|
-
echo " find them with: docker images 'vsc-$(basename "$HERE")-*' ; docker volume ls -q -f name=dind-var-lib-docker"
|
|
161
|
-
fi
|
|
162
|
-
|
|
163
|
-
nb_ck=0; for _ in ${kind_containers}; do nb_ck=$((nb_ck + 1)); done
|
|
164
|
-
nb_ce=0; for _ in ${labeled_containers}; do nb_ce=$((nb_ce + 1)); done
|
|
165
|
-
total=$((${#containers[@]} + ${#images[@]} + ${#dind[@]} + ${#volumes[@]} + ${#metrics[@]} + ${#services[@]} + nb_ck + nb_ce))
|
|
166
|
-
if [ "$total" -eq 0 ]; then
|
|
167
|
-
echo "✔ Nothing to remove."
|
|
168
|
-
else
|
|
169
|
-
CONFIRM_VALUE="${CONFIRM:-${CONFIRMER:-}}"
|
|
170
|
-
if [ "$CONFIRM_VALUE" != yes ]; then
|
|
171
|
-
if [ ! -t 0 ]; then
|
|
172
|
-
echo "✖ Cannot confirm without a terminal: CONFIRM=yes make desinstaller" >&2
|
|
173
|
-
exit 1
|
|
174
|
-
fi
|
|
175
|
-
read -r -p "Permanently remove? Type yes: " answer
|
|
176
|
-
case "$answer" in
|
|
177
|
-
yes) ;;
|
|
178
|
-
*) echo "Canceled: nothing was removed."; exit 0 ;;
|
|
179
|
-
esac
|
|
180
|
-
fi
|
|
181
|
-
|
|
182
|
-
# --- Removal -------------------------------------------------------------
|
|
183
|
-
for id in ${containers[@]+"${containers[@]}"}; do docker rm -f "$id" >/dev/null && echo "✔ container removed: $id"; done
|
|
184
|
-
for i in ${images[@]+"${images[@]}"}; do docker rmi "$i" >/dev/null && echo "✔ image removed: $i"; done
|
|
185
|
-
for v in ${dind[@]+"${dind[@]}"} ${volumes[@]+"${volumes[@]}"}; do docker volume rm "$v" >/dev/null && echo "✔ volume removed: $v"; done
|
|
186
|
-
if [ "${#metrics[@]}" -gt 0 ]; then
|
|
187
|
-
version="$(sed -n 's/^METRICS_SERVER_VERSION=//p' "$HERE/.devcontainer/versions.env" | head -1)"
|
|
188
|
-
manifest="https://github.com/kubernetes-sigs/metrics-server/releases/download/${version}/components.yaml"
|
|
189
|
-
for ctx in "${metrics[@]}"; do
|
|
190
|
-
kubectl --context "$ctx" delete -f "$manifest" --ignore-not-found >/dev/null &&
|
|
191
|
-
echo "✔ metrics-server removed: $ctx"
|
|
192
|
-
done
|
|
193
|
-
fi
|
|
194
|
-
for ns in ${services[@]+"${services[@]}"}; do
|
|
195
|
-
kubectl --context "$CLUSTER" delete namespace "$ns" --wait=true >/dev/null &&
|
|
196
|
-
echo "✔ namespace removed: $ns ($CLUSTER)"
|
|
197
|
-
done
|
|
198
|
-
for id in ${kind_containers}; do
|
|
199
|
-
docker rm -f "$id" >/dev/null 2>&1 && echo "✔ kind cluster container removed: $id"
|
|
200
|
-
done
|
|
201
|
-
# kind Docker network: removed only if no container uses it anymore
|
|
202
|
-
kind_network=""
|
|
203
|
-
[ "$INSIDE_CONTAINER" = true ] || kind_network="$(docker network inspect kind 2>/dev/null || true)"
|
|
204
|
-
if [ -n "$kind_network" ] && printf '%s\n' "$kind_network" | grep -q '"Containers": {}'; then
|
|
205
|
-
if docker network rm kind >/dev/null 2>&1; then
|
|
206
|
-
echo "✔ kind Docker network removed"
|
|
207
|
-
fi
|
|
208
|
-
fi
|
|
209
|
-
for id in ${labeled_containers}; do
|
|
210
|
-
docker rm -f "$id" >/dev/null 2>&1 && echo "✔ labeled container removed: $id"
|
|
211
|
-
done
|
|
212
|
-
fi
|
|
213
|
-
rm -f "$HERE/.devzone.log" "$STATE"
|
|
214
|
-
|
|
215
|
-
# Instance module state (one "module=on|off" line): removed, modules return to
|
|
216
|
-
# their default values on next start
|
|
217
|
-
rm -f "$HERE/.devzone.modules"
|
|
218
|
-
|
|
219
|
-
# --- What remains ------------------------------------------------------------
|
|
220
|
-
echo
|
|
221
|
-
echo "Not touched (remove yourself if you want):"
|
|
222
|
-
echo " workspace/: your projects"
|
|
223
|
-
for ctx in ${foreign[@]+"${foreign[@]}"}; do
|
|
224
|
-
echo " metrics-server on $ctx: not installed by devzone (kubectl --context $ctx -n kube-system delete deployment metrics-server)"
|
|
225
|
-
done
|
|
226
|
-
command -v kubectl >/dev/null 2>&1 || echo " metrics-server: kubectl not on host, host clusters not checked"
|
|
227
|
-
echo " base image mcr.microsoft.com/devcontainers/base (shared): docker rmi mcr.microsoft.com/devcontainers/base:ubuntu-24.04"
|
|
228
|
-
echo " devcontainer CLI npx cache: ~/.npm/_npx"
|
|
229
|
-
echo " \"GitHub CLI\" authorization on your account: GitHub → Settings → Applications"
|
|
230
|
-
ARGOCD_REPO="$(conf_get argocd repo)"
|
|
231
|
-
if [ -n "$ARGOCD_REPO" ] && [ "$ARGOCD_REPO" != none ]; then
|
|
232
|
-
echo " GitOps repository not removed: $ARGOCD_REPO (delete it yourself if you want to)"
|
|
233
|
-
fi
|
|
234
|
-
echo " this folder: $HERE"
|