ventura mesh fix
This commit is contained in:
parent
e51e4ccf83
commit
8e6858778b
24
agent/embed_darwin.go
Normal file
24
agent/embed_darwin.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
//go:build darwin
|
||||||
|
// +build darwin
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2023 Amidaware Inc.
|
||||||
|
|
||||||
|
Licensed under the Tactical RMM License Version 1.0 (the “License”).
|
||||||
|
You may only use the Licensed Software in accordance with the License.
|
||||||
|
A copy of the License is available at:
|
||||||
|
|
||||||
|
https://license.tacticalrmm.com
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
package agent
|
||||||
|
|
||||||
|
import _ "embed"
|
||||||
|
|
||||||
|
//go:embed scripts/macos_fix_mesh_install.sh
|
||||||
|
var ventura_mesh_fix string
|
||||||
|
|
||||||
|
func (a *Agent) FixVenturaMesh() {
|
||||||
|
a.RunScript(ventura_mesh_fix, "foo", []string{}, 45, false, []string{})
|
||||||
|
}
|
17
agent/embed_stub.go
Normal file
17
agent/embed_stub.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
//go:build !darwin
|
||||||
|
// +build !darwin
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2023 Amidaware Inc.
|
||||||
|
|
||||||
|
Licensed under the Tactical RMM License Version 1.0 (the “License”).
|
||||||
|
You may only use the Licensed Software in accordance with the License.
|
||||||
|
A copy of the License is available at:
|
||||||
|
|
||||||
|
https://license.tacticalrmm.com
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
package agent
|
||||||
|
|
||||||
|
func (a *Agent) FixVenturaMesh() {}
|
90
agent/scripts/macos_fix_mesh_install.sh
Normal file
90
agent/scripts/macos_fix_mesh_install.sh
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# source: https://github.com/amidaware/community-scripts/blob/main/scripts_staging/macos_fix_mesh_install.sh
|
||||||
|
# author: https://github.com/NiceGuyIT
|
||||||
|
|
||||||
|
# This script fixes MeshAgent issue #161: MacOS Ventura - Not starting meshagent on boot (Maybe Solved)
|
||||||
|
# https://github.com/Ylianst/MeshAgent/issues/161
|
||||||
|
#
|
||||||
|
# The following actions are taken:
|
||||||
|
# 1) Add the eXecute bit for directory traversal for the installation directory. This allows regular users
|
||||||
|
# access to run the binary inside the directory, fixing the "meshagent" LaunchAgent integration with the
|
||||||
|
# user.
|
||||||
|
# 2) Rename the LaunchAgent "meshagent.plist" to prevent conflicts with the LaunchDaemon "meshagent.plist".
|
||||||
|
# This may not be needed but is done for good measure.
|
||||||
|
# 3) Rename the service Label inside the plist. Using "defaults" causes the plist to be rewritten in plist
|
||||||
|
# format, not ascii.
|
||||||
|
#
|
||||||
|
# Here's the original plist from my install.
|
||||||
|
# <?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
# <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
# <plist version="1.0">
|
||||||
|
# <dict>
|
||||||
|
# <key>Label</key>
|
||||||
|
# <string>meshagent</string>
|
||||||
|
# <key>ProgramArguments</key>
|
||||||
|
# <array>
|
||||||
|
# <string>/opt/tacticalmesh/meshagent</string>
|
||||||
|
# <string>-kvm1</string>
|
||||||
|
# </array>
|
||||||
|
#
|
||||||
|
# <key>WorkingDirectory</key>
|
||||||
|
# <string>/opt/tacticalmesh</string>
|
||||||
|
#
|
||||||
|
# <key>RunAtLoad</key>
|
||||||
|
# <true/>
|
||||||
|
# <key>LimitLoadToSessionType</key>
|
||||||
|
# <array>
|
||||||
|
# <string>LoginWindow</string>
|
||||||
|
# </array>
|
||||||
|
# <key>KeepAlive</key>
|
||||||
|
# <dict>
|
||||||
|
# <key>Crashed</key>
|
||||||
|
# <true/>
|
||||||
|
# </dict>
|
||||||
|
# </dict>
|
||||||
|
# </plist>
|
||||||
|
|
||||||
|
|
||||||
|
mesh_install_dir="/opt/tacticalmesh/"
|
||||||
|
mesh_agent_plist_old="/Library/LaunchAgents/meshagent.plist"
|
||||||
|
mesh_agent_plist="/Library/LaunchAgents/meshagent-agent.plist"
|
||||||
|
mesh_daemon_plist="/Library/LaunchDaemons/meshagent.plist"
|
||||||
|
|
||||||
|
if [ ! -f "${mesh_daemon_plist}" ]
|
||||||
|
then
|
||||||
|
echo "meshagent LaunchDaemon does not exist to cause the duplicate service name issue. Exiting."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if /usr/bin/stat -f "%Sp" "${mesh_install_dir}" | grep -v 'x$' >/dev/null
|
||||||
|
then
|
||||||
|
echo "Fixing permissions on meshagent installation directory: ${mesh_install_dir}"
|
||||||
|
chmod o+X "${mesh_install_dir}"
|
||||||
|
else
|
||||||
|
echo "No action taken. Permissions on meshagent installation directory have already been fixed."
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [ -f "${mesh_agent_plist_old}" ]
|
||||||
|
then
|
||||||
|
echo "Renaming agent plist: ${mesh_agent_plist_old}"
|
||||||
|
mv "${mesh_agent_plist_old}" "${mesh_agent_plist}"
|
||||||
|
else
|
||||||
|
echo "No action taken. meshagent.plist was already renamed: ${mesh_agent_plist}"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
# New file has to exist before renaming the label.
|
||||||
|
if [ -f "${mesh_agent_plist}" ]
|
||||||
|
then
|
||||||
|
label=$(defaults read "${mesh_agent_plist}" Label)
|
||||||
|
if [ "${label}" != "meshagent-agent" ]
|
||||||
|
then
|
||||||
|
echo "Renaming meshagent label in plist: ${mesh_agent_plist}"
|
||||||
|
echo "Warning: This will convert the plist from a text file to a binary plist file."
|
||||||
|
defaults write "${mesh_agent_plist}" Label "meshagent-agent"
|
||||||
|
else
|
||||||
|
echo "No action taken. meshagent label was already renamed: ${label}"
|
||||||
|
fi
|
||||||
|
fi
|
@ -80,6 +80,10 @@ func (a *Agent) AgentSvc(nc *nats.Conn) {
|
|||||||
a.SendSoftware()
|
a.SendSoftware()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
go a.FixVenturaMesh()
|
||||||
|
}
|
||||||
|
|
||||||
checkInHelloTicker := time.NewTicker(time.Duration(conf.Hello) * time.Second)
|
checkInHelloTicker := time.NewTicker(time.Duration(conf.Hello) * time.Second)
|
||||||
checkInAgentInfoTicker := time.NewTicker(time.Duration(conf.AgentInfo) * time.Second)
|
checkInAgentInfoTicker := time.NewTicker(time.Duration(conf.AgentInfo) * time.Second)
|
||||||
checkInWinSvcTicker := time.NewTicker(time.Duration(conf.WinSvc) * time.Second)
|
checkInWinSvcTicker := time.NewTicker(time.Duration(conf.WinSvc) * time.Second)
|
||||||
|
2
main.go
2
main.go
@ -119,6 +119,8 @@ func main() {
|
|||||||
a.RunMigrations()
|
a.RunMigrations()
|
||||||
case "recovermesh":
|
case "recovermesh":
|
||||||
a.RecoverMesh()
|
a.RecoverMesh()
|
||||||
|
case "macventurafix":
|
||||||
|
a.FixVenturaMesh()
|
||||||
case "taskrunner":
|
case "taskrunner":
|
||||||
if len(os.Args) < 5 || *taskPK == 0 {
|
if len(os.Args) < 5 || *taskPK == 0 {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user