Support auto-install in package uploader tool (#31117)

This commit is contained in:
Tim Lee 2025-07-22 08:36:41 -04:00 committed by GitHub
parent 6147a12ece
commit b5de3c58e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View file

@ -6,10 +6,11 @@
2. Run the following script to upload a folder of packages via the Fleet API:
``` bash
bash ./tools/software/packages/upload-packages.sh -u $FLEET_URL -t $TEAM_ID -k "$API_KEY" -f $FOLDER_PATH_CONTAINING_PACKAGES
bash ./tools/software/packages/upload-packages.sh -u $FLEET_URL -t $TEAM_ID -k "$API_KEY" -f $FOLDER_PATH_CONTAINING_PACKAGES [-a]
```
Notes:
- uploading to a `localhost` Fleet server is heavily encouraged as uploading a large amount of packages is time consuming and can be subject to timeouts using tools like `ngrok`
- `upload-packages.sh` creates non-functional install and uninstall scripts for `exe` files
- use the `-a` flag to add auto-install to the upload

View file

@ -4,16 +4,26 @@ set -euo pipefail
shopt -s nullglob
usage() {
echo "Usage: $0 -u FLEET_URL -t TEAM_ID -k API_TOKEN -f FOLDERPATH"
echo "Usage: $0 -u FLEET_URL -t TEAM_ID -k API_TOKEN -f FOLDERPATH [-a]"
echo ""
echo "Options:"
echo " -u FLEET_URL The Fleet server URL"
echo " -t TEAM_ID The team ID"
echo " -k API_TOKEN The API token for authentication"
echo " -f FOLDERPATH Path to the folder containing packages"
echo " -a Enable automatic installation (optional)"
exit 1
}
while getopts "u:t:k:f:" opt; do
AUTO_INSTALL=false
while getopts "u:t:k:f:a" opt; do
case ${opt} in
u ) API_URL="$OPTARG" ;;
t ) TEAM_ID="$OPTARG" ;;
k ) API_TOKEN="$OPTARG" ;;
f ) FOLDER="$OPTARG" ;;
a ) AUTO_INSTALL=true ;;
* ) usage ;;
esac
done
@ -44,6 +54,7 @@ for file in "${files[@]}"; do
-H "Authorization: Bearer $API_TOKEN"
-F "software=@${file}"
-F "team_id=$TEAM_ID"
-F "automatic_install=$AUTO_INSTALL"
)
if [[ "$ext" == "exe" ]]; then