fleet/pkg/file/scripts/remove_pkg.sh
Roberto Dip 37fe905f96
missing validations and tweaks to default scripts (#18780)
This adds two things:

- when implementing the CLI, I found [a
panel](https://www.figma.com/file/oQl2oQUG0iRkUy0YOxc307/%2314921-Deploy-security-agents-to-macOS%2C-Windows%2C-and-Linux-hosts?type=design&node-id=779-29335&mode=design&t=Y27cbj7DdhUEGJko-4)
in the Figma file with validations that I missed
- explicit shebang for bash scrips (requested by product) and removed a
comment that will be user facing for exe files.
2024-05-07 13:02:08 -03:00

10 lines
430 B
Bash

#!/bin/sh
# grab the identifier from the first PackageInfo we find. Those are placed in different locations depending on the installer
pkg_id=$(tar xOvf "$INSTALLER_PATH" --include='*PackageInfo*' 2>/dev/null | sed -n 's/.*identifier="\([^"]*\)".*/\1/p')
# remove all the files and empty directories that were installed
pkgutil --files $pkg_id | tr '\n' '\0' | xargs -n 1 -0 rm -d
# remove the receipt
pkgutil --forget $pkg_id