grahampugh / jamf-upload

Scripts for uploading packages to Jamf Cloud
Apache License 2.0
149 stars 37 forks source link

Support for multiple SMB shares and SMB + Cloud DP support #74

Closed novaksam closed 1 year ago

novaksam commented 1 year ago

Moved away from my delimited strings to separate fields. Tested and confirmed functionality for two on-prem DPs using SMB_URL and SMB2_URL

MLBZ521 commented 1 year ago

I added a patch to novaksam's repo to simply the logic for multiple SMB DPs.

I also had a thought of setting the SMB share attributes (url, username, password) in a dictionary within an array and then you could simply loop through as many of them as there were. That would negate having all the smb_<attr><#> listed in the Processor/Recipe Overrides/Prefs file.

grahampugh commented 1 year ago

I'll happily review the PR once @MLBZ521's suggestions have been merged in.

grahampugh commented 1 year ago

Thank you. I have some amendments to make, but I'll do them myself the JamfUpload repo.

grahampugh commented 1 year ago

@MLBZ521 @novaksam I have made amendments which now allow for infinite number of SMB DPs. You still supply SMB_URL, SMB2_URL etc, but a while loop keeps adding to the list of tuples until it reaches an empty SMBx_URL. This also saves manually adding code for each extra SMB DP, and accommodates someone coming along who has 30 DPs around the world or whatever.

I've tested it on 2 DPs, and I've tested it with JCDS + 2 DPs. It seems to work, though I have no idea how Jamf handles multiple DPs in reality, having never had to deal with that kind of setup.

Let me know if either of you get to test it out.

MLBZ521 commented 1 year ago

I don't have any way to test SMB DPs any more -- I just noticed a way to improve the logic.

I also had an idea to make the SMB shares an array of dictionaries that could be looped through, instead of the SMB#_<ATTRIBUTE>, and not having to account for an infinite number of DPs in the input variables, some what to what you've done.

e.g.

<key>smb_shares</key>
<array>
    <dict>
        <key>smb_url</key>
        <string>smb://server</string>
        <key>smb_username</key>
        <string>username</string>
        <key>smb_password</key>
        <string>password</string>
    </dict>
    <dict>
        <key>smb_url</key>
        <string>smb://server</string>
        <key>smb_username</key>
        <string>username</string>
        <key>smb_password</key>
        <string>password</string>
    </dict>
    <dict>
        <key>smb_url</key>
        <string>smb://server</string>
        <key>smb_username</key>
        <string>username</string>
        <key>smb_password</key>
        <string>password</string>
    </dict>
</array>
grahampugh commented 1 year ago

That's how JSSImporter did it, but I don't want to do that, because it's impossible to override or supply from the command line, which breaks the convention of AutoPkg shared processors. My current method achieves a similar result while complying to the restrictions of Input lists.

grahampugh commented 1 year ago

Actually, I've now figured out how to offer both possibilities, so that an array can be used in the prefs, but alternatively, individual keys can be used in recipes or at the command line (or in the autopkg prefs, or in a recipe-list.plist), allowing for overrides.