mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 08:50:12 -08:00
5.8 KiB
5.8 KiB
GitHub Copilot Instructions for Shell Repository
This document provides context and guidance for GitHub Copilot when working with this shell script and dotfiles repository.
Repository Overview
This repository contains:
- Shell scripts for system administration tasks
- Dotfiles for system configuration
- Setup scripts for automated environment configuration
- Docker-based testing framework for validating setup across environments
Repository Structure
- Root directory: Contains various utility shell scripts
- docs/: Documentation for individual scripts and components
- dotfiles/: System configuration files that get symlinked to the user's home directory
- powershell/: PowerShell scripts for Windows environments
- setup/: Setup scripts and package lists for automated environment configuration
- .github/: GitHub-related configuration files
Key Files Overview
Shell Scripts
- bootstrap.sh: Entry point script for automated setup
- test-setup.sh: Testing script for validating environment setup
- run-docker-tests.sh: Runner for Docker-based testing
- update.sh: System update scripts
- plex.sh: Plex Media Server management
Configuration Files
- setup/packages.list: List of packages to install during setup
- dotfiles/my-aliases.zsh: Custom ZSH aliases
- dotfiles/tailscale-acl.json: Tailscale ACL configuration
Documentation
- README.md: Main repository documentation
- docs/docker-bootstrap-testing-framework.md: Detailed documentation for the Docker-based bootstrap validation framework
- dotfiles/README.md: Documentation for dotfiles setup and usage
Style Guidelines
When suggesting code or modifications:
-
Shell Scripts:
- Use
#!/bin/bashfor most scripts - Include proper error handling with
set -ewhere appropriate - For test scripts, avoid
set -eto allow testing all components - Add descriptive comments for script sections
- Use colors for terminal output when appropriate (GREEN, RED, YELLOW, etc.)
- Use capitalized variable names (e.g.,
USER_HOME=/home/user)
- Use
-
Docker Files:
- Follow Docker best practices for layer optimization
- Use specific tags for base images rather than 'latest'
- Include proper LABEL directives for metadata
-
Documentation:
- Use proper Markdown formatting
- Include code examples using appropriate syntax highlighting
- Document script parameters and usage
Testing Framework
When modifying the testing framework:
- Make sure to test across both Ubuntu and Debian environments
- Ensure tests continue even when individual components fail
- Track and summarize all errors at the end of tests
- Maintain proper error reporting and logging
Docker Testing Enhancements
The Docker-based testing framework includes these key features:
-
Continuous Testing: Tests continue running even when individual package installations fail
- Achieved by removing
set -efrom test scripts - Uses a counter to track errors rather than exiting immediately
- Achieved by removing
-
Package Testing:
- Dynamically reads packages from
setup/packages.list - Tests each package individually
- Maintains an array of missing packages for final reporting
- Dynamically reads packages from
-
Summary Reporting:
- Provides a comprehensive summary of all failed tests
- Suggests commands to fix missing packages
- Saves detailed logs to a timestamped file
-
Cross-Platform Testing:
- Tests both Ubuntu and Debian environments
- Handles platform-specific package names (e.g.,
batvsbatcat)
Key Concepts
- Shell Environment Setup: Focuses on ZSH with Oh My Zsh and plugins
- Docker Testing: Validates environment setup in isolated containers
- Dotfiles Management: Uses symbolic links to user's home directory
- Package Installation: Uses apt/nala on Debian-based systems
Main Use Cases
- Setting up a new development environment: Using bootstrap.sh
- Managing media services: Using plex.sh and related scripts
- System maintenance: Using update.sh and backup scripts
- Testing configuration changes: Using the Docker testing framework
Code Organization Principles
- Modularity: Keep scripts focused on one task
- Documentation: Document all scripts and configurations
- Testing: Ensure all changes are testable
- Cross-platform: Support both Ubuntu and Debian where possible
Security Practices
When suggesting security-related code:
-
Permissions:
- Avoid running scripts as root unless necessary
- Use
sudofor specific commands rather than entire scripts - Set appropriate file permissions (e.g.,
chmod 600for sensitive files)
-
Secret Management:
- Never include hardcoded credentials in scripts
- Use environment variables or external secret management
- Add sensitive files to .gitignore
-
Input Validation:
- Validate and sanitize all user inputs
- Use quotes around variables to prevent word splitting and globbing
- Implement proper error handling for invalid inputs
-
Network Security:
- Verify URLs before downloading (
curl/wget) - Use HTTPS instead of HTTP when possible
- Validate checksums for downloaded packages
- Verify URLs before downloading (
Contribution Guidelines
For contributors and Copilot suggestions:
-
Script Modifications:
- Test all changes using the Docker testing framework
- Update documentation when adding new functionality
- Maintain backward compatibility when possible
-
New Scripts:
- Follow the established naming conventions
- Include a header with description, usage, and author
- Add appropriate documentation to the docs/ directory
- Add any new dependencies to setup/packages.list
-
Review Process:
- Run tests before submitting changes
- Document what was changed and why
- Consider both Ubuntu, Debian, and Fedora compatibility