# 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](https://www.hexnode.com/mobile-device-management/help/how-to-run-scripts-on-mac-using-hexnode-mdm/) 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

 Disclaimer: 
The sample scripts provided below are adapted from third-party open-source sites.

 

Deploy ZIP file
---------------

The below script downloads the ZIP folder and unzips its contents on the device.

Script to deploy a ZIP file

\#!/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"

   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:

1. Open Finder by clicking on the Finder icon in the Dock or searching for it in Spotlight.
2. In the Finder menu, click on “Go” and select “Go to Folder”.
3. In the “Go to Folder” dialog box, type **/tmp** and press “Enter”. This will open the /tmp folder in Finder.
4. The user must navigate to the /tmp folder, identify the installer and install the app manually.

Here is an example script:

Sample script to deploy a ZIP file

\#!/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" 

   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" 

   

 

  

 Notes:- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.