This PR closes https://github.com/fleetdm/fleet/issues/21108 @noahtalerman, I double-checked all redirects, and they are working. Clicking through the URLs in [this spreadsheet](https://docs.google.com/spreadsheets/d/1djVynIMuJK4pT5ziJW12CluVqcaoxxnCLaBO3VXfAt4/edit?usp=sharing) is a pretty quick way to go through them all. Note that "Audit logs" and "Understanding host vitals" redirect to the contributor docs on GitHub, so they will throw a 404 until this is merged. Some new guides benefitted from a name change, so they make more sense as stand-alone guides, and also so that we don't have to mess around with more redirects later. Those name changes followed [this convention](https://fleetdm.com/handbook/company/communications#headings-and-titles), which was recently documented in the handbook. Have fun! --------- Co-authored-by: Eric <eashaw@sailsjs.com> Co-authored-by: Noah Talerman <noahtal@umich.edu>
2.4 KiB
Scripts
In Fleet you can execute a custom script to remediate an issue on your macOS, Windows, and Linux hosts.
Shell scripts are supported on macOS and Linux. By default, shell scripts will run in the host's (root) shell (/bin/sh). We also support /bin/zsh interpreter.
Note: To run in /bin/zsh, create .sh file (only supported extension) and add an interpreter at the first line.
PowerShell scripts are supported on Windows. Other types of scripts are not supported yet.
Script execution is disabled by default. Continue reading to learn how to enable scripts.
Enable scripts
If you use Fleet's macOS MDM features, scripts are automatically enabled for macOS hosts that have MDM turned on. You're set!
If you don't use MDM features, to enable scripts, we'll deploy a fleetd agent with scripts enabled:
-
Generate a new fleetd agent for macOS, Windows, or Linux using the
fleetctl packagecommand with the--enable-scriptsflag. -
Deploy fleetd to your hosts. If your hosts already have fleetd installed, you can deploy the new fleetd on-top of the old installation.
Learn more about generating a fleetd agent and deploying it here.
Execute a script
You can execute a script in the Fleet UI, with Fleet API, or with the fleetctl command-line interface (CLI).
Fleet UI:
-
In Fleet, head to the Controls > Scripts tab and upload your script.
-
Head to the Hosts page and select the host you want to run the script on.
-
On your target host's host details page, select the Actions dropdown and select Run Script to view the Run Script menu.
-
In the Run Script menu, select the Actions dropdown for the script you'd like to execute and choose the Run option.
Scripts run from the Fleet UI will run the next time your host checks in with Fleet. You can view the status of the script execution as well as the output in the target host's activity feed.
Fleet API: API documentation is here
fleetctl CLI:
fleetctl run-script --script-path=/path/to/script --host=hostname