Search code examples
shellunixcurlaemwindows-shell

How to iterate all files inside folder and run curl command to install AEM packages


I am trying to create a shell script which to iterate all the zip files and install those in AEM package manager using curl command. The below single curl command is working, It is properly installing the package in respective AEM instance.

curl -u admin:admin -F file=@"content-ope.zip" -F name="content-ope.zip" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp

But we have to install many zip files so we are planning to keep all of them in one folder, iterate all the zip files and install using curl command. Tried with while and for loop but unable to read all the .zip files using shell script.

Can anyone have any idea on this?


Solution

  • I wrote that exact thing, see here:

    https://gist.github.com/ahmed-musallam/07fbf430168d4ac57bd8c89d8be9bca5

    #!/bin/bash
    # this script will install ALL zip packages in current directory the AEM instance at 4502
    for f in *.zip
    do
        echo "installing: $f"
        curl -u admin:admin -F file=@"$f" -F name="$f" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp
        echo "done."
    
    done