in cortado/rtas/plist_creation.py [0:0]
def main():
launch_agents_dir = Path.home() / "Library" / "Launchagents"
plistbuddy_bin = "/usr/libexec/PlistBuddy"
plist_file = Path.home() / "Library" / "Launchagents" / "init_verx.plist"
# Create launch agents dir if it doesn't exist
if not launch_agents_dir.exists():
log.info(f"Creating directory {launch_agents_dir}")
launch_agents_dir.mkdir()
# Create plist file using Plistbuddy
log.info("Executing PlistBuddy commands to create plist file")
_ = _common.execute_command(
[f"{plistbuddy_bin}", "-c", "Add :Label string init_verx", f"{plist_file}"],
shell=True,
)
pause()
_ = _common.execute_command([f"{plistbuddy_bin}", "-c", "Add :RunAtLoad bool true", f"{plist_file}"])
pause()
_ = _common.execute_command([f"{plistbuddy_bin}", "-c", "Add :StartInterval integer 3600", f"{plist_file}"])
pause()
_ = _common.execute_command([f"{plistbuddy_bin}", "-c", "Add :ProgramArguments array", f"{plist_file}"])
pause()
_ = _common.execute_command(
[
f"{plistbuddy_bin}",
"-c",
"Add :ProgramArguments:0 string '/bin/sh'",
f"{plist_file}",
]
)
pause()
_ = _common.execute_command(
[
f"{plistbuddy_bin}",
"-c",
"Add :ProgramArguments:1 string -c",
f"{plist_file}",
]
)
# Delete the plist file if it exists
if plist_file.exists():
log.info(f"Deleting plist file {plist_file}")
plist_file.unlink()