First off, thank you for considering contributing to the sysadmin-toolkit! We welcome contributions from the community to make this collection of scripts even more useful for system administrators and operations engineers. Whether you're fixing a bug, proposing a new script, improving documentation, or suggesting enhancements, your input is valuable.
This document provides guidelines for contributing to the project to ensure a smooth and effective collaboration process.
- Contributing to sysadmin-toolkit
This project and everyone participating in it is governed by a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers. We strive to maintain a welcoming and respectful environment for everyone.
There are several ways you can contribute to the sysadmin-toolkit:
If you encounter a bug or unexpected behavior in one of the scripts:
- Search Existing Issues: Check the GitHub Issues first to see if the bug has already been reported.
- Open a New Issue: If not, please open a new issue. Provide as much detail as possible:
- A clear and descriptive title.
- The name of the script and its category folder.
- The version of the OS and relevant tools (e.g.,
bashversion,nmapversion if applicable). - Detailed steps to reproduce the bug.
- What you expected to happen.
- What actually happened (include relevant error messages or output).
- Any relevant configuration details.
Have an idea for improving an existing script or a proposal for a new script that fits the toolkit's purpose?
- Search Existing Issues: Check the GitHub Issues to see if a similar enhancement or script idea has already been suggested.
- Open a New Issue: If not, open a new issue describing your suggestion:
- Use a clear and descriptive title (e.g., "Enhancement: Add timeout option to check_port.sh" or "New Script Idea: Automated log rotation").
- Provide a detailed description of the enhancement or the purpose and functionality of the proposed new script.
- Explain the use case and why it would be beneficial to sysadmins.
- (Optional) Suggest a possible implementation approach.
Improvements to existing scripts, new scripts, documentation updates, and bug fixes are primarily handled through GitHub Pull Requests (PRs). Please follow the process outlined below.
Before you start coding:
- Ensure Prerequisites: Make sure you have
gitandbashinstalled. Review the general prerequisites in the main README.md. - Fork & Clone: Fork the repository to your own GitHub account and then clone your fork locally:
git clone https://github.com/YOUR_USERNAME/sysadmin-toolkit.git cd sysadmin-toolkit - Set Upstream Remote: Configure the original repository as the
upstreamremote:git remote add upstream https://github.com/0xbaha/sysadmin-toolkit.git
Unsure where to begin?
- Look for issues tagged
good first issueorhelp wanted. - Start with something small, like fixing a typo in comments, improving documentation, or addressing a simple bug.
- Feel free to ask questions on an issue if you need clarification before starting work.
- Sync Your Fork: Keep your local
mainbranch synchronized with theupstreamrepository:git checkout main git pull upstream main - Create a Branch: Create a new branch for your changes, named descriptively (e.g.,
fix/check-ip-timeout,feat/add-log-rotation-script):git checkout -b your-branch-name - Make Your Changes: Write your code, following the Scripting Guidelines. Add or modify scripts as needed.
- Test: Thoroughly test your changes locally to ensure they work as expected and don't introduce regressions.
- Commit: Commit your changes with clear, concise, and informative commit messages. Reference the relevant issue number if applicable (e.g.,
git commit -m 'feat: Add timeout option to check_ip.sh (fixes #123)'). - Push: Push your branch to your fork on GitHub:
git push origin your-branch-name - Open a Pull Request: Navigate to the original
sysadmin-toolkitrepository on GitHub and open a Pull Request from your branch to themainbranch.- Provide a clear title and description for your PR.
- Explain the purpose of your changes and why they are needed.
- Link to any relevant issues (e.g., "Closes #123").
- Outline the testing you have performed.
- Review & Discussion: Project maintainers will review your PR. Be prepared to discuss your changes and make adjustments based on feedback. The maintainers aim to review PRs in a timely manner, but response times may vary.
To maintain consistency and quality across the toolkit, please adhere to the following guidelines when contributing scripts:
- Target Shell: Write scripts primarily for
bash. Use the shebang#!/bin/bash. - Portability: While
bashis the target, avoid overly obscurebash-specific features (bashisms) if standard POSIX features suffice, unless the feature significantly improves the script. Assume a reasonably modernbashversion (e.g., 4.x+).
- Placement: Place new scripts in the most relevant category folder as defined in the main README.md. If unsure, suggest a category in your PR or issue.
- Naming: Use descriptive, lowercase filenames with underscores separating words (e.g.,
check_disk_usage.sh,backup_database.sh). Use the.shextension.
- Header Comments: Include comments at the top of each script explaining:
- Its purpose and functionality.
- Basic usage instructions (arguments, options).
- Any required dependencies (non-standard tools).
- (Optional) Author/Contributor and date.
- Inline Comments: Use comments to explain complex logic, algorithms, or non-obvious steps (explain the why, not just the what).
- Minimize: Use standard Linux/Unix utilities whenever possible.
- Document: Clearly list any non-standard dependencies (e.g.,
nmap,jq,rsync, specific packages) in the header comments. - Check Existence (Optional but Recommended): Consider adding checks within the script to verify if required commands exist (
command -v tool_name &> /dev/null) and provide a helpful error message if they don't.
- Check Exit Codes: Check the exit status (
$?) of critical commands and handle potential failures gracefully. - Use
setOptions (Recommended): Consider usingset -eo pipefailat the beginning of scripts to exit on errors (-e), treat unset variables as errors (-u, use with caution), and handle errors in pipelines (-o pipefail). Understand the implications before using them. - Provide Useful Output: Print informative status messages and clear error messages to standard error (
>&2).
- Manual Testing: Thoroughly test your script in various scenarios (different inputs, edge cases, failure conditions) on a standard Linux environment before submitting.
- Idempotency (Where Applicable): If a script makes configuration changes, strive to make it idempotent (running it multiple times produces the same result).
- Consistency: Try to follow the general style of existing scripts.
- Indentation: Use consistent indentation (e.g., 2 or 4 spaces).
- Variable Names: Use descriptive variable names (e.g.,
target_directoryinstead oftd). Prefer${variable_name}syntax for clarity. - Tools: Consider using tools like
shellcheckto identify potential issues and improve script quality.
If you are adding a script to a category that involves complex setup, multiple related scripts, or specific configurations, please consider adding or updating a README.md file within that category folder. This helps users understand the scripts in that specific context.
Maintainers may use labels (e.g., bug, enhancement, documentation, good first issue) on issues and PRs to help organize work. Feel free to suggest appropriate labels when opening issues or PRs.
If you have questions about contributing, the project's direction, or how to approach a specific change, feel free to open an issue on GitHub and ask!
Thank you for contributing to the sysadmin-toolkit!