Category filter
Script to deploy ZIP file to Macs using a URL
In enterprise environments, IT administrators often need to deploy applications to a large number of macOS devices. One way to accomplish this is by creating a ZIP file of the application and distributing it to the devices through a download URL. In this context, a script to deploy a ZIP file can automate the deployment process which saves time and effort for administrators. Use Hexnode’s Execute Custom Script feature to deploy the script that downloads the ZIP file and its extracted content on the devices using a download URL.
Scripting Language – Bash
File extension – .sh
Deploy ZIP file
The below script downloads the ZIP folder and unzips its contents on the device.
1 2 3 4 5 6 7 8 9 10 |
#!/bin/bash #Switch to the /tmp directory cd /tmp #Download the ZIP file curl -k [DOWNLOAD_URL] -o "[FOLDER_NAME].zip" #Unzip the file unzip "[FOLDER_NAME].zip" |
The cd /tmp command changes the current working directory to the /tmp directory, and curl -k makes an HTTP request to download data from a URL.
[Download_URL]: Replace this with the server URL that contains the ZIP file. For example, https://example.com/myapp.zip.
[FOLDER_NAME].zip: Specify the name of the ZIP file in the URL. For example, myapp.zip.
After the execution of the script, the ZIP file, along with its extracted content, will be downloaded to the device’s /tmp directory. To navigate to this directory, please follow these steps on the device:
- Open Finder by clicking on the Finder icon in the Dock or searching for it in Spotlight.
- In the Finder menu, click on “Go” and select “Go to Folder”.
- In the “Go to Folder” dialog box, type /tmp and press “Enter”. This will open the /tmp folder in Finder.
- The user must navigate to the /tmp folder, identify the installer and install the app manually.
Here is an example script:
1 2 3 4 5 6 7 8 9 10 |
#!/bin/bash #Switch to the /tmp directory cd /tmp #Download the ZIP file curl -k https://example.com/myapp.zip -o "myapp.zip" #Unzip the installer unzip "myapp.zip" |