https://github.com/jonesiscoding/mac-libs
A library of common reusable bash functions for macOS
https://github.com/jonesiscoding/mac-libs
bash jamf library macos script terminal
Last synced: 5 months ago
JSON representation
A library of common reusable bash functions for macOS
- Host: GitHub
- URL: https://github.com/jonesiscoding/mac-libs
- Owner: jonesiscoding
- License: lgpl-2.1
- Created: 2022-09-10T13:35:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-09T17:58:42.000Z (8 months ago)
- Last Synced: 2025-06-09T18:46:55.231Z (8 months ago)
- Topics: bash, jamf, library, macos, script, terminal
- Language: Shell
- Homepage:
- Size: 115 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mac-libs
A library of common reusable bash functions, with 0 non-native dependencies, to assist in the management of macOS computers.
While all the functionality can be replicated within macOS itself, there are two advantages to using the library:
* Less code to touch if the method to do something in macOS changes.
* Less remembering (or searching for) obscure macOS utilities, flags, and filters.
### Usage
* Source one of the stub files below, depending on how your script to be run.
* Source each of the function files that contain the functions you want to use.
* Internal dependencies are taken care of automatically.
* See individual function files for arguments & additional notes.
* If using `jamf.sh` or `root.sh`, initialize the user with one of the `user::init` functions.
#### Stub Files
| File | For | Effects |
|-----------|-------------------------------------------------|-------------------------------------------------------------------------|
| `core.sh` | Scripts run as shell user | User functions automatically run on $USER |
| `root.sh` | Scripts run as root, affecting a different user | Must call `user::init ` or `user::init::console` to set user. |
| `jamf.sh` | Scripts run via Jamf Pro | * User functions automaticaly run on username supplied by Jamf as $3.
* `$jamfUser` automatically set to `$3`
* `$jamfHost` automatically set to `$2
* `$jamfRoot` automatically set to `$1`
* All arguments shifted, $4 becomes $1 |
### User Functions
All functions based on user information in this library run on a specific _reference user_, based on the chosen sub file (see above) and the `user::init` function used.
### Optional Installer Script
If your script is running as root, you can silently install the library using the 1-liner below:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/jonesiscoding/mac-libs/HEAD/bin/install.sh)" || exit 1
The installer will check this repo for the most recent release, then if needed, download & extract to `/usr/local/sbin/lib/mac-libs/`.