devzone 2.0.0 → 4.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/command-aliases.sh +17 -8
- package/.devcontainer/devzone +93 -1496
- 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 +191 -195
- package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
- package/manage/devzone +7 -11
- package/manage/scripts/argocd-workspace.sh +1 -1
- package/manage/scripts/{check-charts.sh → ci/check-charts.sh} +1 -1
- package/manage/scripts/{check-english.sh → ci/check-english.sh} +1 -1
- package/manage/scripts/{check-go-layout.sh → ci/check-go-layout.sh} +1 -1
- package/manage/scripts/{check-names.sh → ci/check-names.sh} +7 -6
- package/manage/scripts/{check-utf8-vars.sh → ci/check-utf8-vars.sh} +1 -1
- package/manage/scripts/{versions.sh → ci/versions.sh} +8 -8
- package/manage/scripts/create-cluster.sh +1 -1
- package/manage/scripts/create-mode.sh +11 -18
- package/manage/scripts/devzone-create.sh +7 -35
- 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/ports-apps.sh +1 -1
- package/manage/scripts/ports-workspace.sh +7 -7
- package/manage/scripts/poste.sh +6 -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/manage/workspace.sh +2 -12
- 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/manage/scripts/docker-workstation.sh +0 -73
- package/manage/scripts/migrate-revert.sh +0 -60
- package/manage/scripts/migrate.sh +0 -243
- /package/manage/scripts/{ci-dns.sh → ci/ci-dns.sh} +0 -0
package/.devcontainer/ports.sh
CHANGED
|
@@ -1,227 +1,231 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# ports.sh open <n>
|
|
5
|
-
# ports.sh list
|
|
6
|
-
# ports.sh close <n>
|
|
7
|
-
# ports.sh restart
|
|
8
|
-
# ports.sh resume
|
|
9
|
-
#
|
|
10
|
-
#
|
|
2
|
+
# Port relays (#290): applications of the devzone container reachable from
|
|
3
|
+
# 127.0.0.1 of the workstation, one alpine/socat container per port.
|
|
4
|
+
# ports.sh open <n> opens the relay of port <n>
|
|
5
|
+
# ports.sh list relays of the state: port, active, application
|
|
6
|
+
# ports.sh close <n> removes the relay and the port from the state
|
|
7
|
+
# ports.sh restart recreates the relays of the state toward the current IP
|
|
8
|
+
# ports.sh resume one-line summary for the devzone recap
|
|
9
|
+
# The state is the line "ports=8080,3000" of DEVZONE_STATE (sorted, no duplicate).
|
|
10
|
+
# ROOT: a single dirname from HERE (.devcontainer) = root of the devzone repository.
|
|
11
11
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then set -euo pipefail; fi
|
|
12
12
|
|
|
13
13
|
SOCAT_IMAGE=alpine/socat:1.8.0.3
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
ETAT="${
|
|
15
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
16
|
+
ROOT="${DEVZONE_ROOT:-$(dirname "$HERE")}"
|
|
17
|
+
ETAT="${DEVZONE_STATE:-$ROOT/.devzone.modules}"
|
|
18
18
|
INSTANCE="${DEVZONE_INSTANCE:-devzone}"
|
|
19
19
|
|
|
20
|
-
#
|
|
20
|
+
# Safe state write (#417): lock, temporary file in the state folder, backup copy
|
|
21
21
|
# shellcheck source=SCRIPTDIR/state.sh
|
|
22
22
|
# shellcheck disable=SC1091
|
|
23
|
-
. "$
|
|
23
|
+
. "$HERE/state.sh"
|
|
24
24
|
|
|
25
25
|
refuse() { echo "devzone : port : $*" >&2; exit 1; }
|
|
26
26
|
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
# Application labels: the list shows them in English. The JSON output keeps its
|
|
28
|
+
# French values (read by the tools, #557): a contract, UTF-8 written as byte escapes.
|
|
29
|
+
APP_RESPONDS="application responds"
|
|
30
|
+
APP_NONE="no application"
|
|
31
|
+
# shellcheck disable=SC2034 # read by ports-json.sh and ports-auto.sh (sourced)
|
|
32
|
+
JSON_APP_RESPONDS=$'application r\303\251pond'
|
|
33
|
+
# shellcheck disable=SC2034 # read by ports-json.sh and ports-auto.sh (sourced)
|
|
34
|
+
JSON_APP_NONE="aucune application"
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
relay_name() { echo "devzone-$INSTANCE-port-$1"; }
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
port_valid() { case "${1:-}" in '' | *[!0-9]*) return 1 ;; esac; [ "$1" -ge 1 ] 2>/dev/null && [ "$1" -le 65535 ] 2>/dev/null; }
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
validate_port() { port_valid "${1:-}" || refuse "invalid port : ${1:-(none)} (1-65535)"; }
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
read_ports() { grep -E '^ports=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2- || true; }
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
sort_ports() {
|
|
41
45
|
printf '%s\n' "${1:-}" | tr ',' '\n' | awk 'NF && $0 ~ /^[0-9]+$/ { print }' | sort -n -u | paste -sd, -
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
#
|
|
45
|
-
|
|
46
|
-
state_write ports "${1:-}" || { echo "devzone : port :
|
|
48
|
+
# Writes the ports= line of the state (#417: never mv outside state.sh)
|
|
49
|
+
write_ports() {
|
|
50
|
+
state_write ports "${1:-}" || { echo "devzone : port : state not saved : $ETAT" >&2; exit 1; }
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
add_port() {
|
|
50
54
|
local port="$1"
|
|
51
|
-
|
|
55
|
+
write_ports "$(sort_ports "$(read_ports),$port")"
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
local port="$1"
|
|
56
|
-
# shellcheck disable=SC2046 #
|
|
57
|
-
for p in $(printf '%s' "$(
|
|
58
|
-
[ "$p" = "$port" ] ||
|
|
58
|
+
remove_port() {
|
|
59
|
+
local port="$1" rest="" p
|
|
60
|
+
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
61
|
+
for p in $(printf '%s' "$(read_ports)" | tr ',' ' '); do
|
|
62
|
+
[ "$p" = "$port" ] || rest="$rest${rest:+,}$p"
|
|
59
63
|
done
|
|
60
|
-
|
|
64
|
+
write_ports "$(sort_ports "$rest")"
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
|
|
66
|
-
local
|
|
67
|
+
# Network and address of the devzone container, read on the host's Docker: the
|
|
68
|
+
# relay runs there and must reach the container by its IP.
|
|
69
|
+
network_ip() {
|
|
70
|
+
local line
|
|
67
71
|
command -v docker >/dev/null 2>&1 || return 1
|
|
68
|
-
|
|
72
|
+
line="$(docker inspect "$(hostname)" \
|
|
69
73
|
--format '{{range $nom, $r := .NetworkSettings.Networks}}{{$nom}} {{$r.IPAddress}}{{"\n"}}{{end}}' 2>/dev/null |
|
|
70
74
|
awk 'NF >= 2 && $2 != "" { print; exit }')" || return 1
|
|
71
|
-
[ -n "$
|
|
72
|
-
|
|
73
|
-
IP="${
|
|
74
|
-
[ -n "$
|
|
75
|
+
[ -n "$line" ] || return 1
|
|
76
|
+
NETWORK="${line%% *}"
|
|
77
|
+
IP="${line#* }"
|
|
78
|
+
[ -n "$NETWORK" ] && [ -n "$IP" ]
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
local
|
|
79
|
-
|
|
81
|
+
relay_exists() {
|
|
82
|
+
local name
|
|
83
|
+
name="$(relay_name "$1")"
|
|
80
84
|
command -v docker >/dev/null 2>&1 || return 1
|
|
81
|
-
[ -n "$(docker ps -a --filter "name=^$
|
|
82
|
-
grep -Fx "$
|
|
85
|
+
[ -n "$(docker ps -a --filter "name=^$name$" --format '{{.Names}}' 2>/dev/null |
|
|
86
|
+
grep -Fx "$name" || true)" ]
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
local
|
|
87
|
-
|
|
89
|
+
relay_active() {
|
|
90
|
+
local name
|
|
91
|
+
name="$(relay_name "$1")"
|
|
88
92
|
command -v docker >/dev/null 2>&1 || return 1
|
|
89
|
-
[ -n "$(docker ps --filter "name=^$
|
|
90
|
-
grep -Fx "$
|
|
93
|
+
[ -n "$(docker ps --filter "name=^$name$" --format '{{.Names}}' 2>/dev/null |
|
|
94
|
+
grep -Fx "$name" || true)" ]
|
|
91
95
|
}
|
|
92
96
|
|
|
93
|
-
#
|
|
94
|
-
#
|
|
95
|
-
|
|
96
|
-
local port="$1"
|
|
97
|
-
|
|
98
|
-
if
|
|
99
|
-
--name "$
|
|
97
|
+
# Launches the relay; on failure, a clear message and code 1 (this function does
|
|
98
|
+
# not change the state)
|
|
99
|
+
launch() {
|
|
100
|
+
local port="$1" network="$2" ip="$3" name output
|
|
101
|
+
name="$(relay_name "$port")"
|
|
102
|
+
if output="$(docker run -d --restart unless-stopped \
|
|
103
|
+
--name "$name" \
|
|
100
104
|
--label "devzone.instance=$INSTANCE" \
|
|
101
105
|
--label "devzone.port=$port" \
|
|
102
|
-
--network "$
|
|
106
|
+
--network "$network" \
|
|
103
107
|
-p "127.0.0.1:$port:$port" \
|
|
104
108
|
"$SOCAT_IMAGE" \
|
|
105
109
|
"tcp-listen:$port,fork,reuseaddr" "tcp-connect:$ip:$port" 2>&1)"; then
|
|
106
110
|
return 0
|
|
107
111
|
fi
|
|
108
|
-
case "$
|
|
112
|
+
case "$output" in
|
|
109
113
|
*"port is already allocated"* | *"address already in use"*)
|
|
110
|
-
echo "devzone : port : port
|
|
114
|
+
echo "devzone : port : port already in use on the workstation : $port" >&2
|
|
111
115
|
;;
|
|
112
116
|
*)
|
|
113
|
-
echo "devzone : port :
|
|
117
|
+
echo "devzone : port : relay on port $port failed : $output" >&2
|
|
114
118
|
;;
|
|
115
119
|
esac
|
|
116
120
|
return 1
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
|
|
123
|
+
open_port() {
|
|
120
124
|
local port="${1:-}"
|
|
121
|
-
|
|
122
|
-
if
|
|
123
|
-
|
|
124
|
-
echo "✔
|
|
125
|
+
validate_port "$port"
|
|
126
|
+
if relay_active "$port"; then
|
|
127
|
+
add_port "$port"
|
|
128
|
+
echo "✔ relay already open: 127.0.0.1:$port on the workstation → $port in the container"
|
|
125
129
|
return 0
|
|
126
130
|
fi
|
|
127
|
-
|
|
128
|
-
docker rm -f "$(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
echo "✔ 127.0.0.1:$port
|
|
131
|
+
network_ip || refuse "devzone container not found: host Docker unreachable?"
|
|
132
|
+
docker rm -f "$(relay_name "$port")" >/dev/null 2>&1 || true
|
|
133
|
+
launch "$port" "$NETWORK" "$IP" || exit 1
|
|
134
|
+
add_port "$port"
|
|
135
|
+
echo "✔ 127.0.0.1:$port on the workstation → $port in the container (relay $(relay_name "$port"))"
|
|
132
136
|
}
|
|
133
137
|
|
|
134
|
-
|
|
138
|
+
close_port() {
|
|
135
139
|
local port="${1:-}"
|
|
136
|
-
|
|
137
|
-
docker rm -f "$(
|
|
138
|
-
|
|
139
|
-
echo "✔
|
|
140
|
+
validate_port "$port"
|
|
141
|
+
docker rm -f "$(relay_name "$port")" >/dev/null 2>&1 || true
|
|
142
|
+
remove_port "$port"
|
|
143
|
+
echo "✔ relay closed: $port"
|
|
140
144
|
}
|
|
141
145
|
|
|
142
|
-
|
|
146
|
+
app_responds() { curl -s -o /dev/null --max-time 2 "http://127.0.0.1:$1" >/dev/null 2>&1; }
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
local ports port
|
|
146
|
-
ports="$(
|
|
148
|
+
list_ports() {
|
|
149
|
+
local ports port mark app
|
|
150
|
+
ports="$(sort_ports "$(read_ports)")"
|
|
147
151
|
if [ -z "$ports" ]; then
|
|
148
|
-
echo "
|
|
152
|
+
echo "no relay (devzone port <n>)"
|
|
149
153
|
return 0
|
|
150
154
|
fi
|
|
151
|
-
# shellcheck disable=SC2046 #
|
|
155
|
+
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
152
156
|
for port in $(printf '%s' "$ports" | tr ',' ' '); do
|
|
153
|
-
if
|
|
154
|
-
|
|
157
|
+
if relay_active "$port"; then
|
|
158
|
+
mark="● active"
|
|
155
159
|
else
|
|
156
|
-
|
|
160
|
+
mark="○ stopped"
|
|
157
161
|
fi
|
|
158
|
-
if
|
|
159
|
-
app="$
|
|
162
|
+
if app_responds "$port"; then
|
|
163
|
+
app="$APP_RESPONDS"
|
|
160
164
|
else
|
|
161
|
-
app="$
|
|
165
|
+
app="$APP_NONE"
|
|
162
166
|
fi
|
|
163
|
-
printf ' %-5s %s %s\n' "$port" "$
|
|
167
|
+
printf ' %-5s %s %s\n' "$port" "$mark" "$app"
|
|
164
168
|
done
|
|
165
|
-
bash "$
|
|
169
|
+
bash "$HERE/ports-auto.sh" list_auto 2>/dev/null || true
|
|
166
170
|
}
|
|
167
171
|
|
|
168
|
-
|
|
169
|
-
local ports port
|
|
170
|
-
ports="$(
|
|
172
|
+
summary() {
|
|
173
|
+
local ports port output=""
|
|
174
|
+
ports="$(sort_ports "$(read_ports)")"
|
|
171
175
|
if [ -z "$ports" ]; then
|
|
172
176
|
echo "none (devzone port <n>)"
|
|
173
177
|
return 0
|
|
174
178
|
fi
|
|
175
|
-
# shellcheck disable=SC2046 #
|
|
179
|
+
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
176
180
|
for port in $(printf '%s' "$ports" | tr ',' ' '); do
|
|
177
|
-
if
|
|
178
|
-
|
|
181
|
+
if relay_active "$port"; then
|
|
182
|
+
output="$output${output:+, }$port ●"
|
|
179
183
|
else
|
|
180
|
-
|
|
184
|
+
output="$output${output:+, }$port ○"
|
|
181
185
|
fi
|
|
182
186
|
done
|
|
183
|
-
echo "$
|
|
187
|
+
echo "$output"
|
|
184
188
|
}
|
|
185
189
|
|
|
186
|
-
|
|
190
|
+
restart_relays() {
|
|
187
191
|
local ports port rc=0
|
|
188
|
-
ports="$(
|
|
192
|
+
ports="$(sort_ports "$(read_ports)")"
|
|
189
193
|
[ -n "$ports" ] || return 0
|
|
190
|
-
if !
|
|
191
|
-
echo "devzone : port :
|
|
194
|
+
if ! network_ip; then
|
|
195
|
+
echo "devzone : port : relays not restarted: devzone container not found (host Docker unreachable?)" >&2
|
|
192
196
|
return 1
|
|
193
197
|
fi
|
|
194
|
-
# shellcheck disable=SC2046 #
|
|
198
|
+
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
195
199
|
for port in $(printf '%s' "$ports" | tr ',' ' '); do
|
|
196
|
-
if !
|
|
197
|
-
echo "devzone : port : port
|
|
200
|
+
if ! port_valid "$port"; then
|
|
201
|
+
echo "devzone : port : invalid port in the state, ignored: $port" >&2
|
|
198
202
|
rc=1
|
|
199
203
|
continue
|
|
200
204
|
fi
|
|
201
|
-
#
|
|
202
|
-
docker rm -f "$(
|
|
203
|
-
|
|
205
|
+
# The container IP changes at each start: the relay is recreated
|
|
206
|
+
docker rm -f "$(relay_name "$port")" >/dev/null 2>&1 || true
|
|
207
|
+
launch "$port" "$NETWORK" "$IP" || rc=1
|
|
204
208
|
done
|
|
205
209
|
return "$rc"
|
|
206
210
|
}
|
|
207
211
|
|
|
208
|
-
#
|
|
212
|
+
# Machine-readable output of list: a JSON array [{port,active,application,auto}], jq only.
|
|
209
213
|
# shellcheck source=SCRIPTDIR/ports-json.sh
|
|
210
214
|
# shellcheck disable=SC1091
|
|
211
|
-
. "$
|
|
215
|
+
. "$HERE/ports-json.sh"
|
|
212
216
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
213
217
|
case "${1:-}" in
|
|
214
218
|
'' | list)
|
|
215
|
-
if [ "${2:-}" = "--json" ]; then
|
|
219
|
+
if [ "${2:-}" = "--json" ]; then list_json; else list_ports; fi
|
|
216
220
|
;;
|
|
217
|
-
open)
|
|
218
|
-
close | --close)
|
|
219
|
-
restart)
|
|
220
|
-
resume)
|
|
221
|
-
auto) bash "$
|
|
222
|
-
exclude) bash "$
|
|
223
|
-
include) bash "$
|
|
221
|
+
open) open_port "${2:-}" ;;
|
|
222
|
+
close | --close) close_port "${2:-}" ;;
|
|
223
|
+
restart) restart_relays ;;
|
|
224
|
+
resume) summary ;;
|
|
225
|
+
auto) bash "$HERE/ports-auto.sh" auto "${2:-}" "${3:-}" ;;
|
|
226
|
+
exclude) bash "$HERE/ports-auto.sh" exclude "${2:-}" ;;
|
|
227
|
+
include) bash "$HERE/ports-auto.sh" include "${2:-}" ;;
|
|
224
228
|
-h | --help | aide) sed -n '2,8p' "$0" | sed 's/^# \{0,1\}//' ;;
|
|
225
|
-
*)
|
|
229
|
+
*) open_port "$1" ;;
|
|
226
230
|
esac
|
|
227
231
|
fi
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# - volumes
|
|
4
|
-
# - npm
|
|
2
|
+
# Steps that cannot be in the image (Dockerfile):
|
|
3
|
+
# - volumes mounted at startup only
|
|
4
|
+
# - npm provided by the node feature, added after the Dockerfile
|
|
5
5
|
set -euo pipefail
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
6
|
+
# Never a question: the devcontainer CLI runs this step under a terminal, output
|
|
7
|
+
# sent to .devzone.log by make, so invisible; a question (repowarden install
|
|
8
|
+
# proposes « repowarden bots » in a GitHub repository whose gh is administrator)
|
|
9
|
+
# would wait forever. Empty input: each tool switches to non-interactive mode
|
|
10
|
+
# (bots: « later, repowarden bots »)
|
|
11
11
|
exec </dev/null
|
|
12
12
|
|
|
13
|
-
#
|
|
14
|
-
# (
|
|
13
|
+
# Named volumes created as root → give back to the vscode user
|
|
14
|
+
# (and ~/.config, created by Docker to mount ~/.config/opencode)
|
|
15
15
|
sudo chown -R vscode:vscode /home/vscode/.m2 /home/vscode/.gradle /home/vscode/.local /home/vscode/.claude \
|
|
16
16
|
/home/vscode/.config/opencode /home/vscode/.config/gh /home/vscode/.config/git \
|
|
17
17
|
/home/vscode/.config/devzone /home/vscode/.local/state/oc-lancer
|
|
18
18
|
sudo chown vscode:vscode /home/vscode/.config
|
|
19
19
|
|
|
20
|
-
# Git
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
20
|
+
# Git: the container's repositories declared safe (their owner may differ from
|
|
21
|
+
# the user running git: volumes, Docker Desktop, tools run separately), and
|
|
22
|
+
# GitHub access by the gh token, kept in its volume (https, even for the
|
|
23
|
+
# git@github.com: remotes, without an ssh key to copy)
|
|
24
|
+
# Machine settings in the container's ~/.gitconfig (recreated at each rebuild):
|
|
25
|
+
# without this file, git config --global (and repowarden install) would write
|
|
26
|
+
# into ~/.config/git/config, the identity volume, where they would pile up from
|
|
27
|
+
# one rebuild to the next
|
|
28
28
|
touch "$HOME/.gitconfig"
|
|
29
|
-
# Volume
|
|
30
|
-
#
|
|
29
|
+
# Volume touched by a previous version: only these settings are removed from it,
|
|
30
|
+
# the identity and any other setting are kept
|
|
31
31
|
volume="$HOME/.config/git/config"
|
|
32
32
|
if [ -f "$volume" ]; then
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
remove() { git config --file "$volume" --unset-all "$@" 2>/dev/null || true; }
|
|
34
|
+
remove safe.directory '^/workspaces/devzone'
|
|
35
|
+
remove credential.https://github.com.helper
|
|
36
|
+
remove url.https://github.com/.insteadOf
|
|
37
|
+
remove core.hooksPath 'repowarden'
|
|
38
|
+
remove alias.cc 'repowarden'
|
|
39
|
+
remove repowarden.lang
|
|
40
40
|
fi
|
|
41
41
|
git config --global --add safe.directory /workspaces/devzone
|
|
42
42
|
git config --global --add safe.directory '/workspaces/devzone/workspace/*'
|
|
@@ -46,44 +46,44 @@ git config --global url.https://github.com/.insteadOf git@github.com:
|
|
|
46
46
|
|
|
47
47
|
# repowarden, pinned version (it installs global git hooks); update
|
|
48
48
|
# .devcontainer/versions.env, then Rebuild Container
|
|
49
|
-
echo "devzone :
|
|
49
|
+
echo "devzone : installing repowarden…"
|
|
50
50
|
# shellcheck source=SCRIPTDIR/versions.env
|
|
51
51
|
. "$(dirname "${BASH_SOURCE[0]}")/versions.env"
|
|
52
52
|
npm install -g "repowarden@$REPOWARDEN_VERSION"
|
|
53
53
|
repowarden install --global --lang fr
|
|
54
54
|
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
55
|
+
# Optional modules (AI assistants, Kubernetes): devzone command, state kept in
|
|
56
|
+
# the instance folder ($RACINE/.devzone.modules); installs what is enabled. A
|
|
57
|
+
# failing module does not stop the creation: the container stays usable and the
|
|
58
|
+
# state (devzone, at each startup) shows it as « in failure »
|
|
59
59
|
sudo ln -sf /workspaces/devzone/.devcontainer/devzone /usr/local/bin/devzone
|
|
60
|
-
#
|
|
61
|
-
# (#370)
|
|
62
|
-
bash /workspaces/devzone/.devcontainer/kube-config.sh || echo "devzone : configuration
|
|
63
|
-
|
|
64
|
-
#
|
|
65
|
-
|
|
66
|
-
sudo install -m 0755 /workspaces/devzone/.devcontainer/docker-without-host.sh /usr/local/bin/docker
|
|
67
|
-
fi
|
|
68
|
-
devzone apply || echo "devzone : modules incomplets (détail ci-dessus), réessayer : devzone apply" >&2
|
|
69
|
-
# Paquets systeme gardes (#351) : reinstallees a chaque creation ; un echec n arrete pas la creation
|
|
70
|
-
devzone packages apply || echo "devzone : paquets en echec, reessayer : devzone packages" >&2
|
|
60
|
+
# Access to the workstation cluster (hote.config) before the modules that depend
|
|
61
|
+
# on it (#370); a failure does not stop the creation, the startup runs it again
|
|
62
|
+
bash /workspaces/devzone/.devcontainer/kube-config.sh || echo "devzone : kube configuration incomplete, retry: devzone start" >&2
|
|
63
|
+
devzone apply || echo "devzone : modules incomplete (details above), retry: devzone apply" >&2
|
|
64
|
+
# Guarded system packages (#351): reinstalled at each creation; a failure does not stop the creation
|
|
65
|
+
devzone packages apply || echo "devzone : packages failed, retry: devzone packages" >&2
|
|
71
66
|
|
|
72
|
-
#
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
# Kubernetes prompt of the shell (#337): prefixes PS1, only once. The check also
|
|
68
|
+
# accepts the block written before the rename to kube-prompt.sh (invite-kube.sh)
|
|
69
|
+
if grep -qE 'invite-kube\.sh|devzone_invite_kube' "$HOME/.bashrc" 2>/dev/null; then
|
|
70
|
+
sed -i -e 's#/\.devcontainer/invite-kube\.sh#/.devcontainer/kube-prompt.sh#' \
|
|
71
|
+
-e 's#devzone_invite_kube#devzone_kube_prompt#' "$HOME/.bashrc"
|
|
72
|
+
fi
|
|
73
|
+
if ! grep -qE 'kube-prompt.sh|invite-kube.sh' "$HOME/.bashrc" 2>/dev/null; then
|
|
74
|
+
cat >>"$HOME/.bashrc" <<'PROMPT'
|
|
75
75
|
# >>> devzone invite >>>
|
|
76
76
|
# shellcheck source=/dev/null
|
|
77
|
-
. /workspaces/devzone/.devcontainer/
|
|
78
|
-
PS1='$(
|
|
77
|
+
. /workspaces/devzone/.devcontainer/kube-prompt.sh
|
|
78
|
+
PS1='$(devzone_kube_prompt) '"$PS1"
|
|
79
79
|
# <<< devzone invite <<<
|
|
80
|
-
|
|
80
|
+
PROMPT
|
|
81
81
|
fi
|
|
82
82
|
|
|
83
|
-
#
|
|
84
|
-
#
|
|
83
|
+
# What remains to be done (git identity, GitHub, modules): devzone summary,
|
|
84
|
+
# displayed at each startup (startup.sh)
|
|
85
85
|
|
|
86
86
|
recap="java $(java -version 2>&1 | head -1 | cut -d'"' -f2), node $(node -v), python $(python3 --version | cut -d' ' -f2), repowarden $(repowarden --version)"
|
|
87
87
|
! command -v claude >/dev/null || recap+=", claude $(claude --version | cut -d' ' -f1)"
|
|
88
88
|
! command -v opencode >/dev/null || recap+=", opencode $(opencode --version)"
|
|
89
|
-
echo "devzone
|
|
89
|
+
echo "devzone up : $recap"
|