Example: Preparing a Custom Package for ZIP Setup
Use the install.sh script from the 1Password app package (provided below) as a template.
You will need to provide the following parameter values for function main():
- display_name – name of your deployment package that Action1 will use when displaying History messages.
- proc_names – application processes for the app you need to install.
- src_app_folder – the top-level folder in the unpacked ZIP software package you downloaded from the vendor.
- binary_path – you can get it by browsing the src_app_folder (within the ZIP); typically, the setup binary is located under Contents / MacOS.
Important! It is strongly recommended that you edit the script on a macOS machine using the Mac tools. If you plan to use a Windows machine and an editing tool like Notepad++, consider that it may append the “CR” (‘r’) character to each line when saving the file. In this case, make sure that you have removed these characters from the code; otherwise, the script will fail to run.
#!/bin/bash
export PATH=$PATH:/sbin:/usr/sbin
source "common.sh"
trap 'finally_zip $?' EXIT SIGINT
result=''
# external named parameters
# -m "install"|"upgrade"
# -p "/Applications"|"custom_path"
# -f "App folder name.app", for upgrade only
# -s "error|kill|ignore". Default="kill" and continue deployment
# -v "ERR|WARN|INFO|DBG"
# -b "app.new.build.number"
agruments="$@"
inv_script=$(basename "$0")
log_started "$inv_script" "$agruments"
validate_params "$@" || exit $?
deploy_mode="$m"
inst_root_folder="$p"
app_process_mode="$s"
upgrade_app_folder="$f"
new_app_ver="$b"
log_level="$v"
#log_level="DBG"
### 1Password install\update
function main() {
# internal parameters
display_name='1Password' # Name of your deployment package that Action1 will use when displaying History messages.
log -m "$(printf 'start deploying "%s"' "$display_name")" -n "INFO"
proc_names=("1Password") # Application process name for the app you need to install. Multiple names should be separated by space, e.g., ("process1" "process2")
dmg_mount_point='./local_mnt' # Do not modify. Files mount point.
src_app_folder='1Password.app' # Top-level folder in the unpacked ZIP software package you downloaded from the vendor.
extract_path='./local_mnt'
binary_path="${extract_path}/${src_app_folder}/Contents/MacOS/1Password" #You can get the binary path by browsing the src_app_folder (within the ZIP)
if [[ "$deploy_mode" == 'install' ]]; then
app_folder_name="$src_app_folder"
else
app_folder_name="$upgrade_app_folder"
fi
# test setup file
get_setup_by_ext "zip" && setup_file="$result" || exit $?
# unzip setup_file
unzip_archive "$setup_file" "$extract_path" || exit $?
# test application binary architecture
test_binary_arch "$binary_path" || exit $?
# test running processes
if [[ "$app_process_mode" == 'kill' ]]; then
kill_process "${proc_names[@]}"
fi
if [[ "$app_process_mode" != 'ignore' ]]; then
test_process "${proc_names[@]}" || exit $?
fi
# deploy software\update
copy_app_folder "${extract_path}/${src_app_folder}" "$inst_root_folder" "$app_folder_name" "$deploy_mode" || exit $?
exit 0
}
main
NOTE: MacOS is case-sensitive, so make sure you copy and paste all names correctly.
After you have edited the install.sh, save the file and include it in the ZIP archive together with common.sh and the application setup (DMG file).
How the install.sh works for ZIP files?
- It looks for the software setup file within the ZIP you obtained from the vendor.
NOTE: Make sure that ZIP contains only one software setup file. - It unpacks this ZIP file.
- Then it checks the application target architecture.
- It checks if there is an application process running. If found, it terminates the process.
- It copies the content of the unpacked ZIP into the application folder, replacing the existing files.
