Example: Preparing a Custom Package for PKG Setup
Use the install.sh script from the Microsoft Teams 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.
- default_app_folder – default application folder.
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_pkg $?' 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"
### Microsoft Teams install\update
function main() {
# internal parameters
display_name='Microsoft Teams' # for messages only
log -m "$(printf 'start deploying "%s"' "$display_name")" -n "INFO"
proc_names=("MSTeams$") # array, f.e. ("process1" "process2")
default_app_folder="Microsoft Teams.app" # for install mode
if [[ "$deploy_mode" == 'install' ]]; then
app_folder_name="$default_app_folder"
else
app_folder_name="$upgrade_app_folder"
fi
# test setup file
get_setup_by_ext "pkg" && setup_file="$result" || 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
deploy_pkg "$setup_file" "$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 (PKG file).
How the install.sh works for PKG files?
- It checks if there is an application process running. If found, it terminates the process.
- It installs the application in the specified app folder, using the macOS installer utility.
