add customisable macosinstallerimage

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Jun 6, 2026 at 09:29 UTC 1ca6e7c20695e11a1abcdd72c4efdaeb7904610a
5 files changed +23 -3
agents/macosinstallerbackground.png
Binary files /dev/null and b/agents/macosinstallerbackground.png differ
macosinstaller.js
+9 -1
@@ -333,6 +333,13 @@ async function createMacOSInstaller(opts) {
333 await fsp.writeFile(path.join(launchAgents, opts.serviceName + '-launchagent.plist'), replaceTokens(LAUNCH_AGENT_PLIST, tokens));
334 await fsp.writeFile(path.join(scriptsRoot, 'postinstall'), replaceTokens(POSTINSTALL, tokens));
335
336 + if (opts.backgroundPath) {
337 + await fsp.copyFile(opts.backgroundPath, path.join(resourcesDir, 'background'));
338 + } else {
339 + const backgroundPath = path.join(__dirname, 'agents', 'macosinstallerbackground.png');
340 + await fsp.copyFile(backgroundPath, path.join(resourcesDir, 'background'));
341 + }
342 +
343 await chmodIfExists(path.join(installDir, opts.executableName), 0o755);
344 await chmodIfExists(path.join(scriptsRoot, 'postinstall'), 0o755);
345 await chmodIfExists(path.join(installDir, opts.executableName + '.msh'), 0o644);
@@ -357,7 +364,8 @@ async function createMacOSInstaller(opts) {
364 const distribution = '<?xml version="1.0" encoding="utf-8"?>\n'
365 + '<installer-script minSpecVersion="1.000000">\n'
366 + ' <title>' + xmlEscape(opts.displayName) + '</title>\n'
360 - + ' <options customize="never" allow-external-scripts="no" rootVolumeOnly="true"/>\n'
367 + + ' <options customize="always" allow-external-scripts="no" rootVolumeOnly="true"/>\n'
368 + + ' <background file="background" alignment="topleft" scaling="tofit"/>\n'
369 + ' <welcome language="en-US" mime-type="text/plain"><![CDATA[' + welcome.split(']]>').join(']]]]><![CDATA[>') + ']]></welcome>\n'
370 + ' <choices-outline>\n'
371 + ' <line choice="choice65"/>\n'
meshcentral-config-schema.json
+5
@@ -2235,6 +2235,11 @@
2235 "default": null,
2236 "description": "The filename of a image file in .png format located in meshcentral-data to display in the MeshCentral Agent installation dialog, image should be square and from 64x64 to 200x200."
2237 },
2238 + "macosinstallerimage": {
2239 + "type": "string",
2240 + "default": null,
2241 + "description": "The filename of a background image file in .png format located in meshcentral-data to display in the macOS installer."
2242 + },
2243 "fileName": {
2244 "type": "string",
2245 "default": "meshagent",
sample-config-advanced.json
+1
@@ -373,6 +373,7 @@
373 "companyName": "Company®",
374 "serviceName": "companyagent",
375 "image": "agent-logo.png",
376 + "macosinstallerimage": "macos-installer-background.png",
377 "fileName": "compagnyagent"
378 },
379 "_agentFileInfo": {
webserver.js
+8 -2
@@ -6697,7 +6697,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
6697 archive.pipe(res);
6698
6699 // Create a flat XAR macOS installer package. Bundle .mpkg installers are rejected by recent macOS versions.
6700 - require('./macosinstaller').createMacOSInstaller({
6700 + const macosInstallerOpts = {
6701 agentPath: argentInfo.path,
6702 meshSettings: meshsettings,
6703 meshName: mesh.name.split(']').join('').split('[').join(''), // We can't have ']]' in the string since it will terminate the CDATA.
@@ -6706,7 +6706,13 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
6706 displayName: meshdisplayname,
6707 serviceName: meshservicename,
6708 companyName: meshcompanyname
6709 - }).then(function (installer) {
6709 + };
6710 +
6711 + if ((domain.agentcustomization != null) && (typeof domain.agentcustomization.macosinstallerimage == 'string')) {
6712 + macosInstallerOpts.backgroundPath = parent.path.join(parent.datapath, domain.agentcustomization.macosinstallerimage);
6713 + }
6714 +
6715 + require('./macosinstaller').createMacOSInstaller(macosInstallerOpts).then(function (installer) {
6716 archive.append(installer.pkg, { name: meshpkgname });
6717 archive.append(installer.uninstall, { name: 'Uninstall.command', mode: 493 });
6718 archive.finalize();