update macOS installer scripts for launch agent and daemon plist naming conventions

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

si458 committed Jun 6, 2026 at 07:17 UTC 77cbac4017bb7a8e465889e4db51bc156e434f20
1 file changed +29 -7
macosinstaller.js
+29 -7
@@ -35,7 +35,7 @@ const LAUNCH_DAEMON_PLIST = `<?xml version="1.0" encoding="UTF-8"?>
35 <key>KeepAlive</key>
36 <true/>
37 <key>ThrottleInterval</key>
38 - <integer>5</integer>
38 + <integer>1</integer>
39 </dict>
40 </plist>
41 `;
@@ -49,11 +49,12 @@ const LAUNCH_AGENT_PLIST = `<?xml version="1.0" encoding="UTF-8"?>
49 <key>ProgramArguments</key>
50 <array>
51 <string>/usr/local/mesh_services/###COMPANYNAME###/###SERVICENAME###/###EXECUTABLENAME###</string>
52 - <string>-kvm1</string>
52 + <string>-kvmagent</string>
53 </array>
54 <key>LimitLoadToSessionType</key>
55 <array>
56 <string>LoginWindow</string>
57 + <string>Aqua</string>
58 </array>
59 <key>WorkingDirectory</key>
60 <string>/usr/local/mesh_services/###COMPANYNAME###/###SERVICENAME###/</string>
@@ -75,29 +76,50 @@ INSTALLDIR="/usr/local/mesh_services/\${COMPANYNAME}/\${SERVICENAME}"
76
77 chown -R root:wheel "/usr/local/mesh_services/\${COMPANYNAME}" || true
78 chown root:wheel "\${INSTALLDIR}/\${EXECUTABLENAME}" "\${INSTALLDIR}/\${EXECUTABLENAME}.msh"
78 -chown root:wheel "/Library/LaunchDaemons/\${SERVICENAME}.plist" "/Library/LaunchAgents/\${SERVICENAME}.plist"
79 +chown root:wheel "/Library/LaunchDaemons/\${SERVICENAME}.plist" "/Library/LaunchAgents/\${SERVICENAME}-launchagent.plist"
80
81 chmod 755 "\${INSTALLDIR}" "\${INSTALLDIR}/\${EXECUTABLENAME}"
81 -chmod 644 "\${INSTALLDIR}/\${EXECUTABLENAME}.msh" "/Library/LaunchDaemons/\${SERVICENAME}.plist" "/Library/LaunchAgents/\${SERVICENAME}.plist"
82 +chmod 644 "\${INSTALLDIR}/\${EXECUTABLENAME}.msh" "/Library/LaunchDaemons/\${SERVICENAME}.plist" "/Library/LaunchAgents/\${SERVICENAME}-launchagent.plist"
83
84 /bin/launchctl bootout system "/Library/LaunchDaemons/\${SERVICENAME}.plist" >/dev/null 2>&1 || true
85 /bin/launchctl bootstrap system "/Library/LaunchDaemons/\${SERVICENAME}.plist" >/dev/null 2>&1 || /bin/launchctl load "/Library/LaunchDaemons/\${SERVICENAME}.plist"
86 +
87 +CONSOLE_USER=$(stat -f '%Su' /dev/console 2>/dev/null || true)
88 +CONSOLE_UID=$(id -u "\${CONSOLE_USER}" 2>/dev/null || true)
89 +if [ -n "\${CONSOLE_UID}" ] && [ "\${CONSOLE_UID}" != "0" ]; then
90 + /bin/launchctl bootout "gui/\${CONSOLE_UID}" "/Library/LaunchAgents/\${SERVICENAME}-launchagent.plist" >/dev/null 2>&1 || true
91 + /bin/launchctl bootstrap "gui/\${CONSOLE_UID}" "/Library/LaunchAgents/\${SERVICENAME}-launchagent.plist" >/dev/null 2>&1 || true
92 +fi
93 `;
94
95 const UNINSTALL = `#!/bin/bash
96
97 echo "Stopping ###SERVICENAME###..."
98 sudo /bin/launchctl bootout system "/Library/LaunchDaemons/###SERVICENAME###.plist" &> /dev/null || sudo /bin/launchctl unload "/Library/LaunchDaemons/###SERVICENAME###.plist" &> /dev/null
99 +sudo pkill -9 "###SERVICENAME###" &> /dev/null || true
100 +CONSOLE_USER=$(stat -f '%Su' /dev/console 2>/dev/null || true)
101 +CONSOLE_UID=$(id -u "\${CONSOLE_USER}" 2>/dev/null || true)
102 +if [ -n "\${CONSOLE_UID}" ] && [ "\${CONSOLE_UID}" != "0" ]; then
103 + sudo /bin/launchctl bootout "gui/\${CONSOLE_UID}" "/Library/LaunchAgents/###SERVICENAME###-launchagent.plist" &> /dev/null || true
104 +fi
105 sudo /bin/launchctl unload "/Library/LaunchDaemons/meshagentDiagnostic_periodicStart.plist" &> /dev/null
106 sudo /bin/launchctl unload "/Library/LaunchDaemons/meshagentDiagnostic.plist" &> /dev/null
107 sudo rm "/Library/LaunchDaemons/meshagentDiagnostic_periodicStart.plist" &> /dev/null
108 sudo rm "/Library/LaunchDaemons/meshagentDiagnostic.plist" &> /dev/null
109 +
110 +echo "Resetting TCC permissions for ###SERVICENAME###..."
111 +BUNDLE_ID=$(mdls -name kMDItemCFBundleIdentifier -raw "/usr/local/mesh_services/###COMPANYNAME###/###SERVICENAME###/###EXECUTABLENAME###" 2>/dev/null || true)
112 +if [ -n "\${BUNDLE_ID}" ] && [ "\${BUNDLE_ID}" != "(null)" ]; then
113 + sudo tccutil reset All "\${BUNDLE_ID}" &> /dev/null || true
114 +fi
115 +sudo tccutil reset All "###SERVICENAME###" &> /dev/null || true
116 +
117 sudo rm "/usr/local/mesh_services/###COMPANYNAME###/###SERVICENAME###/###EXECUTABLENAME###" &> /dev/null
118 sudo rm "/usr/local/mesh_services/###COMPANYNAME###/###SERVICENAME###/###EXECUTABLENAME###.msh" &> /dev/null
119 sudo rm "/usr/local/mesh_services/###COMPANYNAME###/###SERVICENAME###/###EXECUTABLENAME###.db" &> /dev/null
120 sudo rm "/usr/local/mesh_services/meshagentDiagnostic/meshagentDiagnostic" &> /dev/null
121 sudo rm "/Library/LaunchDaemons/###SERVICENAME###.plist" &> /dev/null
100 -sudo rm "/Library/LaunchAgents/###SERVICENAME###.plist" &> /dev/null
122 +sudo rm "/Library/LaunchAgents/###SERVICENAME###-launchagent.plist" &> /dev/null
123 echo "###SERVICENAME### was uninstalled."
124 `;
125
@@ -308,14 +330,14 @@ async function createMacOSInstaller(opts) {
330 await fsp.copyFile(opts.agentPath, path.join(installDir, opts.executableName));
331 await fsp.writeFile(path.join(installDir, opts.executableName + '.msh'), opts.meshSettings);
332 await fsp.writeFile(path.join(launchDaemons, opts.serviceName + '.plist'), replaceTokens(LAUNCH_DAEMON_PLIST, tokens));
311 - await fsp.writeFile(path.join(launchAgents, opts.serviceName + '.plist'), replaceTokens(LAUNCH_AGENT_PLIST, tokens));
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 await chmodIfExists(path.join(installDir, opts.executableName), 0o755);
337 await chmodIfExists(path.join(scriptsRoot, 'postinstall'), 0o755);
338 await chmodIfExists(path.join(installDir, opts.executableName + '.msh'), 0o644);
339 await chmodIfExists(path.join(launchDaemons, opts.serviceName + '.plist'), 0o644);
318 - await chmodIfExists(path.join(launchAgents, opts.serviceName + '.plist'), 0o644);
340 + await chmodIfExists(path.join(launchAgents, opts.serviceName + '-launchagent.plist'), 0o644);
341
342 const payloadStats = await walk(payloadRoot);
343 const installKBytes = Math.ceil(payloadStats.bytes / 1000);