akvirtualcamera/ports/deploy/installscript.mac.qs

115 lines
5.2 KiB
Text
Raw Normal View History

2020-06-05 22:09:17 +00:00
function Component()
{
}
Component.prototype.beginInstallation = function()
{
component.beginInstallation();
}
Component.prototype.createOperations = function()
{
component.createOperations();
2020-06-11 20:38:57 +00:00
// Remove virtual cameras
if (installer.isUninstaller()) {
component.addOperation("Execute",
"@TargetDir@/@Name@.plugin/Contents/Resources/AkVCamManager",
"remove-devices");
component.addOperation("Execute",
"@TargetDir@/@Name@.plugin/Contents/Resources/AkVCamManager",
"update");
}
2020-06-11 20:38:57 +00:00
// Remove old plugin
if (installer.isInstaller()) {
component.addOperation("ConsumeOutput",
"AkPluginSymlink",
"/usr/bin/readlink",
"/Library/CoreMediaIO/Plug-Ins/DAL/@Name@.plugin");
if (installer.value("AkPluginSymlink") == "")
component.addElevatedOperation("Execute",
"rm",
"-rf",
"/Library/CoreMediaIO/Plug-Ins/DAL/@Name@.plugin");
2020-08-10 18:37:33 +00:00
component.addElevatedOperation("Execute",
"chmod",
"a+x",
2020-08-10 18:37:33 +00:00
"@TargetDir@/@Name@.plugin/Contents/Resources/AkVCamAssistant");
component.addElevatedOperation("Execute",
"chmod",
"a+x",
2020-08-10 18:37:33 +00:00
"@TargetDir@/@Name@.plugin/Contents/Resources/AkVCamManager");
2020-06-11 20:38:57 +00:00
}
// Create a symlink to the plugin.
component.addElevatedOperation("Execute",
"ln",
"-s",
"@TargetDir@/@Name@.plugin",
"/Library/CoreMediaIO/Plug-Ins/DAL/@Name@.plugin",
"UNDOEXECUTE",
"rm",
"-f",
"/Library/CoreMediaIO/Plug-Ins/DAL/@Name@.plugin");
// Set assistant daemon.
let service = "org.webcamoid.cmio.AkVCam.Assistant"
let daemonPlist = "/Library/LaunchDaemons/" + service + ".plist"
2020-06-11 20:38:57 +00:00
let plistContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" "
+ "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
+ "<plist version=\"1.0\">\n"
+ " <dict>\n"
+ " <key>Label</key>\n"
+ " <string>" + service + "</string>\n"
2020-06-11 20:38:57 +00:00
+ " <key>ProgramArguments</key>\n"
+ " <array>\n"
+ " <string>"
+ installer.value("TargetDir")
+ "/AkVirtualCamera.plugin/Contents/Resources/AkVCamAssistant"
+ "</string>\n"
+ " <string>--timeout</string>\n"
+ " <string>300.0</string>\n"
+ " </array>\n"
+ " <key>MachServices</key>\n"
+ " <dict>\n"
+ " <key>" + service + "</key>\n"
2020-06-11 20:38:57 +00:00
+ " <true/>\n"
+ " </dict>\n"
2020-06-29 16:17:34 +00:00
+ " <key>StandardOutPath</key>\n"
+ " <string>/tmp/AkVCamAssistant.log</string>\n"
+ " <key>StandardErrorPath</key>\n"
+ " <string>/tmp/AkVCamAssistant.log</string>\n"
2020-06-11 20:38:57 +00:00
+ " </dict>\n"
+ "</plist>\n";
component.addElevatedOperation("Delete", daemonPlist);
component.addElevatedOperation("AppendFile", daemonPlist, plistContents);
// Load assistant daemon.
if (installer.isUninstaller())
component.addElevatedOperation("Execute",
"launchctl", "enable", "system/" + service);
2020-06-11 20:38:57 +00:00
component.addElevatedOperation("Execute",
"launchctl", "bootstrap", "system", daemonPlist,
2020-06-11 20:38:57 +00:00
"UNDOEXECUTE",
"launchctl", "bootout", "system", daemonPlist);
2020-06-11 20:38:57 +00:00
if (installer.isUninstaller())
component.addElevatedOperation("Delete", daemonPlist);
if (installer.value("TargetDir") != "/Applications/" + installer.value("Name"))
component.addElevatedOperation("Execute",
"ln",
"-s",
"@TargetDir@",
"/Applications/@Name@",
"UNDOEXECUTE",
"rm",
"-f",
"/Applications/@Name@");
2020-06-05 22:09:17 +00:00
}