{"id":1661,"date":"2007-05-02T23:19:23","date_gmt":"2007-05-02T14:19:23","guid":{"rendered":"http:\/\/yasu2.prosou.nu\/blog\/index.php\/2007\/05\/02\/launchd_howto\/"},"modified":"2007-05-02T23:19:23","modified_gmt":"2007-05-02T14:19:23","slug":"launchd_howto","status":"publish","type":"post","link":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/2007\/05\/02\/1661\/","title":{"rendered":"launchd HOWTO"},"content":{"rendered":"<p>MacOS X 10.5 has autofs, but 10.4 doesn&#8217;t. Alternative solution is am-utils, available in <a href=\"http:\/\/www.macports.org\/\">MacPorts<\/a>. However, MacPorts doesn&#8217;t provide any way to launch amd at startup.<\/p>\n<p>\nIn MacOS X, there&#8217;s no scripts like \/etc\/rc, but there&#8217;s launchd. I spent about a half day to launch amd by launchd and learned:<\/p>\n<ul>\n<li>Write the policy to launch in \/System\/Library\/LaunchDaemons\/foobar.plist\n<li>The process spawned by foobar.plist must NOT go background, but must stay in foreground (see launchd.plist(5)!).\n<\/ul>\n<p>However, my sweet amd goes background&#8230; So, launchd misunderstands: &#8220;Oh, amd is dead. I must start a new one!&#8221; and there will be so many amd processes.<\/p>\n<p>\nAs the solution, I wrote a simple wrapper script (amd_start) like:<\/p>\n<pre>\n#!\/bin\/sh\n\/opt\/local\/sbin\/amd -F \/opt\/local\/etc\/amd.conf\nwhile [ true ]; do\nsleep 360000\ndone\n<\/pre>\n<p>And my amd.plist is this:<\/p>\n<pre>\n&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;!DOCTYPE plist PUBLIC \"-\/\/Apple Computer\/\/DTD PLIST 1.0\/\/EN\" \"http:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd\"&gt;\n&lt;plist version=\"1.0\"&gt;\n&lt;dict&gt;\n&lt;key&gt;Label&lt;\/key&gt;\n&lt;string&gt;amd&lt;\/string&gt;\n&lt;key&gt;OnDemand&lt;\/key&gt;\n&lt;false\/&gt;\n&lt;key&gt;ProgramArguments&lt;\/key&gt;\n&lt;array&gt;\n&lt;string&gt;\/System\/Library\/amd_start&lt;\/string&gt;\n&lt;\/array&gt;\n&lt;key&gt;ServiceIPC&lt;\/key&gt;\n&lt;false\/&gt;\n&lt;\/dict&gt;\n&lt;\/plist&gt;\n<\/pre>\n<p>Put this in \/System\/Library\/LaunchDaemons\/amd.plist, then:<\/p>\n<pre>\n% sudo launchctl load \/System\/Library\/LaunchDaemons\/amd.plist\n<\/pre>\n<p>This will launch amd.<\/p>\n<p>\nlaunchd is fun&#8230; It works as \/etc\/rc, crond and inetd. Wow.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MacOS X 10.5 has autofs, but 10.4 doesn&#8217;t. Alternative solution is am-utils, available in MacPorts. Howe &hellip; <a href=\"https:\/\/yasu2.prosou.nu\/blog\/index.php\/2007\/05\/02\/1661\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;launchd HOWTO&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[9,6],"tags":[],"class_list":["post-1661","post","type-post","status-publish","format-standard","hentry","category-mac","category-unix-"],"_links":{"self":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1661"}],"version-history":[{"count":0,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1661\/revisions"}],"wp:attachment":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}