From nobody Sat Jun 6 06:14:18 2026 X-Original-To: dev-commits-src-main@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 4gXSgZ5DB9z6g536 for ; Sat, 06 Jun 2026 06:14:18 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gXSgZ1V0kz3Sxm for ; Sat, 06 Jun 2026 06:14:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780726458; 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=Zim8Dcg2RC5Qhasa2gCd2U2PwWYyTj3Jj8CVQUaBIto=; b=wDMUxXXwfa5aa0MzQpn6Zgv/JQ/DEPrYcpoFnI7ML3FuKkCs/UEiInWRyCO9aZhjoq8kuf P2w1E35XRpwyczcaMBpd7d2WW/DfpAEWZw/VGN66yZwmtpO6TsyeuO91O40hjg6ek9XB1t j1uYsS07m2yKCXkcAgSIIHnkFiEVKbu35YeBH48uEHAJzSZD51gNmcZIOoLgoaFNwJo6jl 0RKyrBzUz9K5QecoMWYjsHRXPxH+/16CwrRB0go3m3IvRKPg7j4PqDYqD4nCv+g+Q/X7Ft MfbgCYamclZOrE0XXC7d3AgVbQ3pfuy5xL/chhQfaLmfwEEBJMPVKx/ZDmvxag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780726458; a=rsa-sha256; cv=none; b=yWRTDy1oA3L23AXOlIU4YEgWAoABHH9CZyKVd510ZFHCkIBrEyuH/j6j7ls6zfu9A+5w5H 6sheWSR3cDBOiQXVygoYt14xN9Br93BYsM1gUdJag0vj2/Sg//UGWwwU7nVTdC6wfhc/fO KB+vAJM9GG1Sfd9qCcLoUcR3/ovbQDwLl2nwoQ0Wuv6r3YOmIT4BrM/MVNxjufHJqXubj/ dn3CCqDbP11534yjKoqcUg+ey0HG3fNchCE9Nab69Q18eXkvvMqW30lgMMW/Y1Veo0AGBz K4G1O1Hit/JIGN7c3FaT/X3GXu1eNYyXD6wJQaZK+wOVS2PA2Sa9wcfmh5GBxw== 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=1780726458; 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=Zim8Dcg2RC5Qhasa2gCd2U2PwWYyTj3Jj8CVQUaBIto=; b=sL+2X6T1FUyQub5KJhwwAZxcz8J/D/XcqvJqOvh3t8dfeY/Q4QQyvkI1KygGR36q4FV7Sv G4cem5C4qRHjpp/G/9/Oe7WPqow8GJTgCbcYapg3Ep6mYIyRYRc9UobBfu3W0verivkZ63 vuygwE3wOn44Exmg1KXokTMyimHmeSRremoWNODg70qnpACuD6/t/5quEmeNpNfI09d9uw p94QMWOmHnfXaOE8KCR9/lmXliUgSykhLr6N6XTfcFYym/1QOvJHGS27Ak33XHF3QpqPZt sGaSXyy63WBHSFfKjzSSZb9DXP//ENtmbJiDlDfxbkgKuE+icAjWGw7+CPNqPg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gXSgZ0zHpz13jM for ; Sat, 06 Jun 2026 06:14:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2757f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 06 Jun 2026 06:14:18 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 328a76d17f85 - main - nuageinit: implement power_state_change and locale support List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 328a76d17f85ff6aa6228035c4c4b989eb7534f8 Auto-Submitted: auto-generated Date: Sat, 06 Jun 2026 06:14:18 +0000 Message-Id: <6a23baba.2757f.6cff3de7@gitrepo.freebsd.org> The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=328a76d17f85ff6aa6228035c4c4b989eb7534f8 commit 328a76d17f85ff6aa6228035c4c4b989eb7534f8 Author: Baptiste Daroussin AuthorDate: 2026-06-05 20:48:18 +0000 Commit: Baptiste Daroussin CommitDate: 2026-06-05 20:48:18 +0000 nuageinit: implement power_state_change and locale support --- 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 <