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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
2
|
+
# Kubernetes prompt of the shell (#337): ⎈ ctx/ns.
|
|
3
3
|
|
|
4
|
-
#
|
|
5
|
-
|
|
4
|
+
# Renders the Kubernetes prompt (⎈ ctx/ns), with a cache keyed on the mtime.
|
|
5
|
+
devzone_kube_prompt() {
|
|
6
6
|
local kubeconfig="${KUBECONFIG:-$HOME/.kube/config:$HOME/.kube/hote.config}"
|
|
7
7
|
local files=() f sig="" cache mtime ctx ns result ici
|
|
8
8
|
ici="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
@@ -16,7 +16,7 @@ devzone_invite_kube() {
|
|
|
16
16
|
fi
|
|
17
17
|
sig+="${f}:${mtime};"
|
|
18
18
|
done
|
|
19
|
-
cache="${XDG_CACHE_HOME:-$HOME/.cache}/devzone-
|
|
19
|
+
cache="${XDG_CACHE_HOME:-$HOME/.cache}/devzone-kube-prompt"
|
|
20
20
|
mkdir -p "$(dirname "$cache")"
|
|
21
21
|
if [ -f "$cache" ]; then
|
|
22
22
|
if [ "$(sed -n '1p' "$cache" 2>/dev/null)" = "$sig" ]; then
|
|
@@ -31,10 +31,10 @@ devzone_invite_kube() {
|
|
|
31
31
|
ns="$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"$ctx\")].context.namespace}" 2>/dev/null || true)"
|
|
32
32
|
[ -n "$ns" ] || ns=default
|
|
33
33
|
# shellcheck disable=SC1090,SC1091
|
|
34
|
-
if ( . "$ici/cluster.sh";
|
|
34
|
+
if ( . "$ici/cluster.sh"; cluster_is_local "$ctx" ) >/dev/null 2>&1; then
|
|
35
35
|
result="$(printf '\001\033[36m\002⎈ %s/%s\001\033[0m\002' "$ctx" "$ns")"
|
|
36
36
|
else
|
|
37
|
-
result="$(printf '\001\033[1;31m\002⎈ %s/%s
|
|
37
|
+
result="$(printf '\001\033[1;31m\002⎈ %s/%s remote\001\033[0m\002' "$ctx" "$ns")"
|
|
38
38
|
fi
|
|
39
39
|
fi
|
|
40
40
|
printf '%s\n%s\n' "$sig" "$result" >"$cache"
|
|
@@ -1,64 +1,64 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Clusters
|
|
3
|
-
#
|
|
4
|
-
# 127.0.0.1
|
|
5
|
-
# 1.
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
# 2.
|
|
11
|
-
#
|
|
12
|
-
# host.docker.internal
|
|
13
|
-
#
|
|
14
|
-
# kube-reachable.sh
|
|
15
|
-
#
|
|
2
|
+
# Clusters reachable from the container (#291). With the host's Docker, the API
|
|
3
|
+
# of a kind cluster listens on 127.0.0.1 OF THE WORKSTATION: inside the
|
|
4
|
+
# container, 127.0.0.1 is the container itself.
|
|
5
|
+
# 1. kind node found (container publishing this port): the devzone container
|
|
6
|
+
# joins the Docker network of the node and targets https://<node>:6443, the
|
|
7
|
+
# address kind provides for containers (kind get kubeconfig --internal);
|
|
8
|
+
# the node name is in the API certificate. Works under Linux as with Docker
|
|
9
|
+
# Desktop, without exposing anything on the workstation's network.
|
|
10
|
+
# 2. Otherwise: https://host.docker.internal:<port>, with the original name for
|
|
11
|
+
# the TLS check (--tls-server-name); enough with Docker Desktop, where
|
|
12
|
+
# host.docker.internal leads to the workstation's 127.0.0.1.
|
|
13
|
+
# Sourced library (cluster.sh, kind wrapper); run directly:
|
|
14
|
+
# kube-reachable.sh FILE
|
|
15
|
+
# kube_reachable_from_container FILE rewrites 127.0.0.1/localhost, idempotent
|
|
16
16
|
|
|
17
|
-
#
|
|
18
|
-
|
|
17
|
+
# kind control-plane node that publishes this port on the workstation (empty otherwise)
|
|
18
|
+
kube_kind_node() {
|
|
19
19
|
docker ps --filter "label=io.x-k8s.kind.role=control-plane" --filter "publish=$1" \
|
|
20
20
|
--format '{{.Names}}' 2>/dev/null | head -1
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
local
|
|
26
|
-
|
|
27
|
-
for
|
|
28
|
-
--format '{{range $
|
|
29
|
-
docker network connect "$
|
|
23
|
+
# The devzone container joins the node's network (idempotent: already a member = nothing)
|
|
24
|
+
kube_join_network() {
|
|
25
|
+
local node="$1" me network
|
|
26
|
+
me="$(hostname)"
|
|
27
|
+
for network in $(docker inspect "$node" \
|
|
28
|
+
--format '{{range $name, $v := .NetworkSettings.Networks}}{{$name}} {{end}}' 2>/dev/null); do
|
|
29
|
+
docker network connect "$network" "$me" >/dev/null 2>&1 || true
|
|
30
30
|
done
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
local
|
|
35
|
-
[ -n "$
|
|
33
|
+
kube_reachable_from_container() {
|
|
34
|
+
local file="${1:-}" name server host port node
|
|
35
|
+
[ -n "$file" ] || return 0
|
|
36
36
|
# Kubernetes workspace (#517): the pod reaches the API through the cluster service, no docker call
|
|
37
37
|
if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then return 0; fi
|
|
38
|
-
KUBECONFIG="$
|
|
38
|
+
KUBECONFIG="$file" kubectl config view \
|
|
39
39
|
-o jsonpath='{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}' 2>/dev/null |
|
|
40
|
-
while IFS=$'\t' read -r
|
|
41
|
-
case "$
|
|
40
|
+
while IFS=$'\t' read -r name server; do
|
|
41
|
+
case "$server" in
|
|
42
42
|
https://127.0.0.1:* | https://localhost:*) ;;
|
|
43
43
|
*) continue ;;
|
|
44
44
|
esac
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
port="${
|
|
48
|
-
|
|
49
|
-
if [ -n "$
|
|
50
|
-
|
|
51
|
-
KUBECONFIG="$
|
|
52
|
-
--server="https://${
|
|
45
|
+
host="${server#https://}"
|
|
46
|
+
host="${host%%:*}"
|
|
47
|
+
port="${server##*:}"
|
|
48
|
+
node="$(kube_kind_node "$port")"
|
|
49
|
+
if [ -n "$node" ]; then
|
|
50
|
+
kube_join_network "$node"
|
|
51
|
+
KUBECONFIG="$file" kubectl config set-cluster "$name" \
|
|
52
|
+
--server="https://${node}:6443" >/dev/null 2>&1 || true
|
|
53
53
|
else
|
|
54
|
-
KUBECONFIG="$
|
|
54
|
+
KUBECONFIG="$file" kubectl config set-cluster "$name" \
|
|
55
55
|
--server="https://host.docker.internal:${port}" \
|
|
56
|
-
--tls-server-name="$
|
|
56
|
+
--tls-server-name="$host" >/dev/null 2>&1 || true
|
|
57
57
|
fi
|
|
58
58
|
done
|
|
59
59
|
return 0
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
63
|
-
|
|
63
|
+
kube_reachable_from_container "${1:-}"
|
|
64
64
|
fi
|
package/.devcontainer/memory.sh
CHANGED
|
@@ -55,7 +55,7 @@ memory_cluster_ki() {
|
|
|
55
55
|
local output line providerID memory node total=0 max=0 n=0 all_kind=1
|
|
56
56
|
MEMORY_KI=""
|
|
57
57
|
MEMORY_RULE=""
|
|
58
|
-
output="$(
|
|
58
|
+
output="$(account_admin "$(account_context)" get nodes \
|
|
59
59
|
-o jsonpath='{range .items[*]}{.spec.providerID}{"|"}{.status.allocatable.memory}{"\n"}{end}' 2>/dev/null)" || return 1
|
|
60
60
|
[ -n "$output" ] || return 1
|
|
61
61
|
while IFS= read -r line; do
|
|
@@ -27,7 +27,7 @@ if [ "${1:-}" = retirer ]; then
|
|
|
27
27
|
# Local clusters only: removal on a remote cluster has nothing to remove
|
|
28
28
|
# (devzone never installs there)
|
|
29
29
|
mapfile -t contexts < <(printf '%s\n' ${known[@]+"${known[@]}"} |
|
|
30
|
-
while IFS= read -r c; do
|
|
30
|
+
while IFS= read -r c; do cluster_is_local "$c" && echo "$c"; done || true)
|
|
31
31
|
set -- ${contexts[@]+"${contexts[@]}"}
|
|
32
32
|
fi
|
|
33
33
|
code=0
|
|
@@ -56,7 +56,7 @@ if [ "$requested" -eq 0 ]; then
|
|
|
56
56
|
# Local clusters only: never an automatic installation on a remote cluster
|
|
57
57
|
# of the host (prod, staging…); for another one, name it as an argument
|
|
58
58
|
mapfile -t contexts < <(printf '%s\n' ${known[@]+"${known[@]}"} |
|
|
59
|
-
while IFS= read -r c; do
|
|
59
|
+
while IFS= read -r c; do cluster_is_local "$c" && echo "$c"; done || true)
|
|
60
60
|
set -- ${contexts[@]+"${contexts[@]}"}
|
|
61
61
|
fi
|
|
62
62
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// devzone :
|
|
1
|
+
// devzone : default opencode configuration (devzone enable ia keeps it up to date; remove this line to customise it)
|
|
2
2
|
{
|
|
3
3
|
"$schema": "https://opencode.ai/config.json",
|
|
4
4
|
// Modèles gratuits de la version d'opencode fixée par devzone.
|
|
5
|
-
//
|
|
5
|
+
// Sharing and updates disabled: versions are pinned by devzone.
|
|
6
6
|
"model": "opencode/big-pickle",
|
|
7
7
|
"small_model": "opencode/mimo-v2.6-flash-free",
|
|
8
8
|
"share": "disabled",
|
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
# packages.sh
|
|
8
|
-
# packages.sh
|
|
9
|
-
# packages.sh
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
# apt-cache, dpkg-query, marque, horodatage). Compatible bash 3.2 (macOS).
|
|
2
|
+
# System packages kept after a rebuild (#351): a list in the devzone folder
|
|
3
|
+
# (<root>/.devzone.packages, a comment header + one package name per line, sorted,
|
|
4
|
+
# without duplicates), reinstalled at each container creation (post-create.sh).
|
|
5
|
+
# A package installed by hand is lost by a rebuild, unless it is in this list.
|
|
6
|
+
# packages.sh or packages.sh list list with the state of each package
|
|
7
|
+
# packages.sh add <name>… validates, installs, adds to the list
|
|
8
|
+
# packages.sh remove <name>… removes from the list and uninstalls (except image packages)
|
|
9
|
+
# packages.sh apply installs everything missing (post-create.sh)
|
|
10
|
+
# The state of a package comes from dpkg-query -W -f='${Status}'; the system
|
|
11
|
+
# commands go through overridable variables for the tests (sudo, apt-get,
|
|
12
|
+
# apt-cache, dpkg-query, mark, timestamp). Compatible with bash 3.2 (macOS).
|
|
14
13
|
set -euo pipefail
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
SUDO="${
|
|
22
|
-
APT="${
|
|
23
|
-
APTCACHE="${
|
|
24
|
-
DPKGQUERY="${
|
|
15
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
16
|
+
ROOT="${DEVZONE_ROOT:-$(dirname "$HERE")}"
|
|
17
|
+
LIST="${ROOT}/.devzone.packages"
|
|
18
|
+
MARK="${DEVZONE_PACKAGES_MARKER:-/tmp/devzone-packages.failed}"
|
|
19
|
+
UPDATED="${DEVZONE_PACKAGES_UPDATE:-/tmp/devzone-paquets.maj}"
|
|
20
|
+
SUDO="${DEVZONE_PACKAGES_SUDO-sudo}"
|
|
21
|
+
APT="${DEVZONE_PACKAGES_APT:-apt-get}"
|
|
22
|
+
APTCACHE="${DEVZONE_PACKAGES_APTCACHE:-apt-cache}"
|
|
23
|
+
DPKGQUERY="${DEVZONE_PACKAGES_DPKG_QUERY:-dpkg-query}"
|
|
25
24
|
FORMAT="-f=\${Status}"
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
# Stored values, kept byte for byte (the users' list file): the header and the
|
|
26
|
+
# « already present » mark are written in UTF-8 as byte escapes (contract).
|
|
27
|
+
HEADER=$'# paquets ajout\303\251s par devzone packages add ; r\303\251install\303\251s \303\240 chaque cr\303\251ation du conteneur'
|
|
28
|
+
PRESENT_MARK=$'# d\303\251j\303\240 pr\303\251sent'
|
|
28
29
|
|
|
29
30
|
|
|
30
|
-
refuse() { echo "devzone :
|
|
31
|
+
refuse() { echo "devzone : packages : $*" >&2; exit 1; }
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
as_root() {
|
|
33
34
|
if [ -n "$SUDO" ]; then
|
|
34
35
|
"$SUDO" "$@"
|
|
35
36
|
else
|
|
@@ -37,191 +38,191 @@ en_root() {
|
|
|
37
38
|
fi
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
is_installed() {
|
|
41
42
|
"$DPKGQUERY" -W "$FORMAT" "$1" 2>/dev/null | grep -q 'install ok installed'
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
#
|
|
45
|
-
|
|
46
|
-
[ -f "$
|
|
47
|
-
grep -vE '^[[:space:]]*(#|$)' "$
|
|
45
|
+
# List lines as they are (name, or name followed by the present mark).
|
|
46
|
+
list_lines() {
|
|
47
|
+
[ -f "$LIST" ] || return 0
|
|
48
|
+
grep -vE '^[[:space:]]*(#|$)' "$LIST" 2>/dev/null |
|
|
48
49
|
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' |
|
|
49
50
|
sort -k1,1 -u || true
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
# Names only: the end-of-line mark is ignored.
|
|
54
|
+
list_names() {
|
|
55
|
+
list_lines | sed -e 's/[[:space:]]*#.*$//' | sort -u || true
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
local
|
|
59
|
-
while IFS= read -r
|
|
60
|
-
[ "$
|
|
61
|
-
done < <(
|
|
58
|
+
name_listed() {
|
|
59
|
+
local name
|
|
60
|
+
while IFS= read -r name; do
|
|
61
|
+
[ "$name" = "$1" ] && return 0
|
|
62
|
+
done < <(list_names)
|
|
62
63
|
return 1
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
#
|
|
66
|
-
|
|
67
|
-
grep -qxF -e "$1 $
|
|
66
|
+
# True if the package was marked as already present in the image.
|
|
67
|
+
mark_present() {
|
|
68
|
+
grep -qxF -e "$1 $PRESENT_MARK" "$LIST" 2>/dev/null
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
#
|
|
71
|
-
|
|
71
|
+
# Rewrites the list: a single header, then the given lines (sorted by name).
|
|
72
|
+
write_list() {
|
|
72
73
|
local tmp
|
|
73
74
|
tmp="$(mktemp)"
|
|
74
75
|
{
|
|
75
|
-
echo "$
|
|
76
|
+
echo "$HEADER"
|
|
76
77
|
[ "$#" -eq 0 ] || printf '%s\n' "$@" | sort -k1,1 -u
|
|
77
78
|
} >"$tmp"
|
|
78
|
-
mv "$tmp" "$
|
|
79
|
+
mv "$tmp" "$LIST"
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
local
|
|
83
|
-
|
|
84
|
-
if [ -n "$
|
|
82
|
+
update_index() {
|
|
83
|
+
local last
|
|
84
|
+
last="$(cat "$UPDATED" 2>/dev/null || true)"
|
|
85
|
+
if [ -n "$last" ] && [ $(( $(date +%s) - last )) -lt 3600 ]; then
|
|
85
86
|
return 0
|
|
86
87
|
fi
|
|
87
|
-
|
|
88
|
-
date +%s >"$
|
|
88
|
+
as_root "$APT" update || return 1
|
|
89
|
+
date +%s >"$UPDATED"
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
local
|
|
93
|
-
|
|
94
|
-
if [ -z "$
|
|
95
|
-
echo "
|
|
92
|
+
list_packages() {
|
|
93
|
+
local packages package
|
|
94
|
+
packages="$(list_names)"
|
|
95
|
+
if [ -z "$packages" ]; then
|
|
96
|
+
echo "no package (devzone packages add <name>)"
|
|
96
97
|
return 0
|
|
97
98
|
fi
|
|
98
|
-
while IFS= read -r
|
|
99
|
-
[ -n "$
|
|
100
|
-
if
|
|
101
|
-
echo " ✔ $
|
|
99
|
+
while IFS= read -r package; do
|
|
100
|
+
[ -n "$package" ] || continue
|
|
101
|
+
if is_installed "$package"; then
|
|
102
|
+
echo " ✔ $package"
|
|
102
103
|
else
|
|
103
|
-
echo " ○ $
|
|
104
|
+
echo " ○ $package"
|
|
104
105
|
fi
|
|
105
|
-
done < <(printf '%s\n' "$
|
|
106
|
+
done < <(printf '%s\n' "$packages")
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
add_packages() {
|
|
109
110
|
local -a a=()
|
|
110
|
-
local -a
|
|
111
|
-
local arg
|
|
111
|
+
local -a entries=()
|
|
112
|
+
local arg name line already=""
|
|
112
113
|
for arg in "$@"; do
|
|
113
114
|
case "$arg" in
|
|
114
|
-
-*) refuse "argument
|
|
115
|
+
-*) refuse "unknown argument: $arg (devzone packages add <name>…)" ;;
|
|
115
116
|
*) a+=("$arg") ;;
|
|
116
117
|
esac
|
|
117
118
|
done
|
|
118
|
-
[ "${#a[@]}" -gt 0 ] || refuse "
|
|
119
|
-
|
|
120
|
-
for
|
|
121
|
-
if ! "$APTCACHE" show "$
|
|
122
|
-
refuse "
|
|
119
|
+
[ "${#a[@]}" -gt 0 ] || refuse "add expects at least one name: devzone packages add <name>…"
|
|
120
|
+
update_index || echo "apt index not updated" >&2
|
|
121
|
+
for name in "${a[@]}"; do
|
|
122
|
+
if ! "$APTCACHE" show "$name" >/dev/null 2>&1; then
|
|
123
|
+
refuse "unknown package: $name (list unchanged)"
|
|
123
124
|
fi
|
|
124
125
|
done
|
|
125
|
-
#
|
|
126
|
-
for
|
|
127
|
-
if
|
|
128
|
-
|
|
126
|
+
# What is already installed before the installation comes from the image: marked
|
|
127
|
+
for name in "${a[@]}"; do
|
|
128
|
+
if is_installed "$name"; then
|
|
129
|
+
already="$already $name"
|
|
129
130
|
fi
|
|
130
131
|
done
|
|
131
|
-
if
|
|
132
|
-
while IFS= read -r
|
|
133
|
-
|
|
134
|
-
done < <(
|
|
135
|
-
for
|
|
136
|
-
if
|
|
132
|
+
if as_root DEBIAN_FRONTEND=noninteractive "$APT" install -y --no-install-recommends "${a[@]}"; then
|
|
133
|
+
while IFS= read -r line; do
|
|
134
|
+
entries+=("$line")
|
|
135
|
+
done < <(list_lines)
|
|
136
|
+
for name in "${a[@]}"; do
|
|
137
|
+
if name_listed "$name"; then
|
|
137
138
|
continue
|
|
138
139
|
fi
|
|
139
|
-
case " $
|
|
140
|
-
*" $
|
|
141
|
-
|
|
142
|
-
echo "$
|
|
140
|
+
case " $already " in
|
|
141
|
+
*" $name "*)
|
|
142
|
+
entries+=("$name $PRESENT_MARK")
|
|
143
|
+
echo "$name : already present before devzone packages (marked ; removing will leave it installed)"
|
|
143
144
|
;;
|
|
144
|
-
*)
|
|
145
|
+
*) entries+=("$name") ;;
|
|
145
146
|
esac
|
|
146
147
|
done
|
|
147
|
-
|
|
148
|
+
write_list "${entries[@]}"
|
|
148
149
|
else
|
|
149
|
-
refuse "installation
|
|
150
|
+
refuse "installation failed: ${a[*]} (list unchanged)"
|
|
150
151
|
fi
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
|
|
154
|
+
remove_packages() {
|
|
154
155
|
local -a a=()
|
|
155
|
-
local -a
|
|
156
|
-
local -a
|
|
157
|
-
local arg
|
|
156
|
+
local -a removals=()
|
|
157
|
+
local -a remaining=()
|
|
158
|
+
local arg name line name_line
|
|
158
159
|
for arg in "$@"; do
|
|
159
160
|
case "$arg" in
|
|
160
|
-
-*) refuse "argument
|
|
161
|
+
-*) refuse "unknown argument: $arg (devzone packages remove <name>…)" ;;
|
|
161
162
|
*) a+=("$arg") ;;
|
|
162
163
|
esac
|
|
163
164
|
done
|
|
164
|
-
[ "${#a[@]}" -gt 0 ] || refuse "
|
|
165
|
-
for
|
|
166
|
-
|
|
167
|
-
refuse "
|
|
168
|
-
if !
|
|
169
|
-
|
|
165
|
+
[ "${#a[@]}" -gt 0 ] || refuse "remove expects at least one name: devzone packages remove <name>…"
|
|
166
|
+
for name in "${a[@]}"; do
|
|
167
|
+
name_listed "$name" ||
|
|
168
|
+
refuse "package not listed: $name (provided by the image?) : devzone packages remove does not add image packages"
|
|
169
|
+
if ! mark_present "$name"; then
|
|
170
|
+
removals+=("$name")
|
|
170
171
|
fi
|
|
171
172
|
done
|
|
172
|
-
if [ "${#
|
|
173
|
-
refuse "
|
|
173
|
+
if [ "${#removals[@]}" -gt 0 ] && ! as_root "$APT" remove -y "${removals[@]}"; then
|
|
174
|
+
refuse "removal failed: ${removals[*]} (list unchanged)"
|
|
174
175
|
fi
|
|
175
|
-
for
|
|
176
|
-
if
|
|
177
|
-
echo "$
|
|
176
|
+
for name in "${a[@]}"; do
|
|
177
|
+
if mark_present "$name"; then
|
|
178
|
+
echo "$name : removed from the list, left installed (present before devzone packages)"
|
|
178
179
|
fi
|
|
179
180
|
done
|
|
180
|
-
while IFS= read -r
|
|
181
|
-
|
|
181
|
+
while IFS= read -r line; do
|
|
182
|
+
name_line="${line%% *}"
|
|
182
183
|
case " ${a[*]} " in
|
|
183
|
-
*" $
|
|
184
|
-
*)
|
|
184
|
+
*" $name_line "*) ;;
|
|
185
|
+
*) remaining+=("$line") ;;
|
|
185
186
|
esac
|
|
186
|
-
done < <(
|
|
187
|
-
|
|
187
|
+
done < <(list_lines)
|
|
188
|
+
write_list "${remaining[@]+"${remaining[@]}"}"
|
|
188
189
|
}
|
|
189
190
|
|
|
190
|
-
|
|
191
|
-
local
|
|
192
|
-
local -a
|
|
193
|
-
while IFS= read -r
|
|
194
|
-
[ -n "$
|
|
195
|
-
if !
|
|
196
|
-
|
|
191
|
+
apply_packages() {
|
|
192
|
+
local package
|
|
193
|
+
local -a missing=()
|
|
194
|
+
while IFS= read -r package; do
|
|
195
|
+
[ -n "$package" ] || continue
|
|
196
|
+
if ! is_installed "$package"; then
|
|
197
|
+
missing+=("$package")
|
|
197
198
|
fi
|
|
198
|
-
done < <(printf '%s\n' "$(
|
|
199
|
-
if [ "${#
|
|
200
|
-
rm -f "$
|
|
199
|
+
done < <(printf '%s\n' "$(list_names)")
|
|
200
|
+
if [ "${#missing[@]}" -eq 0 ]; then
|
|
201
|
+
rm -f "$MARK"
|
|
201
202
|
return 0
|
|
202
203
|
fi
|
|
203
|
-
|
|
204
|
-
for
|
|
205
|
-
|
|
204
|
+
update_index || echo "apt index not updated" >&2
|
|
205
|
+
for package in "${missing[@]}"; do
|
|
206
|
+
as_root DEBIAN_FRONTEND=noninteractive "$APT" install -y --no-install-recommends "$package" || true
|
|
206
207
|
done
|
|
207
|
-
local -a
|
|
208
|
-
for
|
|
209
|
-
if !
|
|
210
|
-
|
|
208
|
+
local -a still_missing=()
|
|
209
|
+
for package in "${missing[@]}"; do
|
|
210
|
+
if ! is_installed "$package"; then
|
|
211
|
+
still_missing+=("$package")
|
|
211
212
|
fi
|
|
212
213
|
done
|
|
213
|
-
if [ "${#
|
|
214
|
-
printf '%s\n' "${
|
|
214
|
+
if [ "${#still_missing[@]}" -gt 0 ]; then
|
|
215
|
+
printf '%s\n' "${still_missing[@]}" >"$MARK"
|
|
215
216
|
return 1
|
|
216
217
|
fi
|
|
217
|
-
rm -f "$
|
|
218
|
+
rm -f "$MARK"
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
case "${1:-}" in
|
|
221
|
-
'' | list)
|
|
222
|
-
add)
|
|
223
|
-
remove)
|
|
224
|
-
apply)
|
|
222
|
+
'' | list) list_packages ;;
|
|
223
|
+
add) add_packages "${@:2}" ;;
|
|
224
|
+
remove) remove_packages "${@:2}" ;;
|
|
225
|
+
apply) apply_packages ;;
|
|
225
226
|
-h | --help | aide) awk 'NR==1{next} /^#$/{exit} /^#/{sub(/^# ?/,""); print; next} {exit}' "${BASH_SOURCE[0]}" ;;
|
|
226
|
-
*) refuse "
|
|
227
|
+
*) refuse "unknown command: ${1:-(none)} (devzone packages --help)" ;;
|
|
227
228
|
esac
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
set -euo pipefail
|
|
9
9
|
|
|
10
10
|
PASSWORD_HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
11
|
-
PASSWORD_ROOT="${
|
|
11
|
+
PASSWORD_ROOT="${DEVZONE_ROOT:-$(dirname "$PASSWORD_HERE")}"
|
|
12
12
|
PASSWORD_TARGET="$PASSWORD_ROOT/.password"
|
|
13
13
|
|
|
14
14
|
# Regenerates $ROOT/.password from workspace/.gitlab, workspace/.postgres,
|