CI : Update agent from web
This commit is contained in:
@@ -185,12 +185,19 @@ if [ "$IS_UPGRADE" = true ]; then
|
||||
node -e '
|
||||
const fs = require("node:fs");
|
||||
const a = process.argv.slice(1);
|
||||
const [file, serverUrl, name, obsHost, obsPort, pwFlag, obsPassword, resetFlag, token] = a;
|
||||
const [file, serverUrl, name, obsHost, obsPort, pwFlag, obsPassword, resetFlag, token, packageUrl] = a;
|
||||
|
||||
const current = JSON.parse(fs.readFileSync(file, "utf8").replace(/^\uFEFF/, ""));
|
||||
const next = { ...current, obs: { ...(current.obs || {}) } };
|
||||
const applied = [];
|
||||
|
||||
// Toujours rafraichie : infrastructure et non identite. Sans elle, un agent
|
||||
// ne saurait pas ou chercher sa propre mise a jour.
|
||||
// (Pas d apostrophe dans ce bloc : il vit dans une chaine bash entre quotes.)
|
||||
if (packageUrl && packageUrl !== current.packageUrl) {
|
||||
next.packageUrl = packageUrl;
|
||||
applied.push("packageUrl");
|
||||
}
|
||||
if (serverUrl) { next.serverUrl = serverUrl; applied.push("serverUrl"); }
|
||||
if (name) { next.name = name; applied.push("name"); }
|
||||
if (obsHost) { next.obs.host = obsHost; applied.push("obs.host"); }
|
||||
@@ -210,7 +217,7 @@ console.log(applied.length
|
||||
? " champs mis à jour : " + applied.join(", ")
|
||||
: " aucun changement demandé");
|
||||
' "$CONFIG_FILE" "$SERVER_URL" "$AGENT_NAME" "$OBS_HOST" "$OBS_PORT" \
|
||||
"$PW_FLAG" "$OBS_PASSWORD" "$RESET_FLAG" "$TOKEN" \
|
||||
"$PW_FLAG" "$OBS_PASSWORD" "$RESET_FLAG" "$TOKEN" "$URL" \
|
||||
|| die "Fusion de la configuration existante impossible ($CONFIG_FILE)."
|
||||
|
||||
info "Configuration mise à jour, identité de l'agent préservée"
|
||||
@@ -221,6 +228,7 @@ else
|
||||
"serverUrl": "$SERVER_URL",
|
||||
"token": "$TOKEN",
|
||||
"name": "$AGENT_NAME",
|
||||
"packageUrl": "$URL",
|
||||
"obs": {
|
||||
"host": "$OBS_HOST",
|
||||
"port": $OBS_PORT,
|
||||
|
||||
Reference in New Issue
Block a user