jssimporter / JSSImporter

JSSImporter is deprecated. Please see the wiki for alternatives
Apache License 2.0
145 stars 38 forks source link

Scripts need <name> = <filename> #78

Closed ftiff closed 7 years ago

ftiff commented 8 years ago

I believe I should be able to create a script with a different name than filename. I mean I should do this: Recipe:

            <key>SCRIPT_NAME</key>
            <string>Add Printer</string>
            <key>SCRIPT_FILENAME</key>
            <string>add_printer.sh</string>
[snip]
                    <key>scripts</key>
                    <array>
                        <dict>
                            <key>name</key>
                            <string>%SCRIPT_FILENAME%</string>
                            <key>template_path</key>
                            <string>S-Standard.xml</string>
                        </dict>
                    </array>

Script Template:

<script>
    <name>%SCRIPT_NAME%</name>
    <category>%CATEGORY%</category>
    <filename>%SCRIPT_FILENAME%</filename>
    <info />
    <notes />
    <priority>After</priority>
    <parameters />
    <os_requirements />
</script>

Unfortunately, I get this error:

JSSImporter: Found file: /Users/admin/Library/AutoPkg/RecipeRepos/com.github.ftiff.mac-autopkg/S-Standard.xml
Response Code: 409  Response: Conflict. Error: Duplicate name
Failed.
Receipt written to /Users/admin/Library/AutoPkg/Cache/com.github.ftiff.mac-autopkg.jss.followme/receipts/com.github.ftiff.mac-autopkg.jss-receipt-20160118-130317.plist

The following recipes failed:
    com.github.ftiff.mac-autopkg.jss.followme
        Error in com.github.ftiff.mac-autopkg.jss.followme: Processor: JSSImporter: Error: Response Code: 409   Response: Conflict. Error: Duplicate name

First of all, am I right?

If yes, I'm ok to work on this and create a PR, as I believe @sheagcraig is quite busy.

sheagcraig commented 8 years ago

Yes-scripts and packages can have different names and filenames. Specifically, at least with non-cloud/JDS distribution points, the filename had to point to the filename of the actual file, whereas the name could be something more human-readable.

The 409 error that you are getting is due to the fact that there is already a name or filename on your JSS that the attempt to update/post is conflicting with. If you remove all similarly named scripts, does this fail the first time, or only on subsequent runs?

I'm a little bit rusty on why this happens, as it has been awhile, but remember having similar issues in the past that revolved around which name the JSS uses for the actual identity of the object. You should be able to sort out the issue by playing around with some combination of removing conflicting named scripts and running multiple times. I can say with authority that name must be unique. I don't know whether filename needs to be unique, although I think it probably has to be too. Imagine what would happen if you had two script objects referencing the same filename, perhaps with the intention of being analogous to a link in the filesystem-save disk space by only having one copy of an otherwise duplicated file. However, using the web-interface to delete this script would result in the second script object have a reference to a now-non-existent file. So I would think the filename also has to be unique. But I don't think they need to be the same thing. Indeed, I'm sure you can prove that using Casper Admin pretty quickly.

I do believe this should work correctly without changing the JSSImporter code; I never did it because I wanted my name and filename to match, but I don't see any reason why you shouldn't be able to do it that way if you want to.

Let me know what you find out and hopefully we can make some progress.

sheagcraig commented 8 years ago

Any updates on this?

sheagcraig commented 7 years ago

Guessing this has been abandoned, based on the dates. Feel free to reopen if you feel like working on it again @ftiff!

master-vodawagner commented 5 years ago

Hi,

I've started to get this on a random recipe override and I cannot figure out why because I have other recipes overrides with scripts that do not error out.