From nobody Sun Jun 28 18:40:47 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gpJBm45nBz6jklR for ; Sun, 28 Jun 2026 18:40:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gpJBl6dQ3z3YJK for ; Sun, 28 Jun 2026 18:40:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782672047; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DIFjwp8fXHJMA6M7CwUwgKl7MNpTECIMRIeZwfuFOwA=; b=i9cXabHAxGHWtkyUOM/dK/BVeSZByrxlnd5NxabbjpLSwrG1+Nu9HKuhOxu1SggutGYE6z xdr2zTWS8GfiKLKtQNVbxgqBEpFWSB4lq6oD0iQDCRTZNDYPUzC7pQ5KpmDrYWafWjjtb2 UZ65s+0/zcjkgVD16nuuzsYyDQj35G8/hPFpUXDXWXzU6QM2IZwQw45I+GYDWWl06LCg08 iKj4KRW505U8YOu4MtewLhsl7wt1gHsylzDFn+ysqPejzqym0zJ+oRi1K3/xtru6t4stOx /BsaSXhvf7vWw12HLyP4MnxT7mp3HXX4yBUjG6t3uqhmua1oFXlDByag8hCssA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782672047; a=rsa-sha256; cv=none; b=C9U9BTEB5zQOhWMW1Jnf1WrYJ4Ynhb6VWXA2o4wWd/GiKv4oEf62SysQFUf6x2jmZxRzv7 ITiGLQqzxKQoFitC1AHMeUuQOLWm3QbPBg+U6sKG1fM8Bpty0lzpmxmJ5Q2wlBJayqj8w7 1ChEATc51SZrU4V+VvFYLEifN6Rxj44497bDpxlZNpqdWBsL49+LCAkbrJWLQeJmGQI/B1 93JKPuw+vvxhIBR7asUCFKEvczkOCsuk/q16VQfQ1rFt5EFjIG0xodwLuEuGCZOs3GSdwU 0soL+sjArB3wqnNa7695Xlm+X1R4COT9Jz9EIi+4x7pzsxQlkQFQPRhH5JEWCw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782672047; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DIFjwp8fXHJMA6M7CwUwgKl7MNpTECIMRIeZwfuFOwA=; b=mWLum7XDc/EW7eTZs63ncCmOWdUMfemwV/NIAjJhAMS+gRqzvlwkIupBE6qMzKj1npejeg vzCpVHvjCtafaj63OwLTl3s1vn2cWWWkWo5tCUJIoJee72+FoskMmi0zgmCePSlGVaRuUk ElF53Wj027ZvWN/iVbBgDABIX1kODifh+imYfXjlq6VJLiRuxrC9c4djAl0jI52xtlhqAJ BAmpU8TZFfRBb5vmLBYXkswgjTIyFWLMVJYLvIF6OdeLFel0HR5Ou/oVxL8zWpCsOnGx1V ga7s+PSyWcZnfKW6mdZOSqc+kLEj0Redk1qOB9psl4QjNZv4RwXgkA6M21R7ZA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gpJBl58RNz75s for ; Sun, 28 Jun 2026 18:40:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1a16b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 28 Jun 2026 18:40:47 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: 202ae0114a15 - stable/15 - nuageinit: implement power_state_change and locale support List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 202ae0114a15ef59990fc50cbd4b419e3f893658 Auto-Submitted: auto-generated Date: Sun, 28 Jun 2026 18:40:47 +0000 Message-Id: <6a416aaf.1a16b.2c6acf1c@gitrepo.freebsd.org> The branch stable/15 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=202ae0114a15ef59990fc50cbd4b419e3f893658 commit 202ae0114a15ef59990fc50cbd4b419e3f893658 Author: Baptiste Daroussin AuthorDate: 2026-06-05 20:48:18 +0000 Commit: Baptiste Daroussin CommitDate: 2026-06-28 18:32:28 +0000 nuageinit: implement power_state_change and locale support (cherry picked from commit 328a76d17f85ff6aa6228035c4c4b989eb7534f8) --- libexec/nuageinit/nuageinit | 61 ++++++++++++++++++++++++++++++++++++ libexec/nuageinit/nuageinit.7 | 49 +++++++++++++++++++++++++++++ libexec/nuageinit/tests/nuageinit.sh | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+) diff --git a/libexec/nuageinit/nuageinit b/libexec/nuageinit/nuageinit index bd72f02d4503..8a9c5c022862 100755 --- a/libexec/nuageinit/nuageinit +++ b/libexec/nuageinit/nuageinit @@ -637,6 +637,28 @@ local function keyboard(obj) f:close() end +local function locale(obj) + if obj.locale == nil then return end + local root = os.getenv("NUAGE_FAKE_ROOTDIR") + if not root then root = "" end + local profile_path = root .. "/etc/profile" + local f = io.open(profile_path, "a") + if not f then + nuage.warn("unable to open " .. profile_path .. " for writing") + return + end + if type(obj.locale) == "string" then + f:write("export LANG=" .. obj.locale .. "\n") + elseif type(obj.locale) == "table" then + for k, v in pairs(obj.locale) do + f:write("export " .. k .. "=" .. v .. "\n") + end + else + nuage.warn("locale: invalid type " .. type(obj.locale) .. ", expecting string or object") + end + f:close() +end + local function mounts(obj) if obj.mounts == nil then return end for _, m in ipairs(obj.mounts) do @@ -725,6 +747,43 @@ local function packages(obj) end end +local function power_state_change(obj) + if obj.power_state == nil then return end + local ps = obj.power_state + local delay = ps.delay or "now" + local mode = ps.mode or "poweroff" + local message = ps.message + local condition = ps.condition + if condition == nil then condition = true end + + -- Evaluate condition + if condition == false then return end + if type(condition) == "string" then + local ret = os.execute(condition) + if not ret then return end + end + + -- Map mode to shutdown flag + local mode_map = {poweroff = "p", reboot = "r", halt = "h"} + local flag = mode_map[mode] + if not flag then + nuage.warn("power_state: invalid mode '" .. mode .. "', using poweroff") + flag = "p" + end + + -- Build shutdown command + local cmd = "shutdown -" .. flag .. " " .. delay + if message then + cmd = cmd .. " " .. nuage.shell_escape(message) + end + + if os.getenv("NUAGE_RUN_TESTS") then + print(cmd) + return + end + os.execute(cmd) +end + local function chpasswd(obj) if obj.chpasswd == nil then return end nuage.chpasswd(obj.chpasswd) @@ -1018,6 +1077,7 @@ elseif line == "#cloud-config" then network_config, resolv_conf, keyboard, + locale, disable_root, ssh_pwauth, runcmd, @@ -1030,6 +1090,7 @@ elseif line == "#cloud-config" then users, chpasswd, write_files_deferred, + power_state_change, } local calls_table = pre_network_calls diff --git a/libexec/nuageinit/nuageinit.7 b/libexec/nuageinit/nuageinit.7 index b4be4e4b2d58..6d0f8ae2f41c 100644 --- a/libexec/nuageinit/nuageinit.7 +++ b/libexec/nuageinit/nuageinit.7 @@ -212,6 +212,16 @@ A list of IP/netmask sortlist entries. .It options A dictionary of resolver options. .El +.It Ic locale +Set the system locale by appending +.Qq Cm export +statements to +.Pa /etc/profile . +.Pp +If the value is a string, it is used as the +.Dq Cm LANG +value. +If the value is an object mapping, each key-value pair is exported. .It Ic keyboard An object configuring the keyboard layout. .Pp @@ -442,6 +452,45 @@ List of packages to be installed. Update the remote package metadata. .It Ic package_upgrade Upgrade the packages installed to their latest version. +.It Ic power_state +An object controlling the power state of the instance after configuration. +The following keys are recognized: +.Bl -tag -width "condition" +.It Ic delay +Time to wait before the action. +Can be +.Qq now +or a time accepted by +.Xr shutdown 8 +(e.g., +.Qq +5 +for five minutes). +Defaults to +.Qq now . +.It Ic mode +The action to take: +.Qq poweroff , +.Qq reboot , +or +.Qq halt . +Defaults to +.Qq poweroff . +.It Ic message +Optional message to display to users. +.It Ic timeout +Not supported on +.Fx , +silently ignored. +.It Ic condition +Boolean or command string. +If +.Qq false , +the action is skipped. +If a string, it is run as a command; the action is only taken if the command +succeeds. +Defaults to +.Qq true . +.El .It Ic users Specify a list of users to be created: .Bl -tag -width "ssh_authorized_keys" diff --git a/libexec/nuageinit/tests/nuageinit.sh b/libexec/nuageinit/tests/nuageinit.sh index 4b751dd2ca43..21cd2e8f17c5 100644 --- a/libexec/nuageinit/tests/nuageinit.sh +++ b/libexec/nuageinit/tests/nuageinit.sh @@ -41,6 +41,8 @@ atf_test_case config2_userdata_ssh_authkey_fingerprints atf_test_case config2_userdata_ntp atf_test_case config2_userdata_ca_certs atf_test_case config2_userdata_multipart +atf_test_case config2_userdata_power_state +atf_test_case config2_userdata_locale atf_test_case config2_userdata_fqdn_and_hostname atf_test_case config2_userdata_write_files @@ -1308,6 +1310,58 @@ EOF true } +config2_userdata_power_state_head() +{ + atf_set "require.user" root +} +config2_userdata_power_state_body() +{ + mkdir -p media/nuageinit + setup_test_adduser + export NUAGE_RUN_TESTS=1 + printf "{}" > media/nuageinit/meta_data.json + cat > media/nuageinit/user_data < media/nuageinit/meta_data.json + cat > media/nuageinit/user_data < media/nuageinit/user_data <