A comprehensive collection of reusable bash functions and scripts for common DevOps and system administration tasks, designed to make shell scripting more efficient and maintainable.
- Modular design for easy integration
- Reusable functions for common operations
- Well-documented code with examples
- Cross-platform compatibility
- Easy installation and setup
- Docker-based development environment
- Comprehensive DevOps tool integration
- Docker (20.10.0 or higher)
- Git
- Basic Shell Scripting knowledge
- Development Environment (VS Code, Vim, etc.)
- OS: Linux, macOS, or Windows with WSL2
- CPU: 2+ cores recommended
- RAM: 4GB minimum, 8GB recommended
- Storage: 10GB free space minimum
- Network: Stable internet connection
curl -sSL https://raw.githubusercontent.com/hperezrodal/bash-library/main/install-remote.sh | bashIf you're using zsh on macOS, you'll need to add the following to your ~/.zshrc file:
# Add bash-library to your PATH
export PATH="$PATH:/path/to/bash-library"
# Source the library
source /path/to/bash-library/lib-loader.shAfter adding these lines, reload your zsh configuration:
source ~/.zshrc- Clone the repository:
git clone https://github.com/hperezrodal/bash-library.git
cd bash-library- Run the installation script:
./install.shsudo ./uninstall.shcurl -sSL https://raw.githubusercontent.com/hperezrodal/bash-library/main/uninstall-remote.sh | bashFor zsh users, remove the bash-library related lines from your ~/.zshrc file and run:
source ~/.zshrcAfter uninstallation, you may need to restart your shell or run source ~/.zshrc for changes to take effect.
The repository includes a pre-commit hook that runs shfmt and shellcheck on all shell scripts. To set it up:
- 
Install Required Tools: For Linux (Debian/Ubuntu): sudo apt-get update sudo apt-get install shellcheck sudo snap install shfmt For macOS (using Homebrew): brew install shellcheck brew install shfmt 
- 
Make the Hook Executable: chmod +x .git/hooks/pre-commit 
The pre-commit hook will automatically:
- Format all shell scripts using shfmt
- Check for potential issues using shellcheck
- Prevent commits if any issues are found
bash-library/
βββ modules/             # Core function modules
βββ scripts/             # Utility scripts
βββ examples/            # Usage examples
βββ lib-loader.sh        # Main functions file
βββ install.sh           # Installation script
βββ uninstall.sh         # Uninstallation script
βββ build.sh             # Docker build script
βββ CONTRIBUTING.md      # Contribution guidelines
| Module | Description | 
|---|---|
| ansible.sh | Ansible automation and configuration management functions. Includes functions for inventory management, playbook execution, and variable handling. | 
| aws.sh | AWS operations and utilities | 
| eth_rpc.sh | Ethereum RPC interaction functions | 
| kubernetes.sh | Kubernetes cluster management and operations. Includes functions for pod management, deployment operations, service management, and cluster configuration. | 
| logging.sh | Logging utilities | 
Each module is designed to be self-contained and can be used independently.
To use the library in your scripts, source the main functions file:
source /path/to/bash-library/lib-loader.shThe library provides several modules with common functions:
- AWS Operations (aws.sh): Functions for AWS-related operations
The library provides the following utility scripts:
- AWS Secrets Management (aws-secrets.sh): Script for managing AWS secrets
After installation, scripts are automatically made available in your system's PATH. You can use them in two ways:
- 
Direct Execution # Run the script directly aws-secrets --help
- 
Sourcing in Your Script # Source the script to use its functions source /path/to/bash-library/scripts/aws-secrets.sh 
Each script includes built-in help documentation. To view available options and usage:
aws-secrets --help# Using AWS secrets script
aws-secrets get-secret my-secret-nameCheck out the examples/ directory for practical usage examples of the library functions.
Contributions are always welcome! Please read the contribution guidelines first.
MIT License - See LICENSE file for details
Made with β€οΈ by hperezrodal