2013-11-21 164 views
1

創建安裝程序我有一個shell腳本,拷貝的plist與sudo cp com.example.plist /Library/LaunchDaemons /庫/ LaunchDaemons然後用chown root com.example.plistlaunchctl load com.example.plist用於啓動守護進程

在命令行中運行時,這工作完全啓動,但我需要創建一個將這個shell腳本分發給非技術性的Mac用戶,這樣他們就可以下載腳本,雙擊它(可能在對話框中輸入他們的用戶名/密碼)並點擊OK。像.pkg或.dmg這樣的東西將是理想的。

我曾嘗試鴨嘴獸和appify但既不作品與sudo因爲須藤導致它在等待那個永遠不會到來的輸入掛起。有沒有辦法爲這個守護進程創建一個安裝程序,或者我需要創建一個應用程序?

回答

0

也許你可以像這樣的腳本保存在的AppleScript編輯器的應用程序:

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 
+0

謝謝,這個作品!注意:Applescript應用程序必須分佈在zip文件夾中,以便其他用戶能夠安裝它們。 – Bob