Error executing script postinstall_script

瀏覽次數:81 次
跳到第一則未讀訊息

Connor Charalambides

未讀,
2022年4月11日 上午10:15:562022/4/11
收件者:munki-discuss

Hi,

I'm running into a post install script issue trying to run a command to disable auto updates on slack following their official instructions: https://slack.com/intl/en-gb/help/articles/360035635174-Deploy-Slack-for-macOS

I'm using MunkiAdmin to manage this, however have double checked the plist and all seems to be in order.

Error: After installing and not having the desired effect I ran managedsoftwareupdate --installonly -vvv and found: 

ERROR: Error executing script postinstall_script: [Errno 2] No such file or directory: '/tmp/munki-9l6adkg3/postinstall_script'

WARNING: Postinstall script for Slack returned -1

The script is very simple: 

#!bin/bash
/usr/bin/defaults write /Users/$USER/Library/Preferences/com.tinyspeck.slackmacgap SlackNoAutoUpdates -bool YES

exit 0


If anybody has run into this issue and knows if I'm doing something stupid or knows how to resolve the issue that'd be great.

Thanks in advance!

Connor



Here is a copy of the pkginfo:

<?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>_metadata</key>
    <dict>
        <key>created_by</key>
        <string>xxxxxxx</string>
        <key>creation_date</key>
        <date>2022-03-25T07:07:19Z</date>
        <key>munki_version</key>
        <string>5.5.0.4360</string>
        <key>os_version</key>
        <string>10.15.7</string>
    </dict>
    <key>autoremove</key>
    <false/>
    <key>catalogs</key>
    <array>
        <string>test</string>
        <string>base</string>
    </array>
    <key>category</key>
    <string>Communication</string>
    <key>description</key>
    <string>Slack is a platform for team communication: everything in one place, instantly searchable, available wherever you go.</string>
    <key>developer</key>
    <string>Slack</string>
    <key>display_name</key>
    <string>Slack</string>
    <key>installer_item_hash</key>
    <string>ace4ff8750236fc8bf08022d25b74f127fded538484495749c5002160700cfb9</string>
    <key>installer_item_location</key>
    <string>apps/slack/Slack-4.25.0.dmg</string>
    <key>installer_item_size</key>
    <integer>81675</integer>
    <key>installer_type</key>
    <string>copy_from_dmg</string>
    <key>installs</key>
    <array>
        <dict>
            <key>CFBundleIdentifier</key>
            <string>com.tinyspeck.slackmacgap</string>
            <key>CFBundleName</key>
            <string>Slack</string>
            <key>CFBundleShortVersionString</key>
            <string>4.25.0</string>
            <key>CFBundleVersion</key>
            <string>6956</string>
            <key>minosversion</key>
            <string>10.11</string>
            <key>path</key>
            <string>/Applications/Slack.app</string>
            <key>type</key>
            <string>application</string>
            <key>version_comparison_key</key>
            <string>CFBundleShortVersionString</string>
        </dict>
    </array>
    <key>items_to_copy</key>
    <array>
        <dict>
            <key>destination_path</key>
            <string>/Applications</string>
            <key>source_item</key>
            <string>Slack.app</string>
        </dict>
    </array>
    <key>minimum_os_version</key>
    <string>10.11</string>
    <key>name</key>
    <string>Slack</string>
    <key>postinstall_script</key>
    <string>#!bin/bash

/usr/bin/defaults write /Users/$USER/Library/Preferences/com.tinyspeck.slackmacgap SlackNoAutoUpdates -bool YES

exit 0</string>
    <key>unattended_install</key>
    <true/>
    <key>uninstall_method</key>
    <string>remove_copied_items</string>
    <key>uninstallable</key>
    <true/>
    <key>version</key>
    <string>4.25.0</string>
</dict>
</plist>



Gregory Neagle

未讀,
2022年4月11日 上午10:17:242022/4/11
收件者:munki-...@googlegroups.com
Your shebang line is invalid. 

It should be #!/bin/bash


Sent from my iPhone

On Apr 11, 2022, at 7:15 AM, Connor Charalambides <charala...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "munki-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to munki-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/munki-discuss/d3c63beb-1655-4cb8-aae4-2c65b96507cdn%40googlegroups.com.

Mike Solin

未讀,
2022年4月11日 下午2:12:342022/4/11
收件者:munki-...@googlegroups.com
If I might add: Slack's sample script includes the variable $USER, but since Munki runs as root, this might not return the user that's actually using the device. If that's the case, it will not have the desired effect on the Slack Mac app.

You can instead opt to disable Slack's autoupdates via a configuration profile:


From there, use AutoPkg to populate your Munki repo with new versions of the Slack app, and add them to the appropriate catalog/manifest when you're ready to deploy.

Connor Charalambides

未讀,
2022年4月12日 凌晨4:58:332022/4/12
收件者:munki-discuss
Haha, yup that was it! 

What I get for not checking something so simple!
However, it appears Mikes reply is correct and the script does not have the desired effect running as root.

Thanks though!

Connor Charalambides

未讀,
2022年4月12日 清晨7:57:532022/4/12
收件者:munki-discuss
I managed to resolve the issue with the $USER variable.

Using the users command I was able to get an array of all users logged in, including my the user running managedsoftwareupdate

#!/bin/bash

currentUsersArray=( $(users) )

for i in "${currentUsersArray[@]}"

do

   if [ ! -f /Users/$i/Library/Preferences/com.tinyspeck.slackmacgap ]

   then

      touch /Users/$i/Library/Preferences/com.tinyspeck.slackmacgap

   fi

   defaults write /Users/$i/Library/Preferences/com.tinyspeck.slackmacgap SlackNoAutoUpdates -bool YES

   chown $i /Users/$i/Library/Preferences/com.tinyspeck.slackmacgap

done

exit 0


Thanks for the help!

Gregory Neagle

未讀,
2022年4月12日 上午8:07:012022/4/12
收件者:munki-...@googlegroups.com
Still in most environments it would be far simpler and more robust to use a configuration profile. 

Sent from my iPhone

On Apr 12, 2022, at 4:58 AM, Connor Charalambides <charala...@gmail.com> wrote:

I managed to resolve the issue with the $USER variable.
回覆所有人
回覆作者
轉寄
0 則新訊息