【问题标题】:Creating installer for launch daemon为启动守护进程创建安装程序
【发布时间】:2013-12-05 11:49:00
【问题描述】:

我有一个 shell 脚本,它使用 sudo cp com.example.plist /Library/LaunchDaemons 将 plist 复制到 /Library/LaunchDaemons,然后使用 chown root com.example.plistlaunchctl load com.example.plist 启动它

这在从命令行运行时完美运行,但我需要创建一种方法将此 shell 脚本分发给非技术 Mac 用户,以便他们可以下载脚本,双击它,(可能输入他们的用户名/密码进入对话框),然后点击确定。 .pkg 或 .dmg 之类的文件是理想的。

我已经尝试过 Platypus 和 appify,但两者都不适用于 sudo,因为 sudo 会导致它在等待永远不会出现的输入时挂起。有没有办法为这个守护进程创建一个安装程序,还是我需要制作一个应用程序?

【问题讨论】:

    标签: ios macos shell daemon sudo


    【解决方案1】:

    也许您可以将这样的脚本保存为 AppleScript Editor 中的应用程序:

    do shell script "echo '<?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>com.example</string>
      <key>ProgramArguments</key>
      <array>
        <string>touch</string>
        <string>/aa</string>
      </array>
      <key>StartInterval</key>
      <integer>5</integer>
    </dict>
    </plist>' > /Library/LaunchDaemons/com.example.plist
    launchctl load /Library/LaunchDaemons/com.example.plist" with administrator privileges
    

    【讨论】:

    • 谢谢,这行得通!注意:Applescript 应用程序必须分发在一个 zip 文件夹中,以便其他用户能够安装它们。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-13
    • 2011-08-28
    • 1970-01-01
    相关资源
    最近更新 更多