add osx mpkg customized filename

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

si458 committed Mar 7, 2024 at 10:19 UTC 2d75bbde333f9dd51483727ede7aa55dfe94c681
1 file changed +7 -5
webserver.js
+7 -5
@@ -5846,9 +5846,11 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
5846 // Customize the mesh agent file name
5847 var meshfilename = 'MeshAgent-' + mesh.name + '.zip';
5848 var meshexecutablename = 'meshagent';
5849 + var meshmpkgname = 'MeshAgent.mpkg';
5850 if ((domain.agentcustomization != null) && (typeof domain.agentcustomization.filename == 'string')) {
5851 meshfilename = meshfilename.split('MeshAgent').join(domain.agentcustomization.filename);
5852 meshexecutablename = meshexecutablename.split('meshagent').join(domain.agentcustomization.filename);
5853 + meshmpkgname = meshmpkgname.split('MeshAgent').join(domain.agentcustomization.filename);
5854 }
5855
5856 // Customise the mesh agent display name
@@ -5891,7 +5893,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
5893 var meshname = mesh.name.split(']').join('').split('[').join(''); // We can't have ']]' in the string since it will terminate the CDATA.
5894 var welcomemsg = 'Welcome to the MeshCentral agent for MacOS\n\nThis installer will install the mesh agent for "' + meshname + '" and allow the administrator to remotely monitor and control this computer over the internet. For more information, go to https://meshcentral.com.\n\nThis software is provided under Apache 2.0 license.\n';
5895 var installsize = Math.floor((argentInfo.size + meshsettings.length) / 1024);
5894 - archive.append(readStream.xxdata.toString().split('###DISPLAYNAME###').join(meshdisplayname).split('###WELCOMEMSG###').join(welcomemsg).split('###INSTALLSIZE###').join(installsize), { name: entry.fileName });
5896 + archive.append(readStream.xxdata.toString().split('###DISPLAYNAME###').join(meshdisplayname).split('###WELCOMEMSG###').join(welcomemsg).split('###INSTALLSIZE###').join(installsize), { name: entry.fileName.replace('MeshAgent.mpkg',meshmpkgname) });
5897 zipfile.readEntry();
5898 });
5899 });
@@ -5905,7 +5907,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
5907 zipfile.openReadStream(entry, function (err, readStream) {
5908 readStream.on('data', function (data) { if (readStream.xxdata) { readStream.xxdata += data; } else { readStream.xxdata = data; } });
5909 readStream.on('end', function () {
5908 - var options = { name: entry.fileName };
5910 + var options = { name: entry.fileName.replace('MeshAgent.mpkg',meshmpkgname) };
5911 if (entry.fileName.endsWith('postflight') || entry.fileName.endsWith('Uninstall.command')) { options.mode = 493; }
5912 archive.append(readStream.xxdata.toString().split('###SERVICENAME###').join(meshservicename).split('###COMPANYNAME###').join(meshcompanyname).split('###EXECUTABLENAME###').join(meshexecutablename), options);
5913 zipfile.readEntry();
@@ -5916,7 +5918,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
5918 // Normal file entry
5919 zipfile.openReadStream(entry, function (err, readStream) {
5920 if (err) { throw err; }
5919 - var options = { name: entry.fileName };
5921 + var options = { name: entry.fileName.replace('MeshAgent.mpkg',meshmpkgname) };
5922 if (entry.fileName.endsWith('postflight') || entry.fileName.endsWith('Uninstall.command')) { options.mode = 493; }
5923 archive.append(readStream, options);
5924 readStream.on('end', function () { zipfile.readEntry(); });
@@ -5925,8 +5927,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
5927 }
5928 });
5929 zipfile.on('end', function () {
5928 - archive.file(argentInfo.path, { name: 'MeshAgent.mpkg/Contents/Packages/internal.pkg/Contents/meshagent_osx64.bin' });
5929 - archive.append(meshsettings, { name: 'MeshAgent.mpkg/Contents/Packages/internal.pkg/Contents/meshagent_osx64.msh' });
5930 + archive.file(argentInfo.path, { name: 'MeshAgent.mpkg/Contents/Packages/internal.pkg/Contents/meshagent_osx64.bin'.replace('MeshAgent.mpkg',meshmpkgname) });
5931 + archive.append(meshsettings, { name: 'MeshAgent.mpkg/Contents/Packages/internal.pkg/Contents/meshagent_osx64.msh'.replace('MeshAgent.mpkg',meshmpkgname) });
5932 archive.finalize();
5933 });
5934 });