Launchd
Jump to navigation
Jump to search
Launchd yra sistemos servisu/aplikaciju/procesu/scriptu pasileidimo ir sustabdymo kontroliavimo karkasas (angl. framework) pristatytas Mac OS X Tiger versijoje ir veikiantis iki siu laiku. Tai yra atviro kodo karkasas kuri sukure Dave Zarzycki kompanijoje Apple, jis yra licensijuotas Apache licensija.
Scripto paleidimas MacOS shutdown metu
Launchd konfiguracinis failas kuri irasome i /Library/LaunchDaemons/boot-shutdown-script.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>boot.shutdown.script.name</string>
<key>ProgramArguments</key>
<array>
<string>/opt/mod/boot-shutdown.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>LOG_PATH/boot-shutdown.log</string>
<key>StandardErrorPath</key>
<string>LOG_PATH/boot-shutdown.err</string>
</dict>
</plist>
Sukuriame direktorija
sudo mkdir -p /opt/mod
Idedame si script teksta i faila /opt/mod/boot-shutdown.sh
#!/bin/bash
function shutdown()
{
# CIA SURASOME KA NORIME PALEISTI MAC OS SHUTDOWN METU
exit 0
}
function startup()
{
# CIA SURASOME KA NORIME PALEISTI MAC OS STARTAVIMO METU
tail -f /dev/null &
wait $!
}
trap shutdown SIGTERM
trap shutdown SIGKILL
startup;
Igaliname scripta pasileisti:
chmod +x /opt/mod/boot-shutdown.sh launchctl load -w /Library/LaunchDaemons/boot-shutdown-script.plist