dongzhashou0116 2017-11-12 13:58
浏览 46
已采纳

如何分发OSX CLI /服务器应用程序

Im building a cli app that can run in server mode for osx in golang. I come from the server world and have no idea how properly distribute a consumer cli tool for osx. The cli can run as a service which can be easily achieved with launchd.

Launchd config:

<plist version="1.0">
    <dict>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>focus-daemon</string>
        <key>RunAtLoad</key>
        <true />
        <key>Program</key>
        <string>/usr/local/bin/focus</string>
  </dict>
</plist>

Building and running is also quite simple:

go build main.go
sudo cp main /usr/local/bin/focus
rm main
sudo chown root /usr/local/bin/focus
sudo chmod 4555 /usr/local/bin/focus
cp focus.plist ~/Library/LaunchAgents/com.21stio.focus.plist
launchctl load ~/Library/LaunchAgents/com.21stio.focus.plist

When being build the process requires sudo to set a sbit on the binary.

I don't want the user having to run a .sh script. Maybe I could use brew and/or a DMG for that. But I have no idea how I can put the Launchd config at the right spot then.

  • 写回答

1条回答 默认 最新

  • dqed19166 2017-11-14 12:07
    关注

    As was suggested in the comments, installer pkgs are usually the way to go with this type of software. You're probably familiar with them if you've manually installed device drivers, OS updates and other lower-level software on the Mac.

    You can also generate them with command-line utilities, and don't necessarily need to use the 3rd party app that pvg suggested in the comment. This answer is a good starting point. Using the command-line tools also lets you automate package building as part of your standard build process.

    Note that Apple's own old "PackageMaker" GUI tool no longer works properly with newer versions of macOS/OSX, I strongly advise you not to use that.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题