repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
big-bear-casaos
github_2023
others
2,163
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,79 @@ +# Configuration for big-bear-umbrel setup + +# Name of the big-bear-umbrel application +name: big-bear-umbrel + +# Service definitions for the big-bear-umbrel application +services: + # Service name: big-bear-umbrel + # The `big-bear-umbrel` service definition + big-bear-umbrel: + # Name of the container + container_name: big-bear-umbrel + + # Image to be used for the container + image: dockurr/umbrel:1.2.2 + + # Container restart policy + restart: unless-stopped + + # Ports mapping between host and container + ports: + # Mapping port 8080 of the host to port 80 of the container + - "8080:80" + + # Volumes to be mounted to the container + volumes: + # Mounting the local /DATA/AppData/$AppID directory to /data inside the container + - /DATA/AppData/$AppID/data:/data + + # Mounting docker.sock to allow docker management via Umbrel + - /var/run/docker.sock:/var/run/docker.sock
_:warning: Potential issue_ **Security concern: Docker socket mount grants excessive privileges.** Mounting `/var/run/docker.sock` gives the container root access to the host Docker daemon. This is a significant security risk as it allows the container to: 1. Create/modify/delete containers 2. Access host resources 3. Potentially escape container isolation Consider: 1. Running Umbrel without Docker socket access if possible 2. If required, implement strict security measures <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
2,163
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,79 @@ +# Configuration for big-bear-umbrel setup + +# Name of the big-bear-umbrel application +name: big-bear-umbrel + +# Service definitions for the big-bear-umbrel application +services: + # Service name: big-bear-umbrel + # The `big-bear-umbrel` service definition + big-bear-umbrel: + # Name of the container + container_name: big-bear-umbrel + + # Image to be used for the container + image: dockurr/umbrel:1.2.2 + + # Container restart policy + restart: unless-stopped + + # Ports mapping between host and container + ports: + # Mapping port 8080 of the host to port 80 of the container + - "8080:80" + + # Volumes to be mounted to the container + volumes: + # Mounting the local /DATA/AppData/$AppID directory to /data inside the container + - /DATA/AppData/$AppID/data:/data + + # Mounting docker.sock to allow docker management via Umbrel + - /var/run/docker.sock:/var/run/docker.sock + + # Stop grace period for the container + stop_grace_period: 1m
_:hammer_and_wrench: Refactor suggestion_ **Add container security and operational best practices.** Several important container configurations are missing: 1. Resource limits (memory, CPU) 2. User context (avoid running as root) 3. Logging limits 4. Health check Add these configurations: ```diff restart: unless-stopped + user: "1000:1000" # Run as non-root user + deploy: + resources: + limits: + memory: 2G + cpus: '2' + logging: + options: + max-size: "10m" + max-file: "3" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:80/health"] + interval: 30s + timeout: 10s + retries: 3 ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion # Container restart policy restart: unless-stopped user: "1000:1000" # Run as non-root user deploy: resources: limits: memory: 2G cpus: '2' logging: options: max-size: "10m" max-file: "3" healthcheck: test: ["CMD", "curl", "-f", "http://localhost:80/health"] interval: 30s timeout: 10s retries: 3 # Ports mapping between host and container ports: # Mapping port 8080 of the host to port 80 of the container - "8080:80" # Volumes to be mounted to the container volumes: # Mounting the local /DATA/AppData/$AppID directory to /data inside the container - /DATA/AppData/$AppID/data:/data # Mounting docker.sock to allow docker management via Umbrel - /var/run/docker.sock:/var/run/docker.sock # Stop grace period for the container stop_grace_period: 1m ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
2,163
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,79 @@ +# Configuration for big-bear-umbrel setup + +# Name of the big-bear-umbrel application +name: big-bear-umbrel + +# Service definitions for the big-bear-umbrel application +services: + # Service name: big-bear-umbrel + # The `big-bear-umbrel` service definition + big-bear-umbrel: + # Name of the container + container_name: big-bear-umbrel + + # Image to be used for the container + image: dockurr/umbrel:1.2.2
_:bulb: Codebase verification_ **Security concern: Unverified Docker image source** The image `dockurr/umbrel:1.2.2` raises significant security concerns: - The image pull attempt failed, indicating it's not available in the public Docker registry - No documentation or references to this image source were found in the codebase - The repository name "dockurr" appears unofficial and suspicious, as it's not associated with the official Umbrel organization Please verify: 1. The correct official Umbrel image repository and tag 2. Replace the potentially malicious `dockurr/umbrel` image with the official one 3. Consider pinning the image digest instead of using tag for better security <details> <summary>πŸ”— Analysis chain</summary> **Verify the image source and integrity.** The image `dockurr/umbrel:1.2.2` is being used. Please ensure: 1. This is the official Umbrel image repository 2. The version 1.2.2 is the latest stable release 3. The image has been scanned for vulnerabilities --- Let me gather more information about the image usage and repository context. --- Let me try one more verification to check the official Umbrel repositories and documentation. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Check if this is a known/official image and get vulnerability info docker pull dockurr/umbrel:1.2.2 2>/dev/null docker scan dockurr/umbrel:1.2.2 2>/dev/null || echo "Docker scan not available" ``` Length of output: 130 --- Script: ```shell #!/bin/bash # Search for image references in docker compose files rg -l "dockurr/umbrel" --type yaml # Check README or docs for image information fd -e md -x cat {} 2>/dev/null | rg -i "umbrel.*image|docker.*umbrel" # Look for any image build context fd Dockerfile -x cat {} ``` Length of output: 158 --- Script: ```shell #!/bin/bash # Check the repository for any references to official Umbrel images rg -i "getumbrel|umbrel/|umbrelbox" --type yaml # Look for any documentation about Docker images fd -g "*INSTALL*" -g "*DOCKER*" -g "*CONTRIBUTING*" -x cat {} 2>/dev/null | rg -i "umbrel.*image|docker.*umbrel" # Check if there's a local build process fd -g "*build*" -g "*setup*" -g "*install*" -x cat {} 2>/dev/null | rg -i "umbrel.*image|docker.*build" ``` Length of output: 250 </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
2,024
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,114 @@ +# Configuration for tailscale setup + +# Name of the big-bear-tailscale application +name: big-bear-tailscale + +# Service definitions for the big-bear-tailscale application +services: + # Service name: big-bear-tailscale + # The `big-bear-tailscale` service definition + big-bear-tailscale: + # Name of the container + container_name: big-bear-tailscale + + # Image to be used for the container + image: tailscale/tailscale:v1.76.6 + + # Container restart policy + restart: unless-stopped + + # Environment variables for the container + environment: + - TS_SERVE_CONFIG="" + - TS_ACCEPT_DNS=false + - TS_AUTH_ONCE=false + - TS_AUTHKEY="" + - TS_HOSTNAME="" + - TS_ROUTES="" + - TS_EXTRA_ARGS="" + - TS_USERSPACE=true + - TS_STATE_DIR=/var/lib/tailscale
_:warning: Potential issue_ **Add validation and documentation for required environment variables** Several critical environment variables are empty and need proper documentation: 1. `TS_AUTHKEY`: Required for authentication 2. `TS_HOSTNAME`: Important for identification 3. `TS_SERVE_CONFIG`: Should be properly configured if used Consider adding environment variable validation in the container's entrypoint or startup script. Also, add comments explaining which variables are required and their expected formats. Example documentation format: ```yaml environment: # Required: Tailscale authentication key from admin console - TS_AUTHKEY= # Required: Unique hostname for this Tailscale node - TS_HOSTNAME= # Optional: Set to true to serve config from /config/tailscale.conf - TS_SERVE_CONFIG= # ... other variables ``` <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
2,024
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,114 @@ +# Configuration for tailscale setup + +# Name of the big-bear-tailscale application +name: big-bear-tailscale + +# Service definitions for the big-bear-tailscale application +services: + # Service name: big-bear-tailscale + # The `big-bear-tailscale` service definition + big-bear-tailscale: + # Name of the container + container_name: big-bear-tailscale + + # Image to be used for the container + image: tailscale/tailscale:v1.76.6 + + # Container restart policy + restart: unless-stopped + + # Environment variables for the container + environment: + - TS_SERVE_CONFIG="" + - TS_ACCEPT_DNS=false + - TS_AUTH_ONCE=false + - TS_AUTHKEY="" + - TS_HOSTNAME="" + - TS_ROUTES="" + - TS_EXTRA_ARGS="" + - TS_USERSPACE=true + - TS_STATE_DIR=/var/lib/tailscale + + # Volumes to be mounted to the container + volumes: + - /DATA/AppData/$AppID/state:/var/lib/tailscale + - /DATA/AppData/$AppID/config:/config + - /dev/net/tun:/dev/net/tun + + cap_add: + - net_admin + - sys_module + + x-casaos: # CasaOS specific configuration + envs: + - name: TS_SERVE_CONFIG + description: + en_us: "Tailscale Config" + - name: TS_ACCEPT_DNS + description: + en_us: "Accept DNS" + - name: TS_AUTH_ONCE + description: + en_us: "Auth Once" + - name: TS_AUTHKEY + description: + en_us: "Auth Key" + - name: TS_HOSTNAME + description: + en_us: "Tailscale Hostname" + - name: TS_ROUTES + description: + en_us: "Routes" + - name: TS_EXTRA_ARGS + description: + en_us: "Tailscale Extra Args" + - name: TS_USERSPACE + description: + en_us: "Tailscale User Space" + - name: TS_STATE_DIR + description: + en_us: "Tailscale State Dir" + volumes: + - container: /var/lib/tailscale + description: + en_us: "Container Path: /var/lib/tailscale" + - container: /config + description: + en_us: "Container Path: /config" + - container: /dev/net/tun + description: + en_us: "Container Path: /dev/net/tun" + ports: + - container: "7575" + description: + en_us: "Container Port: 7575"
_:warning: Potential issue_ **Resolve port configuration inconsistency** There's an inconsistency in port configuration: 1. Port 7575 is defined in the ports section 2. `port_map` is empty at the bottom of the file 3. Missing protocol specification (TCP/UDP) 4. Missing documentation about port usage Please either: 1. Document the purpose of port 7575 and update port_map accordingly 2. Remove the port configuration if it's not needed Also applies to: 114-114 <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition + bot: + # Name of the container + container_name: big-bear-gem_digest_bot + + # Docker image to use + image: piero24/gemdigest:latest + + # Build the container from the Dockerfile + build: + # Context points to the current directory + context: . + # Dockerfile location + dockerfile: Dockerfile + + # Mount local directory to the container's /home/dev directory + volumes: + - /DATA/AppData/$AppID/extra_configs:/gem_digest_bot/extra_configs + + # Environment variables with default values + environment: + TELEGRAM_API_KEY: TELEGRAM_API_KEY + GEMINI_API_KEY: GEMINI_API_KEY + # Add more users separating their id with ";" + ADMIN_USER_ID: 123;456
_:warning: Potential issue_ **Secure sensitive environment variables** Environment variables containing API keys should not be hardcoded. Consider: 1. Using environment files (`.env`) 2. Using Docker secrets for sensitive data 3. Using a secure secrets management solution ```diff - environment: - TELEGRAM_API_KEY: TELEGRAM_API_KEY - GEMINI_API_KEY: GEMINI_API_KEY - # Add more users separating their id with ";" - ADMIN_USER_ID: 123;456 + env_file: + - .env ``` Create a `.env.example` file with: ```plaintext TELEGRAM_API_KEY=your_telegram_api_key GEMINI_API_KEY=your_gemini_api_key ADMIN_USER_ID=123;456 ``` <!-- This is an auto-generated reply by CodeRabbit -->
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition + bot: + # Name of the container + container_name: big-bear-gem_digest_bot + + # Docker image to use + image: piero24/gemdigest:latest + + # Build the container from the Dockerfile + build: + # Context points to the current directory + context: . + # Dockerfile location + dockerfile: Dockerfile + + # Mount local directory to the container's /home/dev directory + volumes: + - /DATA/AppData/$AppID/extra_configs:/gem_digest_bot/extra_configs + + # Environment variables with default values + environment: + TELEGRAM_API_KEY: TELEGRAM_API_KEY + GEMINI_API_KEY: GEMINI_API_KEY + # Add more users separating their id with ";" + ADMIN_USER_ID: 123;456 + + + # Container restart policy + restart: unless-stopped + + # Ports mapping between host and container + ports: + # Example: Mapping port 8080 of the host to port 8080 of the container (adjust as needed) + - "3333:8080" + + x-casaos: # CasaOS specific configuration + volumes: + - container: /gem_digest_bot/extra_configs + description: + en_us: "Container Path: /gem_digest_bot/extra_configs" + ports: + - container: "8080" + description: + en_us: "Container Port: 8080" + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + - arm64 + + # Main service of the application + main: big-bear-gem_digest_bot + + description: + # Description in English + en_us: Simplify your reads, amplify your time! πŸ“šβœ¨ GemDigest is a Telegram bot that summarizes articles from any website into bite-sized nuggets, saving you time and energy for what matters most. πŸ“±πŸ‘‹ + + tagline: + # Short description or tagline in English + en_us: Your personal article summarizer + + # Developer's name or identifier + developer: "Armaggheddon" + + # Author of this configuration + author: BigBearCommunity + + # Application category + category: BigBearCasaOS + + # Icon for the application + icon: https://raw.githubusercontent.com/Piero24/GemDigest/refs/heads/main/.github/images/casOS_logo.png + + # Thumbnail image (currently empty) + thumbnail: "" + + title: + # Title in English + en_us: GemDigest Bot + + tips: + custom: Add you `TELEGRAM-API-KEY` and `GEMINI-API-KEY` in settings and the + users `ID` that are considered as admin separated by a ";" if thereare + more then one. for more info visit [GemDigest](https://github.com/Armaggheddon/GemDigest) + + # Port mapping information + port_map: "3333"
_:warning: Potential issue_ **Fix YAML formatting issues** The YAML file has several formatting issues: 1. Multiple lines with trailing spaces 2. Missing newline at end of file Please run the following command to fix formatting: ```shell sed -i 's/[[:space:]]*$//' docker-compose.yml && echo >> docker-compose.yml ``` <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› yamllint</summary><blockquote> [error] 67-67: trailing spaces (trailing-spaces) --- [error] 71-71: trailing spaces (trailing-spaces) --- [error] 74-74: trailing spaces (trailing-spaces) --- [error] 80-80: trailing spaces (trailing-spaces) --- [error] 83-83: trailing spaces (trailing-spaces) --- [error] 86-86: trailing spaces (trailing-spaces) --- [error] 90-90: trailing spaces (trailing-spaces) --- [error] 95-95: trailing spaces (trailing-spaces) --- [error] 97-97: no new line character at the end of file (new-line-at-end-of-file) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition + bot: + # Name of the container + container_name: big-bear-gem_digest_bot + + # Docker image to use + image: piero24/gemdigest:latest
_:warning: Potential issue_ **Avoid using 'latest' tag in production** Using the `latest` tag can lead to unexpected behavior and breaks reproducibility. Consider pinning to a specific version. ```diff - image: piero24/gemdigest:latest + image: piero24/gemdigest:1.0.0 # Replace with actual version ``` > Committable suggestion was skipped due to low confidence. <!-- This is an auto-generated reply by CodeRabbit -->
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition + bot: + # Name of the container + container_name: big-bear-gem_digest_bot + + # Docker image to use + image: piero24/gemdigest:latest + + # Build the container from the Dockerfile + build: + # Context points to the current directory + context: . + # Dockerfile location + dockerfile: Dockerfile + + # Mount local directory to the container's /home/dev directory + volumes: + - /DATA/AppData/$AppID/extra_configs:/gem_digest_bot/extra_configs + + # Environment variables with default values + environment: + TELEGRAM_API_KEY: TELEGRAM_API_KEY + GEMINI_API_KEY: GEMINI_API_KEY + # Add more users separating their id with ";" + ADMIN_USER_ID: 123;456 + + + # Container restart policy + restart: unless-stopped + + # Ports mapping between host and container + ports: + # Example: Mapping port 8080 of the host to port 8080 of the container (adjust as needed) + - "3333:8080"
_:hammer_and_wrench: Refactor suggestion_ **Add container health check** Consider adding a health check to ensure the container is running properly: ```diff restart: unless-stopped + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s ports: ``` > Committable suggestion was skipped due to low confidence. <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition + bot: + # Name of the container + container_name: big-bear-gem_digest_bot + + # Docker image to use + image: piero24/gemdigest:latest + + # Build the container from the Dockerfile + build: + # Context points to the current directory + context: . + # Dockerfile location + dockerfile: Dockerfile + + # Mount local directory to the container's /home/dev directory + volumes: + - /DATA/AppData/$AppID/extra_configs:/gem_digest_bot/extra_configs + + # Environment variables with default values + environment: + TELEGRAM_API_KEY: TELEGRAM_API_KEY + GEMINI_API_KEY: GEMINI_API_KEY + # Add more users separating their id with ";" + ADMIN_USER_ID: 123;456 + + + # Container restart policy + restart: unless-stopped + + # Ports mapping between host and container + ports: + # Example: Mapping port 8080 of the host to port 8080 of the container (adjust as needed) + - "3333:8080" + + x-casaos: # CasaOS specific configuration + volumes: + - container: /gem_digest_bot/extra_configs + description: + en_us: "Container Path: /gem_digest_bot/extra_configs" + ports: + - container: "8080" + description: + en_us: "Container Port: 8080" + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + - arm64 + + # Main service of the application + main: big-bear-gem_digest_bot + + description: + # Description in English + en_us: Simplify your reads, amplify your time! πŸ“šβœ¨ GemDigest is a Telegram bot that summarizes articles from any website into bite-sized nuggets, saving you time and energy for what matters most. πŸ“±πŸ‘‹ + + tagline: + # Short description or tagline in English + en_us: Your personal article summarizer + + # Developer's name or identifier + developer: "Armaggheddon" + + # Author of this configuration + author: BigBearCommunity + + # Application category + category: BigBearCasaOS + + # Icon for the application + icon: https://raw.githubusercontent.com/Piero24/GemDigest/refs/heads/main/.github/images/casOS_logo.png + + # Thumbnail image (currently empty) + thumbnail: "" + + title: + # Title in English + en_us: GemDigest Bot + + tips: + custom: Add you `TELEGRAM-API-KEY` and `GEMINI-API-KEY` in settings and the + users `ID` that are considered as admin separated by a ";" if thereare + more then one. for more info visit [GemDigest](https://github.com/Armaggheddon/GemDigest)
_:warning: Potential issue_ **Fix typos and formatting in tips section** There are several typos and formatting issues in the tips section: ```diff - custom: Add you `TELEGRAM-API-KEY` and `GEMINI-API-KEY` in settings and the - users `ID` that are considered as admin separated by a ";" if thereare - more then one. for more info visit [GemDigest](https://github.com/Armaggheddon/GemDigest) + custom: Add your `TELEGRAM-API-KEY` and `GEMINI-API-KEY` in settings and the + users' `ID` that are considered as admin separated by ";" if there are + more than one. For more info visit [GemDigest](https://github.com/Armaggheddon/GemDigest) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion custom: Add your `TELEGRAM-API-KEY` and `GEMINI-API-KEY` in settings and the users' `ID` that are considered as admin separated by ";" if there are more than one. For more info visit [GemDigest](https://github.com/Armaggheddon/GemDigest) ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
dragonfire1119
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition + bot:
Change to: big-bear-gem-digest-bot
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
dragonfire1119
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition + bot: + # Name of the container + container_name: big-bear-gem_digest_bot
Change to: big-bear-gem-digest-bot
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
dragonfire1119
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition + bot: + # Name of the container + container_name: big-bear-gem_digest_bot + + # Docker image to use + image: piero24/gemdigest:latest + + # Build the container from the Dockerfile + build: + # Context points to the current directory + context: . + # Dockerfile location + dockerfile: Dockerfile
Remove the build it's not needed.
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
dragonfire1119
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition + bot: + # Name of the container + container_name: big-bear-gem_digest_bot + + # Docker image to use + image: piero24/gemdigest:latest + + # Build the container from the Dockerfile + build: + # Context points to the current directory + context: . + # Dockerfile location + dockerfile: Dockerfile + + # Mount local directory to the container's /home/dev directory + volumes: + - /DATA/AppData/$AppID/extra_configs:/gem_digest_bot/extra_configs + + # Environment variables with default values + environment: + TELEGRAM_API_KEY: TELEGRAM_API_KEY + GEMINI_API_KEY: GEMINI_API_KEY + # Add more users separating their id with ";" + ADMIN_USER_ID: 123;456 + + + # Container restart policy + restart: unless-stopped + + # Ports mapping between host and container + ports: + # Example: Mapping port 8080 of the host to port 8080 of the container (adjust as needed) + - "3333:8080" + + x-casaos: # CasaOS specific configuration + volumes: + - container: /gem_digest_bot/extra_configs + description: + en_us: "Container Path: /gem_digest_bot/extra_configs" + ports: + - container: "8080" + description: + en_us: "Container Port: 8080" + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + - arm64 + + # Main service of the application + main: big-bear-gem_digest_bot + + description: + # Description in English + en_us: Simplify your reads, amplify your time! πŸ“šβœ¨ GemDigest is a Telegram bot that summarizes articles from any website into bite-sized nuggets, saving you time and energy for what matters most. πŸ“±πŸ‘‹ + + tagline: + # Short description or tagline in English + en_us: Your personal article summarizer + + # Developer's name or identifier + developer: "Armaggheddon" + + # Author of this configuration + author: BigBearCommunity + + # Application category + category: BigBearCasaOS + + # Icon for the application + icon: https://raw.githubusercontent.com/Piero24/GemDigest/refs/heads/main/.github/images/casOS_logo.png
This needs to use a cdn: `https://cdn.jsdelivr.net/gh/`
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
dragonfire1119
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition + bot: + # Name of the container + container_name: big-bear-gem_digest_bot + + # Docker image to use + image: piero24/gemdigest:latest + + # Build the container from the Dockerfile + build: + # Context points to the current directory + context: . + # Dockerfile location + dockerfile: Dockerfile + + # Mount local directory to the container's /home/dev directory + volumes: + - /DATA/AppData/$AppID/extra_configs:/gem_digest_bot/extra_configs + + # Environment variables with default values + environment: + TELEGRAM_API_KEY: TELEGRAM_API_KEY + GEMINI_API_KEY: GEMINI_API_KEY + # Add more users separating their id with ";" + ADMIN_USER_ID: 123;456 + + + # Container restart policy + restart: unless-stopped + + # Ports mapping between host and container + ports: + # Example: Mapping port 8080 of the host to port 8080 of the container (adjust as needed) + - "3333:8080" + + x-casaos: # CasaOS specific configuration + volumes: + - container: /gem_digest_bot/extra_configs + description: + en_us: "Container Path: /gem_digest_bot/extra_configs" + ports: + - container: "8080" + description: + en_us: "Container Port: 8080" + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + - arm64 + + # Main service of the application + main: big-bear-gem_digest_bot
Change to `big-bear-gem-digest-bot`
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
dragonfire1119
@@ -0,0 +1,8 @@ +{ + "id": "GemDigest", + "version": "1.0",
Version has to match what you're using in the Docker Compose image. Which right now is `latest`? You can push a 1.0 tag to the registry and change the docker compose and this.
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
dragonfire1119
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot
Change to: big-bear-gem-digest-bot
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
dragonfire1119
@@ -0,0 +1,97 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem_digest_bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: bot + # The `bot` service definition
Change to: big-bear-gem-digest-bot
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,90 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem-digest-bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: big-bear-gem-digest-bot + # The `big-bear-gem-digest-bot` service definition + big-bear-gem-digest-bot: + # Name of the container + container_name: big-bear-gem-digest-bot + + # Docker image to use + image: piero24/gemdigest:1.0 + + # Mount local directory to the container's /home/dev directory + volumes: + - /DATA/AppData/$AppID/extra_configs:/gem_digest_bot/extra_configs + + # Environment variables with default values + environment: + TELEGRAM_API_KEY: TELEGRAM_API_KEY + GEMINI_API_KEY: GEMINI_API_KEY + # Add more users separating their id with ";" + ADMIN_USER_ID: 123;456 + + + # Container restart policy + restart: unless-stopped + + # Ports mapping between host and container + ports: + # Example: Mapping port 8080 of the host to port 8080 of the container (adjust as needed) + - "3333:8080" + + x-casaos: # CasaOS specific configuration + volumes: + - container: /gem_digest_bot/extra_configs + description: + en_us: "Container Path: /gem_digest_bot/extra_configs" + ports: + - container: "8080" + description: + en_us: "Container Port: 8080" + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + - arm64 + + # Main service of the application + main: big-bear-gem-digest-bot + + description: + # Description in English + en_us: Simplify your reads, amplify your time! πŸ“šβœ¨ GemDigest is a Telegram bot that summarizes articles from any website into bite-sized nuggets, saving you time and energy for what matters most. πŸ“±πŸ‘‹ + + tagline: + # Short description or tagline in English + en_us: Your personal article summarizer + + # Developer's name or identifier + developer: "Armaggheddon" + + # Author of this configuration + author: BigBearCommunity + + # Application category + category: BigBearCasaOS + + # Icon for the application + icon: https://cdn.jsdelivr.net/gh/Piero24/GemDigest/.github/images/casOS_logo.png
_:warning: Potential issue_ **Update icon URL to use CDN** As requested, update the icon URL to use the jsDelivr CDN. ```diff - icon: https://cdn.jsdelivr.net/gh/Piero24/GemDigest/.github/images/casOS_logo.png + icon: https://cdn.jsdelivr.net/gh/bigbeartechworld/big-bear-casaos/Apps/GemDigest/.github/images/casOS_logo.png ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion icon: https://cdn.jsdelivr.net/gh/bigbeartechworld/big-bear-casaos/Apps/GemDigest/.github/images/casOS_logo.png ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,822
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,90 @@ +# Configuration for GemDigest bot setup + +# Name of the gem-digest-bot application +name: big-bear-gem-digest-bot + +# Service definitions for the gem-digest-bot application +services: + # Service name: big-bear-gem-digest-bot + # The `big-bear-gem-digest-bot` service definition + big-bear-gem-digest-bot: + # Name of the container + container_name: big-bear-gem-digest-bot + + # Docker image to use + image: piero24/gemdigest:1.0 + + # Mount local directory to the container's /home/dev directory + volumes: + - /DATA/AppData/$AppID/extra_configs:/gem_digest_bot/extra_configs + + # Environment variables with default values + environment: + TELEGRAM_API_KEY: TELEGRAM_API_KEY + GEMINI_API_KEY: GEMINI_API_KEY + # Add more users separating their id with ";" + ADMIN_USER_ID: 123;456 + + + # Container restart policy + restart: unless-stopped + + # Ports mapping between host and container + ports: + # Example: Mapping port 8080 of the host to port 8080 of the container (adjust as needed) + - "3333:8080" + + x-casaos: # CasaOS specific configuration + volumes: + - container: /gem_digest_bot/extra_configs + description: + en_us: "Container Path: /gem_digest_bot/extra_configs" + ports: + - container: "8080" + description: + en_us: "Container Port: 8080" + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + - arm64 + + # Main service of the application + main: big-bear-gem-digest-bot + + description: + # Description in English + en_us: Simplify your reads, amplify your time! πŸ“šβœ¨ GemDigest is a Telegram bot that summarizes articles from any website into bite-sized nuggets, saving you time and energy for what matters most. πŸ“±πŸ‘‹ + + tagline: + # Short description or tagline in English + en_us: Your personal article summarizer + + # Developer's name or identifier + developer: "Armaggheddon" + + # Author of this configuration + author: BigBearCommunity + + # Application category + category: BigBearCasaOS + + # Icon for the application + icon: https://cdn.jsdelivr.net/gh/Piero24/GemDigest/.github/images/casOS_logo.png + + # Thumbnail image (currently empty) + thumbnail: "" + + title: + # Title in English + en_us: GemDigest Bot + + tips: + custom: Add you `TELEGRAM-API-KEY` and `GEMINI-API-KEY` in settings and the + users `ID` that are considered as admin separated by a ";" if thereare + more then one. for more info visit [GemDigest](https://github.com/Armaggheddon/GemDigest) + + # Port mapping information + port_map: "3333"
_:warning: Potential issue_ **Fix port map inconsistency** The `port_map` value should match the actual port mapping in the service configuration. ```diff - port_map: "3333" + port_map: "8080" ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,574
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,121 @@ +# Configuration for flowise setup + +# Name of the big-bear-flowise application +name: big-bear-flowise + +# Service definitions for the big-bear-flowise application +services: + # Service name: big-bear-flowise + # The `big-bear-flowise` service definition + big-bear-flowise: + # Name of the container + container_name: big-bear-flowise + + # Image to be used for the container specifies the flowise version and source + image: flowiseai/flowise:2.1.1 + + # Container restart policy - restarts the container unless manually stopped + restart: unless-stopped + + # Entrypoint to be used for the container + entrypoint: /bin/sh -c "sleep 3; flowise start" + + # Environment variables to be set in the container for application configuration + environment: + - PORT=8009 + - FLOWISE_USERNAME=bigbear + - FLOWISE_PASSWORD=b0f91e4c-9d4b-4375-bc9b-9b57667ce7ab + - FLOWISE_SECRETKEY_OVERWRITE="true" + - LANGCHAIN_ENDPOINT="" + - LANGCHAIN_API_KEY="" + - LANGCHAIN_PROJECT="" + - LANGCHAIN_TRACING_V2="" + - DISABLE_FLOWISE_TELEMETRY="true" + - DATABASE_PATH=/root/.flowise + - APIKEY_PATH=/root/.flowise + - SECRETKEY_PATH=/root/.flowise/logs + - LOG_PATH=/root/.flowise
_:bulb: Codebase verification_ _:warning: Potential issue_ **Issue Found: Hardcoded Credentials in Docker Compose File** Sensitive information such as `FLOWISE_USERNAME` and `FLOWISE_PASSWORD` are hardcoded directly in the Docker Compose file. This poses a security risk as credentials are exposed in the codebase. **Location:** - `Apps/flowise/docker-compose.yml` lines 26-27 **Recommendation:** Use environment variables or Docker secrets to manage credentials securely. <details> <summary>πŸ”— Analysis chain</summary> **Security concern: Sensitive information in Docker Compose file** Hardcoding sensitive information like `FLOWISE_USERNAME` and `FLOWISE_PASSWORD` directly in the Docker Compose file is a security risk. Consider using environment variables or Docker secrets to manage these credentials more securely. Here's an example of how you could use environment variables: ```yaml environment: - PORT=8009 - FLOWISE_USERNAME=${FLOWISE_USERNAME} - FLOWISE_PASSWORD=${FLOWISE_PASSWORD} # ... other environment variables ... ``` Then, you can set these variables in a `.env` file or through your CI/CD pipeline. Additionally, ensure that the `FLOWISE_SECRETKEY_OVERWRITE` is set to a boolean value: ```diff - - FLOWISE_SECRETKEY_OVERWRITE="true" + - FLOWISE_SECRETKEY_OVERWRITE=true ``` To check for any unintended exposure of these credentials, you can run: </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Check for hardcoded credentials in Docker Compose files grep -n -E '(FLOWISE_USERNAME|FLOWISE_PASSWORD)=' Apps/flowise/docker-compose.yml ``` Length of output: 141 --- Script: ```shell #!/bin/bash # Verify presence of FLOWISE_USERNAME and FLOWISE_PASSWORD in docker-compose.yml grep -n -E '^\s*-\s*(FLOWISE_USERNAME|FLOWISE_PASSWORD)=' Apps/flowise/docker-compose.yml ``` Length of output: 192 </details> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Gitleaks</summary><blockquote> 27-28: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,519
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,8 @@ +{ + "id": "tududi", + "version": "0.20", + "image": "chrisvel/tududi", + "youtube": "", + "docs_link": "", + "big_bear_cosmos_youtube": "" +}
_:hammer_and_wrench: Refactor suggestion_ **Overall, the configuration file structure is good, but consider adding a "schema" field.** The configuration file provides essential metadata for the "tududi" application. To enhance its robustness and self-documentation, consider adding a "schema" field that specifies the expected data types and formats for each field. This can help with validation and provide clear expectations for future updates. Example: ```json { "schema": { "id": "string", "version": "string (semver)", "image": "string (docker image name)", "youtube": "string (url)", "docs_link": "string (url)", "big_bear_cosmos_youtube": "string (url)" }, // ... existing fields ... } ``` This addition would make the configuration more self-explanatory and easier to maintain. <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,519
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,8 @@ +{ + "id": "tududi", + "version": "0.20", + "image": "chrisvel/tududi",
_:bulb: Codebase verification_ **Docker image chrisvel/tududi does not exist on Docker Hub or is not publicly accessible.** - Please verify the Docker image name and ensure it has been pushed to Docker Hub. - If the image is intended to be private, update the access permissions or use an alternative accessible image. <details> <summary>:link: Analysis chain</summary> **Verify the Docker image existence and accessibility.** The Docker image name "chrisvel/tududi" follows the correct naming convention. However, we should verify its existence and accessibility. Run the following script to check if the Docker image exists: </details> <details> <summary>:checkered_flag: Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Verify the existence of the Docker image # Test: Check if the Docker image exists on Docker Hub curl -s -f -L -I https://hub.docker.com/v2/repositories/chrisvel/tududi/tags/latest > /dev/null if [ $? -eq 0 ]; then echo "Docker image chrisvel/tududi exists on Docker Hub." else echo "Docker image chrisvel/tududi does not exist on Docker Hub or is not publicly accessible." fi ``` Length of output: 291 </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,519
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,91 @@ +# Configuration for tudu di setup + +# Name of the big-bear-tududi application +name: big-bear-tududi + +# Service definitions for the big-bear-tududi application +services: + # Service name: big-bear-tududi + # The `big-bear-tududi` service definition + big-bear-tududi: + # Name of the container + container_name: big-bear-tududi + + # Image to be used for the container + image: chrisvel/tududi:0.20 + + # Container restart policy + restart: unless-stopped + + # Environment variables + environment: + - TUDUDI_USER_EMAIL=admin@example.com + - TUDUDI_USER_PASSWORD=2dd25e05-65f4-47d7-a9a6-1a3293c02461 + - TUDUDI_SESSION_SECRET=3337c138d17ac7acefa412e5db0d7ef6540905b198cc28c5bf0d11e48807a71bdfe48d82ed0a0a6eb667c937cbdd1db3e1e6073b3148bff37f73cc6398a39671 + - TUDUDI_INTERNAL_SSL_ENABLED=false + + # Volumes to be mounted to the container + volumes: + # Mounting the tududi database directory + - /DATA/AppData/$AppID/tududi_db:/usr/src/app/tududi_db + + # Ports mapping between host and container + ports: + # Mapping port 9292 of the host to port 9292 of the container + - "9292:9292"
_:hammer_and_wrench: Refactor suggestion_ **Consider using latest tag and secure environment variable handling.** The service definition is well-structured, but there are two points to consider: 1. The image tag is pinned to a specific version (`0.20`). While this ensures reproducibility, it may prevent automatic updates. Consider using the `latest` tag or implementing a strategy to keep the image up-to-date. 2. Sensitive information (email, password, session secret) is directly included in the Docker Compose file. This is a security risk, especially if the file is version-controlled. Consider using environment variables or Docker secrets for sensitive information. For example: ```yaml environment: - TUDUDI_USER_EMAIL=${TUDUDI_USER_EMAIL} - TUDUDI_USER_PASSWORD=${TUDUDI_USER_PASSWORD} - TUDUDI_SESSION_SECRET=${TUDUDI_SESSION_SECRET} - TUDUDI_INTERNAL_SSL_ENABLED=${TUDUDI_INTERNAL_SSL_ENABLED:-false} ``` Then, you can set these variables in a `.env` file (which should be git-ignored) or through your deployment process. <details> <summary>:toolbox: Tools</summary> <details> <summary>Gitleaks</summary><blockquote> 23-24: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 24-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,519
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,91 @@ +# Configuration for tudu di setup + +# Name of the big-bear-tududi application +name: big-bear-tududi + +# Service definitions for the big-bear-tududi application +services: + # Service name: big-bear-tududi + # The `big-bear-tududi` service definition + big-bear-tududi: + # Name of the container + container_name: big-bear-tududi + + # Image to be used for the container + image: chrisvel/tududi:0.20 + + # Container restart policy + restart: unless-stopped + + # Environment variables + environment: + - TUDUDI_USER_EMAIL=admin@example.com + - TUDUDI_USER_PASSWORD=2dd25e05-65f4-47d7-a9a6-1a3293c02461 + - TUDUDI_SESSION_SECRET=3337c138d17ac7acefa412e5db0d7ef6540905b198cc28c5bf0d11e48807a71bdfe48d82ed0a0a6eb667c937cbdd1db3e1e6073b3148bff37f73cc6398a39671 + - TUDUDI_INTERNAL_SSL_ENABLED=false
_:warning: Potential issue_ **Security concern: Sensitive information exposed in Docker Compose file.** The `TUDUDI_USER_PASSWORD` and `TUDUDI_SESSION_SECRET` environment variables contain sensitive information that should not be directly included in the Docker Compose file. This poses a security risk, especially if the file is version-controlled or shared. To address this security concern: 1. Remove the sensitive values from the Docker Compose file. 2. Use environment variables or Docker secrets to provide these values securely. Example: ```yaml environment: - TUDUDI_USER_EMAIL=${TUDUDI_USER_EMAIL} - TUDUDI_USER_PASSWORD=${TUDUDI_USER_PASSWORD} - TUDUDI_SESSION_SECRET=${TUDUDI_SESSION_SECRET} - TUDUDI_INTERNAL_SSL_ENABLED=${TUDUDI_INTERNAL_SSL_ENABLED:-false} ``` Then, provide these values through a secure method such as a `.env` file (which should be git-ignored) or through your deployment process. <details> <summary>:toolbox: Tools</summary> <details> <summary>Gitleaks</summary><blockquote> 23-24: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 24-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,515
bigbeartechworld
coderabbitai[bot]
@@ -124,7 +124,7 @@ services: timeout: 5s retries: 5 volumes: - - ${APP_DATA_DIR}/data/mysql:/var/lib/mysql + - /DATA/AppData/$AppID/data/mysql:/var/lib/mysql
_:bulb: Codebase verification_ **Directory `/DATA/AppData/$AppID/data/mysql` does not exist or is not accessible.** Please ensure that: 1. The `$AppID` variable is correctly set in the CasaOS environment. 2. The `/DATA/AppData/$AppID/data/mysql` directory exists and has appropriate permissions. You may need to create the directory and set the correct permissions. <details> <summary>:link: Analysis chain</summary> **LGTM! This change addresses the undefined volume issue.** The modification from `${APP_DATA_DIR}/data/mysql:/var/lib/mysql` to `/DATA/AppData/$AppID/data/mysql:/var/lib/mysql` resolves the "invalid compose project" error mentioned in the PR objectives. This change replaces the undefined `${APP_DATA_DIR}` variable with a more specific path that follows CasaOS conventions. To ensure this change fully resolves the issue, please verify that: 1. The `$AppID` variable is correctly set in the CasaOS environment. 2. The `/DATA/AppData/$AppID/data/mysql` directory exists or can be created with appropriate permissions. You can use the following command to check if the directory exists and is accessible: </details> <details> <summary>:checkered_flag: Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash echo "Checking MySQL data directory..." if [ -d "/DATA/AppData/$AppID/data/mysql" ]; then echo "Directory exists and is accessible." else echo "Directory does not exist or is not accessible. Please ensure it can be created with appropriate permissions." fi ``` Length of output: 340 </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,515
bigbeartechworld
coderabbitai[bot]
@@ -162,7 +162,7 @@ services: timeout: 5s retries: 5 volumes: - - ${APP_DATA_DIR}/data/redis:/data + - /DATA/AppData/$AppID/data/redis:/data
_:bulb: Codebase verification_ **Redis data directory path is invalid due to unset AppID environment variable.** The `AppID` environment variable is not set, resulting in an invalid Redis data directory path `/DATA/AppData/$AppID/data/redis:/data`. Please ensure that `AppID` is correctly defined in the environment to prevent runtime issues. <details> <summary>:link: Analysis chain</summary> **LGTM! Consistent change for Redis volume.** The modification from `${APP_DATA_DIR}/data/redis:/data` to `/DATA/AppData/$AppID/data/redis:/data` is consistent with the change made for the MySQL service. This ensures that both services use the same convention for data storage paths. To ensure this change is fully implemented, please verify that: 1. The `$AppID` variable is correctly set in the CasaOS environment (same as for MySQL). 2. The `/DATA/AppData/$AppID/data/redis` directory exists or can be created with appropriate permissions. You can use the following command to check if the directory exists and is accessible: </details> <details> <summary>:checkered_flag: Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash echo "Checking Redis data directory..." if [ -d "/DATA/AppData/$AppID/data/redis" ]; then echo "Directory exists and is accessible." else echo "Directory does not exist or is not accessible. Please ensure it can be created with appropriate permissions." fi ``` Length of output: 340 --- Script: ```shell #!/bin/bash echo "Current value of AppID: $AppID" ``` Length of output: 58 --- Script: ```shell #!/bin/bash echo "Listing all environment variables containing 'AppID':" env | grep 'AppID' ``` Length of output: 141 --- Script: ```shell #!/bin/bash echo "Searching the codebase for definitions or usages of 'AppID'..." rg 'AppID' ``` Length of output: 30670 </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,509
bigbeartechworld
coderabbitai[bot]
@@ -4,8 +4,8 @@ name: big-bear-immich # Service definitions for the big-bear-immich application services: # Main Immich Server service configuration - immich-server: - container_name: immich-server # Name of the running container + big-bear-immich-server: + container_name: big-bear-immich-server # Name of the running container
> [!TIP] > Codebase Verification **Found remaining references to `immich-server`. Please update the `main` field to `big-bear-immich-server` for consistency.** <details> <summary>Analysis chain</summary> **LGTM! Verify references to the renamed service.** The renaming of the `immich-server` service to `big-bear-immich-server` is consistent with the PR objectives. The container name already includes the "big-bear-" prefix, which is good. Please run the following script to check for any references to the old service name that might need updating: </details> <details> <summary>Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Check for references to the old service name 'immich-server' # Test: Search for 'immich-server' in the file. Expect: No matches except in comments. rg --type yaml 'immich-server' Apps/immich/docker-compose.yml ``` Length of output: 290 </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,509
bigbeartechworld
coderabbitai[bot]
@@ -64,8 +64,8 @@ services: en_us: "Container Port: 3001" # Configuration for Immich Machine Learning service - immich-machine-learning: - container_name: immich-machine-learning # Name of the running container + big-bear-immich-machine-learning: + container_name: big-bear-immich-machine-learning # Name of the running container
> [!TIP] > Codebase Verification **Issue found with references to the old service name.** The `IMMICH_MACHINE_LEARNING_URL` is still pointing to `immich-machine-learning`. Please update this reference to `big-bear-immich-machine-learning`. <details> <summary>Analysis chain</summary> **LGTM! Verify references to the renamed service.** The renaming of the `immich-machine-learning` service to `big-bear-immich-machine-learning` is consistent with the PR objectives. The container name has been correctly updated to include the "big-bear-" prefix. Please run the following script to check for any references to the old service name that might need updating: </details> <details> <summary>Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Check for references to the old service name 'immich-machine-learning' # Test: Search for 'immich-machine-learning' in the file. Expect: No matches except in comments. rg --type yaml 'immich-machine-learning' Apps/immich/docker-compose.yml ``` Length of output: 448 --- Script: ```shell #!/bin/bash # Description: Check for references to the old service name 'immich-machine-learning', excluding commented lines rg --type yaml 'immich-machine-learning' Apps/immich/docker-compose.yml | grep -v '^\s*#' ``` Length of output: 363 </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,495
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,93 @@ +# Configuration for note-mark-aio setup + +# Name of the big-bear-note-mark-aio application +name: big-bear-note-mark-aio + +# Service definitions for the big-bear-homarr application +services: + # Service name: big-bear-note-mark-aio + # The `big-bear-note-mark-aio` service definition + big-bear-note-mark-aio: + # Name of the container + container_name: big-bear-note-mark-aio + + # Image to be used for the container + image: ghcr.io/enchant97/note-mark-aio:0.13.1 + + # Container restart policy + restart: unless-stopped + + environment: + - JWT_SECRET="MGZiMzlkM2EtNmYxNC00NzNlLWI2YjItYTViY2M0Mzg0NjNl"
**Security Issue: Hardcoded JWT Secret** The `JWT_SECRET` environment variable is set to a hardcoded value, which is a potential security risk. Hardcoding sensitive information like API keys or secrets directly in the configuration file exposes them to unauthorized access and makes it difficult to manage in different environments. Consider the following: - Use a secret management solution like Docker Secrets or Kubernetes Secrets to securely store and manage the JWT secret. - Alternatively, provide the JWT secret through an environment variable that is not version-controlled and can be set differently for each environment. <details> <summary>Tools</summary> <details> <summary>Gitleaks</summary><blockquote> 21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,493
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,112 @@ +# Configuration for komf setup + +# Name of the big-bear-komf application +name: big-bear-komf + +# Service definitions for the big-bear-homarr application +services: + # Service name: big-bear-komf + # The `big-bear-komf` service definition + big-bear-komf: + # Name of the container + container_name: big-bear-komf + + # Image to be used for the container + image: sndxr/komf:1.0.6 + + # Container restart policy + restart: unless-stopped + + environment: + - KOMF_KOMGA_BASE_URI=http://komga:25600 + - KOMF_KOMGA_USER=admin@example.org + - KOMF_KOMGA_PASSWORD=admin + - KOMF_KAVITA_BASE_URI=http://kavita:5000 + - KOMF_KAVITA_API_KEY=cd1edcc1-6010-41a8-a82b-73f501dc2760 + - KOMF_LOG_LEVEL=INFO
**Remove the placeholder API key and provide instructions for secure configuration.** The detected API key in the configuration file appears to be a placeholder value used for demonstration purposes. While it does not pose an immediate security risk, it is a good practice to avoid committing any sensitive information, even placeholder values, to version control. Consider removing the placeholder API key and providing instructions for users to set their own API key securely, such as using environment variables or a separate configuration file that is not committed to version control. <details> <summary>Tools</summary> <details> <summary>Gitleaks</summary><blockquote> 25-26: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,428
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,206 @@ +# Configuration for davis setup + +# Name of the big-bear-davis application +name: big-bear-davis + +# Service definitions for the big-bear-davis application +services: + # Service name: big-bear-davis + # The `big-bear-davis` service definition + big-bear-davis: + # Name of the container + container_name: big-bear-davis + + # Image to be used for the container + image: ghcr.io/tchapi/davis-standalone:4.4.4 + + # Container restart policy + restart: unless-stopped + + # Environment variables to be set in the container + environment: + - APP_ENV=prod + - DATABASE_DRIVER=mysql + - DATABASE_URL=mysql://bigbear:0c9d2acc-d4f3-423c-8361-86f35cdd3eb2@big-bear-davis-mysql:3306/davis?serverVersion=10.6.10&charset=utf8mb4 + - MAILER_DSN=smtp://:@big-bear-davis-mailpit:1025 + - ADMIN_LOGIN=bigbear + - ADMIN_PASSWORD=aa9405b8-426c-41a1-bbc6-2924d8ec7eb3 + - AUTH_REALM= + - AUTH_METHOD= + - CALDAV_ENABLED= + - CARDDAV_ENABLED= + - WEBDAV_ENABLED= + - WEBDAV_TMP_DIR= + - WEBDAV_PUBLIC_DIR= + - WEBDAV_HOMES_DIR= + - INVITE_FROM_ADDRESS= + - APP_TIMEZONE=UTC + + # Ports to be exposed from the container + ports: + - 9000:9000 + + networks: + - big-bear-davis-network + + depends_on: + - big-bear-davis-mysql + - big-bear-davis-mailpit + + x-casaos: # CasaOS specific configuration + envs: + - container: "APP_ENV" + description: + en_us: "APP_ENV" + - container: "DATABASE_DRIVER" + description: + en_us: "DATABASE_DRIVER" + - container: "DATABASE_URL" + description: + en_us: "DATABASE_URL" + - container: "MAILER_DSN" + description: + en_us: "MAILER_DSN" + - container: "ADMIN_LOGIN" + description: + en_us: "ADMIN_LOGIN" + - container: "ADMIN_PASSWORD" + description: + en_us: "ADMIN_PASSWORD" + - container: "AUTH_REALM" + description: + en_us: "AUTH_REALM" + - container: "AUTH_METHOD" + description: + en_us: "AUTH_METHOD" + - container: "CALDAV_ENABLED" + description: + en_us: "CALDAV_ENABLED" + - container: "CARDDAV_ENABLED" + description: + en_us: "CARDDAV_ENABLED" + - container: "WEBDAV_ENABLED" + description: + en_us: "WEBDAV_ENABLED" + - container: "WEBDAV_TMP_DIR" + description: + en_us: "WEBDAV_TMP_DIR" + - container: "WEBDAV_PUBLIC_DIR" + description: + en_us: "WEBDAV_PUBLIC_DIR" + - container: "WEBDAV_HOMES_DIR" + description: + en_us: "WEBDAV_HOMES_DIR" + - container: "INVITE_FROM_ADDRESS" + description: + en_us: "INVITE_FROM_ADDRESS" + - container: "APP_TIMEZONE" + description: + en_us: "APP_TIMEZONE" + ports: + - container: "9000" + description: + en_us: "Container Port: 9000" + + # Service name: big-bear-davis-mailpit + big-bear-davis-mailpit: + container_name: big-bear-davis-mailpit # Container name for the app service + image: axllent/mailpit:v1.20 # Image for the app service + restart: unless-stopped # Restart policy for the container + volumes: # Volumes to mount for the app service + - /DATA/AppData/$AppID/mailpit/data:/data + environment: # Environment variables for the app service + - TZ=UTC + ports: # Ports to expose for the app service + - "8025:8025" + - "1025:1025" + networks: + - big-bear-davis-network + x-casaos: # CasaOS specific configuration + envs: + - container: TZ + description: + en_us: Timezone + volumes: + - container: /data + description: + en_us: "Container Path: /data" + ports: + - container: "8025" + description: + en_us: "Container Port: 8025" + + # Service name: big-bear-mysql + big-bear-davis-mysql: + container_name: big-bear-davis-mysql + image: mariadb:10.6.10 + environment: + - MYSQL_ROOT_PASSWORD=0c9d2acc-d4f3-423c-8361-86f35cdd3eb2 + - MYSQL_DATABASE=davis + - MYSQL_USER=bigbear + - MYSQL_PASSWORD=0c9d2acc-d4f3-423c-8361-86f35cdd3eb2 + volumes: + - /DATA/AppData/$AppID/mysql:/var/lib/mysql + + networks: + - big-bear-davis-network + + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + interval: 10s + retries: 5 + timeout: 5s + + # CasaOS specific configuration + x-casaos: + envs: + - container: "MYSQL_ROOT_PASSWORD" + description: + en_us: "MYSQL_ROOT_PASSWORD" + - container: "MYSQL_DATABASE" + description: + en_us: "MYSQL_DATABASE" + - container: "MYSQL_USER" + description: + en_us: "MYSQL_USER" + - container: "MYSQL_PASSWORD" + description: + en_us: "MYSQL_PASSWORD" + volumes: + - container: /var/lib/mysql + description: + en_us: "MariaDB Data Volume" + +networks: + big-bear-davis-network: + driver: bridge + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + - arm64 + # Main service of the application + main: big-bear-davis + description: + # Description in English + en_us: A simple, fully translatable admin interface for sabre/dav based on Symfony 5 and Bootstrap 5, initially inspired by BaΓ―kal. Provides user edition, calendar creation and sharing, and address book creation. The interface is simple and straightforward, responsive, and provides a light and a dark mode. + tagline: + # Short description or tagline in English + en_us: Davis + # Developer's name or identifier + developer: "tchapi" + # Author of this configuration + author: BigBearTechWorld + # Icon for the application + icon: https://cdn.jsdelivr.net/gh/bigbeartechworld/big-bear-casaos/Apps/davis/logo.png + # Thumbnail image (currently empty) + thumbnail: "" + title: + # Title in English + en_us: Davis + # Application category + category: BigBearCasaOS + # Port mapping information + port_map: "9000"
**Docker compose setup is structured well, with some security and best practice enhancements needed.** The `docker-compose.yml` file properly defines the services required to run the Davis application stack, including the application itself, mail testing, and the database. The services are configured with necessary settings, dependencies, volumes, and health checks, which should allow the application to function correctly. However, there are security concerns due to hardcoded sensitive information like database credentials and admin password. These should be provided securely using Docker secrets or environment files. Additionally, consider the following best practices to enhance the compose setup: - Use specific image versions instead of latest tags for predictable deployments. - Define resource constraints (CPU, memory) for services to optimize resource utilization. - Use a dedicated bridge network for better isolation and service discovery. - Consider enabling TLS for secure communication between services. Overall, the compose file provides a good foundation for the Davis application stack, but it can be improved further with secure secret management and adoption of Docker best practices. <details> <summary>Tools</summary> <details> <summary>Gitleaks</summary><blockquote> 27-28: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 138-139: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 141-142: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
1,428
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,206 @@ +# Configuration for davis setup + +# Name of the big-bear-davis application +name: big-bear-davis + +# Service definitions for the big-bear-davis application +services: + # Service name: big-bear-davis + # The `big-bear-davis` service definition + big-bear-davis: + # Name of the container + container_name: big-bear-davis + + # Image to be used for the container + image: ghcr.io/tchapi/davis-standalone:4.4.4 + + # Container restart policy + restart: unless-stopped + + # Environment variables to be set in the container + environment: + - APP_ENV=prod + - DATABASE_DRIVER=mysql + - DATABASE_URL=mysql://bigbear:0c9d2acc-d4f3-423c-8361-86f35cdd3eb2@big-bear-davis-mysql:3306/davis?serverVersion=10.6.10&charset=utf8mb4 + - MAILER_DSN=smtp://:@big-bear-davis-mailpit:1025 + - ADMIN_LOGIN=bigbear + - ADMIN_PASSWORD=aa9405b8-426c-41a1-bbc6-2924d8ec7eb3
**Avoid hardcoding sensitive information.** The `DATABASE_URL` and `ADMIN_PASSWORD` environment variables contain sensitive information like database credentials and admin password. Hardcoding such information in the Docker compose file is a security risk. Consider using Docker secrets or environment files (ignored by version control) to securely provide sensitive configurations to the service. For example: ```diff - - DATABASE_URL=mysql://bigbear:0c9d2acc-d4f3-423c-8361-86f35cdd3eb2@big-bear-davis-mysql:3306/davis?serverVersion=10.6.10&charset=utf8mb4 + - DATABASE_URL_FILE=/run/secrets/database_url - - ADMIN_PASSWORD=aa9405b8-426c-41a1-bbc6-2924d8ec7eb3 + - ADMIN_PASSWORD_FILE=/run/secrets/admin_password ``` And define the secrets files with sensitive data. > Committable suggestion was skipped due to low confidence. <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
588
bigbeartechworld
coderabbitai[bot]
@@ -142,7 +142,7 @@ If you have a suggestion for an app, please post in the [BigBearCommunity](https
Remove extra blank line to maintain consistency. ```diff - ``` <!-- This is an auto-generated comment by CodeRabbit --> --- <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> > :bangbang: **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. `````suggestion ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
539
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,161 @@ +# Configuration for OpenVPN-AS setup + +# Name of the OpenVPN-AS application +name: big-bear-openvpn-as +version: '1.0' + +# Service definitions for the OpenVPN application +services: + # Service name: app + # The `app` service definition + app: + + # Name of the container + container_name: OpenVPN + + # Image to be used for the container + image: openvpn/openvpn-as:latest + + # Container restart policy + restart: unless-stopped + + # Privileged mode for the container + privileged: true
Running the service in privileged mode can pose significant security risks, such as container escapes and privilege escalation. Consider removing the `privileged: true` setting unless absolutely necessary for the application's functionality. <!-- This is an auto-generated reply by CodeRabbit -->
big-bear-casaos
github_2023
others
539
bigbeartechworld
dragonfire1119
@@ -0,0 +1,161 @@ +# Configuration for OpenVPN-AS setup + +# Name of the OpenVPN-AS application +name: big-bear-openvpn-as +version: '1.0' + +# Service definitions for the OpenVPN application +services: + # Service name: app + # The `app` service definition + app: + + # Name of the container + container_name: OpenVPN + + # Image to be used for the container + image: openvpn/openvpn-as:latest
I would rather this be a version tag like: [2.13.1-d8cdeb9c-Ubuntu22](https://hub.docker.com/layers/openvpn/openvpn-as/2.13.1-d8cdeb9c-Ubuntu22/images/sha256-1525d59f85e92b17e3a0183e23133a27044acea27d9c2f792e2cc2fb8a92ac74?context=explore)
big-bear-casaos
github_2023
others
539
bigbeartechworld
dragonfire1119
@@ -0,0 +1,161 @@ +# Configuration for OpenVPN-AS setup + +# Name of the OpenVPN-AS application +name: big-bear-openvpn-as +version: '1.0' + +# Service definitions for the OpenVPN application +services: + # Service name: app + # The `app` service definition + app: + + # Name of the container + container_name: OpenVPN + + # Image to be used for the container + image: openvpn/openvpn-as:latest + + # Container restart policy + restart: unless-stopped + + # Privileged mode for the container + privileged: true + + # Capabilities to be added to the container + cap_add: + - NET_ADMIN + + # CPU and memory limits for the container + cpu_shares: 90 + + # Command to be executed inside the container + command: [] + + # Resources to be allocated to the container + deploy: + + # Resources to be allocated to the container + resources: + limits: + # CPU limit for the container + memory: 15775M + + # Environment variables for the container + environment: + + - PGID=1000 + + - PUID=1000 + + # Timezone for the container + - TZ=Europe/Rome + + # Hostname for the container + hostname: OpenVPN + + # Labels for the container + labels: + icon: https://static-00.iconduck.com/assets.00/openvpn-icon-512x512-nmf6geqm.png + + # Ports to be exposed by the container + ports: + # Mapping port 943 of the host to port 943 of the container + - "943:943/tcp" + + # Mapping port 443 of the host to port 443 of the container + - "443:443/tcp" + + # Mapping port 1194 of the host to port 1194 of the container + - "1194:1194/udp" + + # Volumes to be mounted to the container + volumes: + # Mounting the local OpenVPN/data directory to /openvpn inside the container + - /DATA/AppData/$AppID/data:/openvpn + + # CasaOS specific configuration + x-casaos: + ports: + - container: "943" + description: + en_us: "Container Port: 943" + + - container: "443" + description: + en_us: "Container Port: 443" + + - container: "1194" + description: + en_us: "Container Port: 1194" + + + volumes: + - container: /openvpn + description: + en_us: "Container Path: /openvpn" + + devices: [] + + network_mode: bridge + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + #- arm64 + + # Author of this configuration + author: BigBearTechWorld
You should put your name or `BigBearCommunity`.
big-bear-casaos
github_2023
others
539
bigbeartechworld
dragonfire1119
@@ -0,0 +1,161 @@ +# Configuration for OpenVPN-AS setup + +# Name of the OpenVPN-AS application +name: big-bear-openvpn-as +version: '1.0' + +# Service definitions for the OpenVPN application +services: + # Service name: app + # The `app` service definition + app:
This should be: `big-bear-openvpn-as`
big-bear-casaos
github_2023
others
539
bigbeartechworld
dragonfire1119
@@ -0,0 +1,161 @@ +# Configuration for OpenVPN-AS setup + +# Name of the OpenVPN-AS application +name: big-bear-openvpn-as +version: '1.0' + +# Service definitions for the OpenVPN application +services: + # Service name: app + # The `app` service definition + app: + + # Name of the container + container_name: OpenVPN
This should be: `big-bear-openvpn-as`
big-bear-casaos
github_2023
others
539
bigbeartechworld
dragonfire1119
@@ -0,0 +1,161 @@ +# Configuration for OpenVPN-AS setup + +# Name of the OpenVPN-AS application +name: big-bear-openvpn-as +version: '1.0' + +# Service definitions for the OpenVPN application +services: + # Service name: app + # The `app` service definition + app: + + # Name of the container + container_name: OpenVPN + + # Image to be used for the container + image: openvpn/openvpn-as:latest + + # Container restart policy + restart: unless-stopped + + # Privileged mode for the container + privileged: true + + # Capabilities to be added to the container + cap_add: + - NET_ADMIN + + # CPU and memory limits for the container + cpu_shares: 90 + + # Command to be executed inside the container + command: [] + + # Resources to be allocated to the container + deploy: + + # Resources to be allocated to the container + resources: + limits: + # CPU limit for the container + memory: 15775M + + # Environment variables for the container + environment: + + - PGID=1000 + + - PUID=1000 + + # Timezone for the container + - TZ=Europe/Rome + + # Hostname for the container + hostname: OpenVPN + + # Labels for the container + labels: + icon: https://static-00.iconduck.com/assets.00/openvpn-icon-512x512-nmf6geqm.png + + # Ports to be exposed by the container + ports: + # Mapping port 943 of the host to port 943 of the container + - "943:943/tcp" + + # Mapping port 443 of the host to port 443 of the container + - "443:443/tcp" + + # Mapping port 1194 of the host to port 1194 of the container + - "1194:1194/udp" + + # Volumes to be mounted to the container + volumes: + # Mounting the local OpenVPN/data directory to /openvpn inside the container + - /DATA/AppData/$AppID/data:/openvpn + + # CasaOS specific configuration + x-casaos: + ports: + - container: "943" + description: + en_us: "Container Port: 943" + + - container: "443" + description: + en_us: "Container Port: 443" + + - container: "1194" + description: + en_us: "Container Port: 1194" + + + volumes: + - container: /openvpn + description: + en_us: "Container Path: /openvpn" + + devices: [] + + network_mode: bridge + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + #- arm64 + + # Author of this configuration + author: BigBearTechWorld + + # Application category + category: BigBearCasaOS + + description: + # Description in English + en_us: OpenVPN is an open-source commercial software that implements virtual + private network (VPN) techniques to create secure point-to-point or + site-to-site connections in routed or bridged configurations and remote + access facilities. + + # Developer's name or identifier + developer: "openvpn" + + # Icon for the application + icon: https://static-00.iconduck.com/assets.00/openvpn-icon-512x512-nmf6geqm.png + + # Application index + index: /admin + + # Application information + is_uncontrolled: false + + # Main service of the application + main: app
Change this to: `big-bear-openvpn-as`
big-bear-casaos
github_2023
others
539
bigbeartechworld
dragonfire1119
@@ -97,6 +97,7 @@ If you have a suggestion for an app, please post in the [BigBearCommunity](https | odoo | odoo | 17 | | [Docs](https://community.bigbeartechworld.com/t/added-odoo-to-bigbearcasaos/1115?u=dragonfire1119) | | onedev | 1dev/server | 10.6.0 | [YouTube Video](https://youtu.be/ps3JLYRB3SA) | | | onlyoffice | onlyoffice/documentserver | 8.0.1 | | | +| openvpn-as | openvpn/openvpn-as | latest | | |
You can remove the README.md change.
big-bear-casaos
github_2023
others
539
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,161 @@ +# Configuration for OpenVPN-AS setup + +# Name of the OpenVPN-AS application +name: big-bear-openvpn-as +version: '1.0' + +# Service definitions for the OpenVPN application +services: + # Service name: app + # The `app` service definition + big-bear-openvpn-as: + + # Name of the container + container_name: big-bear-openvpn-as + + # Image to be used for the container + image: openvpn/openvpn-as:2.13.1-d8cdeb9c-Ubuntu22
> [!TIP] > Codebase Verification The Docker image version specified in the `docker-compose.yml` file (`openvpn/openvpn-as:2.13.1-d8cdeb9c-Ubuntu22`) differs from the recommendation in the README.md, which suggests using the `latest` version. This discrepancy could potentially lead to issues with stability and compatibility if the specific version used is not aligned with the project's requirements. - Please verify whether the specific version `2.13.1-d8cdeb9c-Ubuntu22` has been chosen for reasons of stability or compatibility that are not documented in the README.md. - Consider updating the README.md to reflect any specific version requirements or updating the docker-compose.yml to use the `latest` tag if it aligns better with the project's current needs. <details> <summary>Analysis chain</summary> Confirm the Docker image version aligns with the project's requirements for stability and compatibility. </details> <details> <summary>Scripts Executed</summary> The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify that the Docker image version 'openvpn/openvpn-as:2.13.1-d8cdeb9c-Ubuntu22' aligns with the project's requirements. # Test: Check the Docker image version against the project's documentation on compatible versions. cat README.md | grep 'openvpn/openvpn-as' ``` Length of output: 92 </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
539
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,161 @@ +# Configuration for OpenVPN-AS setup + +# Name of the OpenVPN-AS application +name: big-bear-openvpn-as +version: '1.0' + +# Service definitions for the OpenVPN application +services: + # Service name: app + # The `app` service definition + big-bear-openvpn-as: + + # Name of the container + container_name: big-bear-openvpn-as + + # Image to be used for the container + image: openvpn/openvpn-as:2.13.1-d8cdeb9c-Ubuntu22 + + # Container restart policy + restart: unless-stopped + + # Privileged mode for the container + privileged: true
Running the service in privileged mode can pose significant security risks. Document the necessity of this setting in the project documentation. ```diff # Suggest adding documentation about the need for privileged mode. + # Note: Privileged mode is required for network management and automatic restarts. Ensure security measures are in place to mitigate risks. ``` <!-- This is an auto-generated comment by CodeRabbit --> --- <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> > :bangbang: **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. ```suggestion # Note: Privileged mode is required for network management and automatic restarts. Ensure security measures are in place to mitigate risks. privileged: true ``` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-casaos
github_2023
others
9
bigbeartechworld
dragonfire1119
@@ -0,0 +1,32 @@ +name: rtsp-to-web +services: + rtsp-to-web: + cpu_shares: 90 + command: [] + container_name: RTSPtoWeb + deploy: + resources: + image: cmer/rtsp-to-web + labels: + icon: https://static.vecteezy.com/system/resources/previews/009/882/145/original/video-surveillance-icon-cctv-camera-free-vector.jpg + network_mode: bridge + ports: + - target: 8083 + published: "8083" + protocol: tcp + restart: unless-stopped + volumes: + - type: bind + source: /DATA/AppData/rtsp-to-web + target: /tmp
You would need to add ``` x-casaos: # CasaOS specific configuration volumes: - container: /tmp description: en_us: "Container Path: /tmp" - container: /app/public/icons description: en_us: "Container Path: /app/public/icons" ports: - container: "8083" description: en_us: "Container Port: 8083" ```
big-bear-casaos
github_2023
others
9
bigbeartechworld
dragonfire1119
@@ -0,0 +1,32 @@ +name: rtsp-to-web +services: + rtsp-to-web: + cpu_shares: 90 + command: [] + container_name: RTSPtoWeb + deploy: + resources: + image: cmer/rtsp-to-web + labels: + icon: https://static.vecteezy.com/system/resources/previews/009/882/145/original/video-surveillance-icon-cctv-camera-free-vector.jpg + network_mode: bridge + ports: + - target: 8083 + published: "8083" + protocol: tcp + restart: unless-stopped + volumes: + - type: bind + source: /DATA/AppData/rtsp-to-web + target: /tmp +x-casaos:
Can you look at: https://github.com/bigbeartechworld/big-bear-casaos/blob/8e00ebbee8eb936f1a44f888beea8a26570d06d1/Apps/homarr/docker-compose.yml#L49
big-bear-casaos
github_2023
others
220
bigbeartechworld
dragonfire1119
@@ -0,0 +1,55 @@ +# Configuration for big-bear-minio setup +name: big-bear-minio +# Service definitions for the big-bear-minio application +services: + # Service name: app + app: + image: minio/minio # The Docker image to use (latest version of minio)
I would really like to get away from the latest tags. Might change this to `RELEASE.2024-02-24T17-11-14Z-cpuv1` [RELEASE.2024-02-24T17-11-14Z-cpuv1](https://hub.docker.com/layers/minio/minio/RELEASE.2024-02-24T17-11-14Z-cpuv1/images/sha256-b79445e9179476ac1071a13e6565a6653cd89171c6e379c08ec7195a8a9bc4f5?context=explore)
big-bear-casaos
github_2023
others
220
bigbeartechworld
dragonfire1119
@@ -0,0 +1,55 @@ +# Configuration for big-bear-minio setup +name: big-bear-minio +# Service definitions for the big-bear-minio application +services: + # Service name: app + app: + image: minio/minio # The Docker image to use (latest version of minio) + container_name: minio # Name of the container instance + volumes: + - /DATA/AppData/$AppID:/data # Mounting the project directory inside the container + ports: + - "9010:9000" # Expose minio's port 9000 on the host's port 9010 + - "9011:9001" # Expose minio web console's port 9001 on the host's port 9011 + environment: + MINIO_ROOT_PASSWORD: 'minioadmin' + MINIO_ROOT_USER: 'minioadmin' + restart: unless-stopped # Policy to restart the container if it stops unexpectedly + command: server --console-address ":9001" /data + x-casaos: # CasaOS specific configuration + envs: + - container: MINIO_ROOT_USER + description: + en_us: 'Minio Console User' + - container: MINIO_ROOT_PASSWORD + description: + en_us: 'Minio Console Password' + volumes: + - container: /data + description: + en_us: "Container Path: /data" + ports: + - container: "9002" + description: + en_us: "Container Port: 9002" + +# CasaOS specific configuration +x-casaos: + architectures: # Supported CPU architectures + - amd64 + - arm + - arm64 + main: app # Main service of the application + description: + en_us: A distributed object storage server built for cloud applications and devops. Default credentials 'minioadmin:minioadmin', we recommend that you change these values with 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment variables. # Description in English + tagline: + en_us: An open-source S3 alternative # Short description or tagline in English + developer: "" # Developer's name or identifier
Should be: `minio`
big-bear-casaos
github_2023
others
220
bigbeartechworld
dragonfire1119
@@ -69,6 +69,7 @@ If you have a suggestion for an app, please post in the [BigBearCommunity](https | Mailpit | axllent/mailpit | v1.13 | [YouTube Video](https://youtu.be/2MY3S6csrVw) | | Mealie | hkotel/mealie | v1.2.0 | [YouTube Video](https://youtu.be/S4MfNLV2Uf4) | | | MIND | mrcas/mind | v1.3.3 | | +| Minio | minio/minio | latest | |
The version needs to be updated: `RELEASE.2024-02-24T17-11-14Z`
big-bear-casaos
github_2023
others
73
bigbeartechworld
dragonfire1119
@@ -11,7 +11,7 @@ services: ports: - "3001:3001" # Port 3001 on the host is mapped to port 3001 in the container volumes: - - /:/mnt/host:ro # Mounts the root directory of the host as read-only at /mnt/host in the container + - /DATA/AppData/$AppID:/mnt/host:ro # Mounts the root directory of the host as read-only at /mnt/host in the container
If it's not going to mount the root directory, We should probably change the comment. I want people to be able to learn by looking at the comments.
big-bear-casaos
github_2023
others
66
bigbeartechworld
dragonfire1119
@@ -0,0 +1,101 @@ +# Configuration for kasm setup + +# Name of the big-bear-kasm application +name: big-bear-kasm + +# Service definitions for the big-bear-kasm application +services: + # Service name: app + # The `app` service definition + app: + # Name of the container + container_name: kasm + + # Image to be used for the container + image: lscr.io/linuxserver/kasm:latest + + # Container restart policy + restart: unless-stopped + + # Privilege of the container + privileged: true + + # Uses bridge network mode + network_mode: bridge + + # Volumes to be mounted to the container + volumes: + # Mounting the local kasm/opt directory to /opt inside the container + - /DATA/AppData/kasm/opt:/opt
The volumes should be: ``` /DATA/AppData/$AppID ``` Replace `kasm` with `$AppID`
big-bear-casaos
github_2023
others
66
bigbeartechworld
dragonfire1119
@@ -0,0 +1,101 @@ +# Configuration for kasm setup + +# Name of the big-bear-kasm application +name: big-bear-kasm + +# Service definitions for the big-bear-kasm application +services: + # Service name: app + # The `app` service definition + app: + # Name of the container + container_name: kasm
Container name should be `big-bear-kasm`.
big-bear-casaos
github_2023
others
66
bigbeartechworld
dragonfire1119
@@ -0,0 +1,101 @@ +# Configuration for kasm setup + +# Name of the big-bear-kasm application +name: big-bear-kasm + +# Service definitions for the big-bear-kasm application +services: + # Service name: app + # The `app` service definition + app: + # Name of the container + container_name: kasm + + # Image to be used for the container + image: lscr.io/linuxserver/kasm:latest + + # Container restart policy + restart: unless-stopped + + # Privilege of the container + privileged: true + + # Uses bridge network mode + network_mode: bridge + + # Volumes to be mounted to the container + volumes: + # Mounting the local kasm/opt directory to /opt inside the container + - /DATA/AppData/kasm/opt:/opt + + # Mounting the local kasm/profiles directory to /profiles inside the container + - /DATA/AppData/kasm/profiles:/profiles + + # Mounting the local /dev/input directory to /dev/input inside the container + - /dev/input:/dev/input + + # Mounting the local /run/udev/data directory to /run/udev/data inside the container + - /run/udev/data:/run/udev/data + + # Ports mapping between host and container + ports: + # Mapping port 3000 of the host to port 3000 of the container + - 3000:3000/tcp + + # Mapping port 443 of the host to port 443 of the container + - 443:443/tcp + + # Environment variables + environment: + # Tell Kasm where the port number + - KASM_PORT=443 + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + # - arm64 + + # Main service of the application + main: app + + description: + # Description in English + en_us: The Container Streaming Platform - Streaming containerized apps and desktops to end-users. The Workspaces platform provides enterprise-class orchestration, data loss prevention, and web streaming technology to enable the delivery of containerized workloads to your browser. + + tagline: + # Short description or tagline in English + en_us: Kasm + + # Developer's name or identifier + developer: "Kasm" + + # Author of this configuration + author: BigBearTechWorld
This should be `BigBearCommunity`.
big-bear-casaos
github_2023
others
15
bigbeartechworld
dragonfire1119
@@ -25,6 +25,9 @@ services: # Mounting the local homarr/icons directory to /app/public/icons inside the container - /DATA/AppData/$AppID/icons:/app/public/icons + # Mounting the local homarr/dat directory to /data inside the container + - /homarr/data:/data
This needs to be: ``` - /DATA/AppData/$AppID/data:/data ```
big-bear-casaos
github_2023
others
14
bigbeartechworld
dragonfire1119
@@ -0,0 +1,26 @@ +name: playitgg +services: + playitgg: + image: dysta/playitgg + restart: unless-stopped + privileged: false + volumes: + - type: bind + source: /DATA/AppData/$AppID/secrets + target: /secrets + bind: + create_host_path: true +x-casaos: + architectures: + - amd64 + - arm
The docker hub says the image only support amd64?
big-bear-casaos
github_2023
others
14
bigbeartechworld
dragonfire1119
@@ -0,0 +1,25 @@ +name: playitgg
This should be big-bear-playitgg. So it doesn't interfere with another app store.
big-bear-casaos
github_2023
others
13
bigbeartechworld
dragonfire1119
@@ -0,0 +1,47 @@ +name: jellyseerr +services: + jellyseerr: + cpu_shares: 50 + deploy: + resources: + limits: + memory: 256M + environment: + - LOG_LEVEL=debug + - TZ=$TZ + image: fallenbagel/jellyseerr:1.7.0 + ports: + - mode: ingress + target: 5055 + published: "5055" + protocol: tcp + restart: unless-stopped + volumes: + - type: bind + source: /DATA/AppData/$AppID
This should be: `/DATA/AppData/$AppID/config`
big-bear-casaos
github_2023
others
8
bigbeartechworld
dragonfire1119
@@ -11,50 +11,19 @@ services: image: gladysassistant/gladys:v4 # Docker image to use for the 'app' service restart: always # Container should always restart privileged: true # Grants additional privileges to this container + network_mode: host + container_name: gladys + cgroup: host environment: # Environment variables for the container NODE_ENV: production # Sets the environment to production SQLITE_FILE_PATH: /var/lib/gladysassistant/gladys-production.db # Path to the SQLite database + TZ: Europe/Paris # Timezone + SERVER_PORT: "1080" # Server port for UI volumes: # Mount points from the host to the container - /var/run/docker.sock:/var/run/docker.sock # Docker socket file for Docker within Docker - - /DATA/AppData/$AppID/data:/var/lib/gladysassistant # Persistent storage for Gladys data
In CasaOS you put app data in /DATA/AppData/*
big-bear-casaos
github_2023
others
8
bigbeartechworld
dragonfire1119
@@ -11,50 +11,19 @@ services: image: gladysassistant/gladys:v4 # Docker image to use for the 'app' service restart: always # Container should always restart privileged: true # Grants additional privileges to this container + network_mode: host + container_name: gladys + cgroup: host environment: # Environment variables for the container NODE_ENV: production # Sets the environment to production SQLITE_FILE_PATH: /var/lib/gladysassistant/gladys-production.db # Path to the SQLite database + TZ: Europe/Paris # Timezone + SERVER_PORT: "1080" # Server port for UI volumes: # Mount points from the host to the container - /var/run/docker.sock:/var/run/docker.sock # Docker socket file for Docker within Docker - - /DATA/AppData/$AppID/data:/var/lib/gladysassistant # Persistent storage for Gladys data + - /var/lib/gladysassistant:/var/lib/gladysassistant # Persistent storage for Gladys data - /dev:/dev # Access to host devices - ports: # Port mappings from the host to the container - - "1080:80" # Maps port 80 in the container to port 1080 on the host - - "10443:443" # Maps port 443 in the container to port 10443 on the host - - x-casaos: # CasaOS specific configuration
The x-casaos needs to stay with describing the envs and volumes.
big-bear-casaos
github_2023
others
8
bigbeartechworld
dragonfire1119
@@ -66,22 +66,26 @@ x-casaos: main: app description: # Description in English - en_us: "Gladys Assistant is a program that runs on any Linux machine: a PC running Ubuntu, a Raspberry Pi, a NAS, a VPS, a server..." + en_us: "Gladys Assistant is a modern, privacy-first & open-source home automation software that runs anywhere." + fr_fr: "Gladys Assistant est un logiciel de domotique moderne et respectueux de la vie privΓ©e." tagline: # Short description or tagline in English - en_us: A privacy-first, open-source home assistant + en_us: "A privacy-first, open-source home assistant." + fr_fr: "Le logiciel de domotique open-source qui respecte votre vie privΓ©e." # Developer's name or identifier - developer: "GladysAssistant" + developer: "Gladys Assistant" # Author of this configuration author: BigBearTechWorld # Icon for the application - icon: https://github.com/walkxcode/dashboard-icons/blob/main/png/gladys-assistant.png?raw=true + icon: https://gladysassistant.com/img/external/github-gladys-logo.png # Thumbnail image (currently empty) - thumbnail: "https://gladysassistant.com/img/home/main_screenshot/main_screenshot_en_j5czyj_c_scale,w_2800.png" + thumbnail: https://gladysassistant.com/img/home/main_screenshot/main_screenshot_en_j5czyj_c_scale,w_2526.png + screenshot_link: + - https://gladysassistant.com/img/home/main_screenshot/main_screenshot_en_j5czyj_c_scale,w_2526.png title: # Title in English - en_us: Gladys Assistant + en_us: "Gladys Assistant" # Application category - category: BigBearCasaOS + category: "Home Automation"
This needs to stay BigBearCasaOS.
big-bear-casaos
github_2023
others
8
bigbeartechworld
dragonfire1119
@@ -66,22 +66,26 @@ x-casaos: main: app description: # Description in English - en_us: "Gladys Assistant is a program that runs on any Linux machine: a PC running Ubuntu, a Raspberry Pi, a NAS, a VPS, a server..." + en_us: "Gladys Assistant is a modern, privacy-first & open-source home automation software that runs anywhere." + fr_fr: "Gladys Assistant est un logiciel de domotique moderne et respectueux de la vie privΓ©e." tagline: # Short description or tagline in English - en_us: A privacy-first, open-source home assistant + en_us: "A privacy-first, open-source home assistant." + fr_fr: "Le logiciel de domotique open-source qui respecte votre vie privΓ©e." # Developer's name or identifier - developer: "GladysAssistant" + developer: "Gladys Assistant"
This needs to stay like the org on github: GladysAssistant
big-bear-casaos
github_2023
others
3
bigbeartechworld
dragonfire1119
@@ -0,0 +1,32 @@ +# Configuration for big-bear-actual-server setup +name: big-bear-actual-server +# Service definitions for the big-bear-actual-server application +services: + # Service name: app + app: + image: actualbudget/actual-server:latest # The Docker image to use (latest version of actual-server) + container_name: actual-server # Name of the container instance + volumes: + - /DATA/AppData/$AppID:/data # Mounting the project directory inside the container + ports: + - "5006:5006" # Expose actual-server's port 8080 on the host's port 8080 + restart: unless-stopped # Policy to restart the container if it stops unexpectedly + +# CasaOS specific configuration +x-casaos: + architectures: # Supported CPU architectures + - amd64 + - arm64 + main: app # Main service of the application + description: + en_us: Actual Budget is a super fast and privacy-focused app for managing your finances. At its heart is the well proven and much loved Envelope Budgeting methodology. You own your data and can do whatever you want with it. Featuring multi-device sync, optional end-to-end encryption and so much more. # Description in English + tagline: + en_us: Actual Server # Short description or tagline in English + developer: "" # Developer's name or identifier + author: BigBearTechWorld # Author of this configuration
This would be your name or BigBearCommunity. :)
big-bear-casaos
github_2023
others
3
bigbeartechworld
dragonfire1119
@@ -0,0 +1,32 @@ +# Configuration for big-bear-actual-server setup +name: big-bear-actual-server +# Service definitions for the big-bear-actual-server application +services: + # Service name: app + app: + image: actualbudget/actual-server:latest # The Docker image to use (latest version of actual-server) + container_name: actual-server # Name of the container instance + volumes: + - /DATA/AppData/$AppID:/data # Mounting the project directory inside the container + ports: + - "5006:5006" # Expose actual-server's port 8080 on the host's port 8080
The comment needs to be: ``` Expose actual-server's port 5006 on the host's port 5006 ```
big-bear-casaos
github_2023
others
3,421
bigbeartechworld
dragonfire1119
@@ -0,0 +1,68 @@ +# Configuration for music-assistant setup + +# Name of the big-bear-music-assistant application +name: big-bear-music-assistant + +# Service definitions for the big-bear-music-assistant application +services: + # Service name: music-assistant-server + # The `appserver service definition + music-assistant-server:
Change this to `big-bear-music-assistant-server`
big-bear-casaos
github_2023
others
3,421
bigbeartechworld
dragonfire1119
@@ -0,0 +1,68 @@ +# Configuration for music-assistant setup + +# Name of the big-bear-music-assistant application +name: big-bear-music-assistant + +# Service definitions for the big-bear-music-assistant application +services: + # Service name: music-assistant-server + # The `appserver service definition + music-assistant-server: + # Name of the container + container_name: music-assistant-server
Change this to `big-bear-music-assistant-server`
big-bear-casaos
github_2023
others
3,421
bigbeartechworld
dragonfire1119
@@ -0,0 +1,68 @@ +# Configuration for music-assistant setup + +# Name of the big-bear-music-assistant application +name: big-bear-music-assistant + +# Service definitions for the big-bear-music-assistant application +services: + # Service name: music-assistant-server + # The `appserver service definition + music-assistant-server: + # Name of the container + container_name: music-assistant-server + + # Image to be used for the container + image: ghcr.io/music-assistant/server:2.4.4 + + # Container restart policy + restart: unless-stopped + + # Volumes to be mounted to the container + volumes: + - type: bind + source: /DATA/AppData/$AppID/data + target: /data + + # Network mode for the container + network_mode: host + + # Security options for container runtime + security_opt: + # Allows necessary system calls for full functionality + - apparmor:unconfined + + # Additional container capabilities + cap_add: + # Required for system administration tasks within the container + - SYS_ADMIN + - DAC_READ_SEARCH + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + - arm64 + # Main service of the application + main: music-assistant-server
Change this to `big-bear-music-assistant-server`
big-bear-casaos
github_2023
others
3,421
bigbeartechworld
dragonfire1119
@@ -0,0 +1,68 @@ +# Configuration for music-assistant setup + +# Name of the big-bear-music-assistant application +name: big-bear-music-assistant + +# Service definitions for the big-bear-music-assistant application +services: + # Service name: music-assistant-server + # The `appserver service definition + music-assistant-server: + # Name of the container + container_name: music-assistant-server + + # Image to be used for the container + image: ghcr.io/music-assistant/server:2.4.4 + + # Container restart policy + restart: unless-stopped + + # Volumes to be mounted to the container + volumes: + - type: bind + source: /DATA/AppData/$AppID/data + target: /data + + # Network mode for the container + network_mode: host + + # Security options for container runtime + security_opt: + # Allows necessary system calls for full functionality + - apparmor:unconfined + + # Additional container capabilities + cap_add: + # Required for system administration tasks within the container + - SYS_ADMIN + - DAC_READ_SEARCH + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + - arm64 + # Main service of the application + main: music-assistant-server + description: + # Description in English + en_us: Music Assistant is a music library manager for your offline and online music sources which can easily stream your favourite music to a wide range of supported players and be combined with the power of Home Assistant! + tagline: + # Short description or tagline in English + en_us: Home Automation + # Developer's name or identifier + developer: "music-assistant" + # Author of this configuration + author: BigBearTechWorld
This can be your name or just BigBearCommunity.
big-bear-casaos
github_2023
others
3,421
bigbeartechworld
dragonfire1119
@@ -0,0 +1,68 @@ +# Configuration for music-assistant setup + +# Name of the big-bear-music-assistant application +name: big-bear-music-assistant + +# Service definitions for the big-bear-music-assistant application +services: + # Service name: music-assistant-server + # The `appserver service definition + music-assistant-server: + # Name of the container + container_name: music-assistant-server + + # Image to be used for the container + image: ghcr.io/music-assistant/server:2.4.4 + + # Container restart policy + restart: unless-stopped + + # Volumes to be mounted to the container + volumes: + - type: bind + source: /DATA/AppData/$AppID/data + target: /data + + # Network mode for the container + network_mode: host + + # Security options for container runtime + security_opt: + # Allows necessary system calls for full functionality + - apparmor:unconfined + + # Additional container capabilities + cap_add: + # Required for system administration tasks within the container + - SYS_ADMIN + - DAC_READ_SEARCH + +# CasaOS specific configuration +x-casaos: + # Supported CPU architectures for the application + architectures: + - amd64 + - arm64 + # Main service of the application + main: music-assistant-server + description: + # Description in English + en_us: Music Assistant is a music library manager for your offline and online music sources which can easily stream your favourite music to a wide range of supported players and be combined with the power of Home Assistant! + tagline: + # Short description or tagline in English + en_us: Home Automation + # Developer's name or identifier + developer: "music-assistant" + # Author of this configuration + author: BigBearTechWorld + # Icon for the application + icon: https://avatars.githubusercontent.com/u/71128003
Avatar URLs are not good to use, so I would recommend saving the image in the music-assistant directory as `logo.png` and then `https://cdn.jsdelivr.net/gh/bigbeartechworld/big-bear-casaos/Apps/music-assistant/logo.png`. Also, GitHub has limits without a CDN.
big-bear-casaos
github_2023
others
3,421
bigbeartechworld
dragonfire1119
@@ -0,0 +1,68 @@ +# Configuration for music-assistant setup + +# Name of the big-bear-music-assistant application +name: big-bear-music-assistant + +# Service definitions for the big-bear-music-assistant application +services: + # Service name: big-bear-music-assistant-server + # The `appserver service definition + big-bear-music-assistant-server: + # Name of the container + container_name: big-bear-music-assistant-server + + # Image to be used for the container + image: ghcr.io/music-assistant/server:2.4.4 + + # Container restart policy + restart: unless-stopped + + # Volumes to be mounted to the container + volumes: + - type: bind + source: /DATA/AppData/$AppID/data + target: /data + + # Network mode for the container + network_mode: host + + # Security options for container runtime + security_opt: + # Allows necessary system calls for full functionality + - apparmor:unconfined + + # Additional container capabilities + cap_add: + # Required for system administration tasks within the container + - SYS_ADMIN + - DAC_READ_SEARCH +
You need to add a x-casaos like example: https://github.com/bigbeartechworld/big-bear-casaos/blob/8a14673d644f57f50d7c60a29d7d2eaadb16b3b1/Apps/big-bear-casaos-user-management/docker-compose.yml#L63C5-L94C42
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) + + [[ "$root_login" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} Root SSH login disabled" || \ + print_color "0;31" "${CROSS_MARK} Root SSH login enabled" + + [[ "$password_auth" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} SSH password authentication disabled" || \ + print_color "0;31" "${CROSS_MARK} SSH password authentication enabled" + fi + + # Check failed login attempts + if [ -f "/var/log/auth.log" ]; then + local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) + if [ "$failed_attempts" -gt 0 ]; then + print_color "0;33" "${WARNING_MARK} Found $failed_attempts failed login attempts" + fi + fi + + # Check listening ports + echo "Open ports:" + netstat -tuln | grep LISTEN +} + +check_memory_pressure() { + print_header "Memory Pressure Check" + + # Check swap usage and configuration + local swap_total=$(free -m | awk '/Swap:/ {print $2}') + local swap_used=$(free -m | awk '/Swap:/ {print $3}') + local swappiness=$(cat /proc/sys/vm/swappiness) + + echo "Swap Configuration:" + if [ "$swap_total" -eq 0 ]; then + print_color "0;33" "${WARNING_MARK} No swap space configured" + else + local swap_percent=$((swap_used * 100 / swap_total)) + if [ "$swap_percent" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High swap usage: ${swap_percent}%" + else + print_color "0;32" "${CHECK_MARK} Swap usage: ${swap_percent}%" + fi + fi + echo "Swappiness value: $swappiness" + + # Check memory pressure stats if available + if [ -f "/proc/pressure/memory" ]; then + echo -e "\nMemory Pressure Statistics:" + local pressure=$(cat /proc/pressure/memory)
_:warning: Potential issue_ **Prevent masking return values by separating `pressure` declaration** Declare `pressure` separately from its assignment. Apply this diff to fix the issue: ```diff -local pressure=$(cat /proc/pressure/memory) +local pressure +pressure=$(cat /proc/pressure/memory) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local pressure pressure=$(cat /proc/pressure/memory) ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 579-579: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager)
_:warning: Potential issue_ **Prevent masking return values by separating `time_status` declaration** Separate the declaration and assignment of `time_status`. Apply this diff to fix the issue: ```diff -local time_status=$(timedatectl status --no-pager) +local time_status +time_status=$(timedatectl status --no-pager) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local time_status time_status=$(timedatectl status --no-pager) ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 486-486: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p)
_:warning: Potential issue_ **Separate declaration and assignment of `ntp_peers`** To avoid masking return values, declare `ntp_peers` separately. Apply this diff to fix the issue: ```diff -local ntp_peers=$(ntpq -p) +local ntp_peers +ntp_peers=$(ntpq -p) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local ntp_peers ntp_peers=$(ntpq -p) ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 491-491: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log")
_:warning: Potential issue_ **Avoid masking return values by separating variable declarations** Declare `size` separately from its assignment. Apply this diff to fix the issue: ```diff -local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") +local size +size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local size size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 510-510: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized")
_:warning: Potential issue_ **Separate declaration and assignment of `ntp_status`** Declaring and assigning in one line can mask return values. Declare `ntp_status` separately. Apply this diff to fix the issue: ```diff -local ntp_status=$(timedatectl | grep "NTP synchronized") +local ntp_status +ntp_status=$(timedatectl | grep "NTP synchronized") ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local ntp_status ntp_status=$(timedatectl | grep "NTP synchronized") ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 479-479: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l)
_:warning: Potential issue_ **Improve accuracy when counting zombie processes and avoid masking return value** The current method for counting zombie processes may produce inaccurate results and declaring and assigning `local zombie_count` in the same line can mask the return value of the command. Consider separating the declaration and using a more precise command. Apply this diff to fix the issues: ```diff -local zombie_count=$(ps aux | grep -w Z | wc -l) +local zombie_count +zombie_count=$(ps -eo stat= | grep '^Z' | wc -l) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local zombie_count zombie_count=$(ps -eo stat= | grep '^Z' | wc -l) ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 395-395: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) + + [[ "$root_login" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} Root SSH login disabled" || \ + print_color "0;31" "${CROSS_MARK} Root SSH login enabled" + + [[ "$password_auth" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} SSH password authentication disabled" || \ + print_color "0;31" "${CROSS_MARK} SSH password authentication enabled" + fi + + # Check failed login attempts + if [ -f "/var/log/auth.log" ]; then + local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l)
_:warning: Potential issue_ **Separate declaration and assignment of `failed_attempts`** To prevent masking return values, declare `failed_attempts` separately. Apply this diff to fix the issue: ```diff -local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) +local failed_attempts +failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local failed_attempts failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 544-544: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) + + [[ "$root_login" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} Root SSH login disabled" || \ + print_color "0;31" "${CROSS_MARK} Root SSH login enabled" + + [[ "$password_auth" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} SSH password authentication disabled" || \ + print_color "0;31" "${CROSS_MARK} SSH password authentication enabled" + fi + + # Check failed login attempts + if [ -f "/var/log/auth.log" ]; then + local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) + if [ "$failed_attempts" -gt 0 ]; then + print_color "0;33" "${WARNING_MARK} Found $failed_attempts failed login attempts" + fi + fi + + # Check listening ports + echo "Open ports:" + netstat -tuln | grep LISTEN +} + +check_memory_pressure() { + print_header "Memory Pressure Check" + + # Check swap usage and configuration + local swap_total=$(free -m | awk '/Swap:/ {print $2}') + local swap_used=$(free -m | awk '/Swap:/ {print $3}') + local swappiness=$(cat /proc/sys/vm/swappiness) + + echo "Swap Configuration:" + if [ "$swap_total" -eq 0 ]; then + print_color "0;33" "${WARNING_MARK} No swap space configured" + else + local swap_percent=$((swap_used * 100 / swap_total)) + if [ "$swap_percent" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High swap usage: ${swap_percent}%" + else + print_color "0;32" "${CHECK_MARK} Swap usage: ${swap_percent}%" + fi + fi + echo "Swappiness value: $swappiness" + + # Check memory pressure stats if available + if [ -f "/proc/pressure/memory" ]; then + echo -e "\nMemory Pressure Statistics:" + local pressure=$(cat /proc/pressure/memory) + echo "$pressure" + + # Extract 10 second average and convert to integer + local avg10=$(echo "$pressure" | grep "avg10=" | cut -d= -f2 | cut -d" " -f1 | awk '{printf "%d", $1}') + if (( $(awk "BEGIN {print ($avg10 > 50) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High memory pressure detected" + else + print_color "0;32" "${CHECK_MARK} Normal memory pressure" + fi + fi +} + +check_docker_containers_health() { + print_header "Docker Container Health Check" + + if ! command -v docker &>/dev/null; then + print_color "0;33" "${WARNING_MARK} Docker not installed" + return + fi + + # Get all containers including stopped ones + local containers=$(docker ps -a --format "{{.Names}}") + + for container in $containers; do + echo "Container: $container" + + # Check container status + local status=$(docker inspect --format='{{.State.Status}}' "$container") + local health=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}no health check{{end}}' "$container") + local restarts=$(docker inspect --format='{{.RestartCount}}' "$container") + + # Get resource usage + local cpu=$(docker stats --no-stream --format "{{.CPUPerc}}" "$container") + local mem=$(docker stats --no-stream --format "{{.MemPerc}}" "$container") + + case $status in + "running") + print_color "0;32" "${CHECK_MARK} Status: Running" + ;; + "exited") + print_color "0;31" "${CROSS_MARK} Status: Stopped" + ;; + *) + print_color "0;33" "${WARNING_MARK} Status: $status" + ;; + esac + + echo "Health: $health" + echo "Restart Count: $restarts" + echo "CPU Usage: $cpu" + echo "Memory Usage: $mem" + echo "---" + done +} + +check_system_limits() { + print_header "System Resource Limits Check" + + local max_files=$(ulimit -n) + local max_processes=$(ulimit -u) + + echo "File descriptor limit: $max_files" + echo "Max user processes: $max_processes" + + if [ "$max_files" -lt 65535 ]; then + print_color "0;33" "${WARNING_MARK} Low file descriptor limit" + fi + + if [ "$max_processes" -lt 4096 ]; then + print_color "0;33" "${WARNING_MARK} Low process limit" + fi +} + +generate_health_report() { + print_header "Health Check Summary Report" + + # Initialize arrays for different severity levels + declare -a critical_issues=() + declare -a warnings=() + + # Collect issues from previous checks + if $ERROR_FOUND; then + critical_issues+=("Service log errors detected") + fi + + # Add disk space issues + local disk_usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g')
_:warning: Potential issue_ **Separate declaration and assignment of `disk_usage`** Declaring and assigning `disk_usage` together can mask return values. Apply this diff to fix the issue: ```diff -local disk_usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g') +local disk_usage +disk_usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g') ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local disk_usage disk_usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g') ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 666-666: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) + + [[ "$root_login" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} Root SSH login disabled" || \ + print_color "0;31" "${CROSS_MARK} Root SSH login enabled" + + [[ "$password_auth" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} SSH password authentication disabled" || \ + print_color "0;31" "${CROSS_MARK} SSH password authentication enabled" + fi + + # Check failed login attempts + if [ -f "/var/log/auth.log" ]; then + local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) + if [ "$failed_attempts" -gt 0 ]; then + print_color "0;33" "${WARNING_MARK} Found $failed_attempts failed login attempts" + fi + fi + + # Check listening ports + echo "Open ports:" + netstat -tuln | grep LISTEN +} + +check_memory_pressure() { + print_header "Memory Pressure Check" + + # Check swap usage and configuration + local swap_total=$(free -m | awk '/Swap:/ {print $2}') + local swap_used=$(free -m | awk '/Swap:/ {print $3}') + local swappiness=$(cat /proc/sys/vm/swappiness) + + echo "Swap Configuration:" + if [ "$swap_total" -eq 0 ]; then + print_color "0;33" "${WARNING_MARK} No swap space configured" + else + local swap_percent=$((swap_used * 100 / swap_total)) + if [ "$swap_percent" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High swap usage: ${swap_percent}%" + else + print_color "0;32" "${CHECK_MARK} Swap usage: ${swap_percent}%" + fi + fi + echo "Swappiness value: $swappiness" + + # Check memory pressure stats if available + if [ -f "/proc/pressure/memory" ]; then + echo -e "\nMemory Pressure Statistics:" + local pressure=$(cat /proc/pressure/memory) + echo "$pressure" + + # Extract 10 second average and convert to integer + local avg10=$(echo "$pressure" | grep "avg10=" | cut -d= -f2 | cut -d" " -f1 | awk '{printf "%d", $1}') + if (( $(awk "BEGIN {print ($avg10 > 50) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High memory pressure detected" + else + print_color "0;32" "${CHECK_MARK} Normal memory pressure" + fi + fi +} + +check_docker_containers_health() { + print_header "Docker Container Health Check" + + if ! command -v docker &>/dev/null; then + print_color "0;33" "${WARNING_MARK} Docker not installed" + return + fi + + # Get all containers including stopped ones + local containers=$(docker ps -a --format "{{.Names}}")
_:warning: Potential issue_ **Separate declaration and assignment of `containers`** Declaring and assigning `containers` together can mask return values. Apply this diff to fix the issue: ```diff -local containers=$(docker ps -a --format "{{.Names}}") +local containers +containers=$(docker ps -a --format "{{.Names}}") ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local containers containers=$(docker ps -a --format "{{.Names}}") ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 601-601: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2)
_:warning: Potential issue_ **Separate variable declaration and assignment for `ping_result`** Declaring and assigning `local ping_result` together can mask the return value of the command. Separate them to ensure accurate error handling. Apply this diff to fix the issue: ```diff -local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) +local ping_result +ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local ping_result ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 434-434: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) + + [[ "$root_login" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} Root SSH login disabled" || \ + print_color "0;31" "${CROSS_MARK} Root SSH login enabled" + + [[ "$password_auth" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} SSH password authentication disabled" || \ + print_color "0;31" "${CROSS_MARK} SSH password authentication enabled" + fi + + # Check failed login attempts + if [ -f "/var/log/auth.log" ]; then + local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) + if [ "$failed_attempts" -gt 0 ]; then + print_color "0;33" "${WARNING_MARK} Found $failed_attempts failed login attempts" + fi + fi + + # Check listening ports + echo "Open ports:" + netstat -tuln | grep LISTEN +} + +check_memory_pressure() { + print_header "Memory Pressure Check" + + # Check swap usage and configuration + local swap_total=$(free -m | awk '/Swap:/ {print $2}') + local swap_used=$(free -m | awk '/Swap:/ {print $3}') + local swappiness=$(cat /proc/sys/vm/swappiness) + + echo "Swap Configuration:" + if [ "$swap_total" -eq 0 ]; then + print_color "0;33" "${WARNING_MARK} No swap space configured" + else + local swap_percent=$((swap_used * 100 / swap_total)) + if [ "$swap_percent" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High swap usage: ${swap_percent}%" + else + print_color "0;32" "${CHECK_MARK} Swap usage: ${swap_percent}%" + fi + fi + echo "Swappiness value: $swappiness" + + # Check memory pressure stats if available + if [ -f "/proc/pressure/memory" ]; then + echo -e "\nMemory Pressure Statistics:" + local pressure=$(cat /proc/pressure/memory) + echo "$pressure" + + # Extract 10 second average and convert to integer + local avg10=$(echo "$pressure" | grep "avg10=" | cut -d= -f2 | cut -d" " -f1 | awk '{printf "%d", $1}')
_:warning: Potential issue_ **Separate declaration and assignment of `avg10`** To avoid masking return values, declare `avg10` separately. Apply this diff to fix the issue: ```diff -local avg10=$(echo "$pressure" | grep "avg10=" | cut -d= -f2 | cut -d" " -f1 | awk '{printf "%d", $1}') +local avg10 +avg10=$(echo "$pressure" | grep "avg10=" | cut -d= -f2 | cut -d" " -f1 | awk '{printf "%d", $1}') ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local avg10 avg10=$(echo "$pressure" | grep "avg10=" | cut -d= -f2 | cut -d" " -f1 | awk '{printf "%d", $1}') ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 583-583: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g')
_:warning: Potential issue_ **Prevent masking return values by separating declarations and assignments** Declaring and assigning `fs` and `inode_usage` together can mask command return values. It's recommended to declare variables separately. Apply this diff to fix the issue: ```diff -local fs=$(echo $line | awk '{print $1}') -local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') +local fs +fs=$(echo $line | awk '{print $1}') +local inode_usage +inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local fs fs=$(echo $line | awk '{print $1}') local inode_usage inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 450-450: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 451-451: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) + + [[ "$root_login" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} Root SSH login disabled" || \ + print_color "0;31" "${CROSS_MARK} Root SSH login enabled" + + [[ "$password_auth" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} SSH password authentication disabled" || \ + print_color "0;31" "${CROSS_MARK} SSH password authentication enabled" + fi + + # Check failed login attempts + if [ -f "/var/log/auth.log" ]; then + local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) + if [ "$failed_attempts" -gt 0 ]; then + print_color "0;33" "${WARNING_MARK} Found $failed_attempts failed login attempts" + fi + fi + + # Check listening ports + echo "Open ports:" + netstat -tuln | grep LISTEN +} + +check_memory_pressure() { + print_header "Memory Pressure Check" + + # Check swap usage and configuration + local swap_total=$(free -m | awk '/Swap:/ {print $2}') + local swap_used=$(free -m | awk '/Swap:/ {print $3}') + local swappiness=$(cat /proc/sys/vm/swappiness) + + echo "Swap Configuration:" + if [ "$swap_total" -eq 0 ]; then + print_color "0;33" "${WARNING_MARK} No swap space configured" + else + local swap_percent=$((swap_used * 100 / swap_total)) + if [ "$swap_percent" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High swap usage: ${swap_percent}%" + else + print_color "0;32" "${CHECK_MARK} Swap usage: ${swap_percent}%" + fi + fi + echo "Swappiness value: $swappiness" + + # Check memory pressure stats if available + if [ -f "/proc/pressure/memory" ]; then + echo -e "\nMemory Pressure Statistics:" + local pressure=$(cat /proc/pressure/memory) + echo "$pressure" + + # Extract 10 second average and convert to integer + local avg10=$(echo "$pressure" | grep "avg10=" | cut -d= -f2 | cut -d" " -f1 | awk '{printf "%d", $1}') + if (( $(awk "BEGIN {print ($avg10 > 50) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High memory pressure detected" + else + print_color "0;32" "${CHECK_MARK} Normal memory pressure" + fi + fi +} + +check_docker_containers_health() { + print_header "Docker Container Health Check" + + if ! command -v docker &>/dev/null; then + print_color "0;33" "${WARNING_MARK} Docker not installed" + return + fi + + # Get all containers including stopped ones + local containers=$(docker ps -a --format "{{.Names}}") + + for container in $containers; do + echo "Container: $container" + + # Check container status + local status=$(docker inspect --format='{{.State.Status}}' "$container") + local health=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}no health check{{end}}' "$container") + local restarts=$(docker inspect --format='{{.RestartCount}}' "$container")
_:warning: Potential issue_ **Avoid masking return values by separating variable declarations** Declare `status`, `health`, and `restarts` separately from their assignments. Apply this diff to fix the issue: ```diff -local status=$(docker inspect --format='{{.State.Status}}' "$container") -local health=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}no health check{{end}}' "$container") -local restarts=$(docker inspect --format='{{.RestartCount}}' "$container") +local status +status=$(docker inspect --format='{{.State.Status}}' "$container") +local health +health=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}no health check{{end}}' "$container") +local restarts +restarts=$(docker inspect --format='{{.RestartCount}}' "$container") ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local status status=$(docker inspect --format='{{.State.Status}}' "$container") local health health=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}no health check{{end}}' "$container") local restarts restarts=$(docker inspect --format='{{.RestartCount}}' "$container") ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 607-607: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 608-608: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 609-609: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) + + [[ "$root_login" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} Root SSH login disabled" || \ + print_color "0;31" "${CROSS_MARK} Root SSH login enabled" + + [[ "$password_auth" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} SSH password authentication disabled" || \ + print_color "0;31" "${CROSS_MARK} SSH password authentication enabled" + fi + + # Check failed login attempts + if [ -f "/var/log/auth.log" ]; then + local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) + if [ "$failed_attempts" -gt 0 ]; then + print_color "0;33" "${WARNING_MARK} Found $failed_attempts failed login attempts" + fi + fi + + # Check listening ports + echo "Open ports:" + netstat -tuln | grep LISTEN +} + +check_memory_pressure() { + print_header "Memory Pressure Check" + + # Check swap usage and configuration + local swap_total=$(free -m | awk '/Swap:/ {print $2}') + local swap_used=$(free -m | awk '/Swap:/ {print $3}') + local swappiness=$(cat /proc/sys/vm/swappiness) + + echo "Swap Configuration:" + if [ "$swap_total" -eq 0 ]; then + print_color "0;33" "${WARNING_MARK} No swap space configured" + else + local swap_percent=$((swap_used * 100 / swap_total)) + if [ "$swap_percent" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High swap usage: ${swap_percent}%" + else + print_color "0;32" "${CHECK_MARK} Swap usage: ${swap_percent}%" + fi + fi + echo "Swappiness value: $swappiness" + + # Check memory pressure stats if available + if [ -f "/proc/pressure/memory" ]; then + echo -e "\nMemory Pressure Statistics:" + local pressure=$(cat /proc/pressure/memory) + echo "$pressure" + + # Extract 10 second average and convert to integer + local avg10=$(echo "$pressure" | grep "avg10=" | cut -d= -f2 | cut -d" " -f1 | awk '{printf "%d", $1}') + if (( $(awk "BEGIN {print ($avg10 > 50) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High memory pressure detected" + else + print_color "0;32" "${CHECK_MARK} Normal memory pressure" + fi + fi +} + +check_docker_containers_health() { + print_header "Docker Container Health Check" + + if ! command -v docker &>/dev/null; then + print_color "0;33" "${WARNING_MARK} Docker not installed" + return + fi + + # Get all containers including stopped ones + local containers=$(docker ps -a --format "{{.Names}}") + + for container in $containers; do + echo "Container: $container" + + # Check container status + local status=$(docker inspect --format='{{.State.Status}}' "$container") + local health=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}no health check{{end}}' "$container") + local restarts=$(docker inspect --format='{{.RestartCount}}' "$container") + + # Get resource usage + local cpu=$(docker stats --no-stream --format "{{.CPUPerc}}" "$container") + local mem=$(docker stats --no-stream --format "{{.MemPerc}}" "$container") + + case $status in + "running") + print_color "0;32" "${CHECK_MARK} Status: Running" + ;; + "exited") + print_color "0;31" "${CROSS_MARK} Status: Stopped" + ;; + *) + print_color "0;33" "${WARNING_MARK} Status: $status" + ;; + esac + + echo "Health: $health" + echo "Restart Count: $restarts" + echo "CPU Usage: $cpu" + echo "Memory Usage: $mem" + echo "---" + done +} + +check_system_limits() { + print_header "System Resource Limits Check" + + local max_files=$(ulimit -n) + local max_processes=$(ulimit -u)
_:warning: Potential issue_ **Avoid masking return values by separating declarations** Declare `max_files` and `max_processes` separately from their assignments. Apply this diff to fix the issue: ```diff -local max_files=$(ulimit -n) -local max_processes=$(ulimit -u) +local max_files +max_files=$(ulimit -n) +local max_processes +max_processes=$(ulimit -u) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local max_files max_files=$(ulimit -n) local max_processes max_processes=$(ulimit -u) ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 638-638: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 639-639: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then
_:warning: Potential issue_ **Separate variable declarations from assignments** To avoid masking return values, declare `mount_point` separately from its assignment. Apply this diff to fix the issue: ```diff -local mount_point=$(echo $line | awk '{print $3}') +local mount_point +mount_point=$(echo $line | awk '{print $3}') ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local mount_point mount_point=$(echo $line | awk '{print $3}') if touch "$mount_point"/.test_write 2>/dev/null; then ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 465-465: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) + + [[ "$root_login" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} Root SSH login disabled" || \ + print_color "0;31" "${CROSS_MARK} Root SSH login enabled" + + [[ "$password_auth" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} SSH password authentication disabled" || \ + print_color "0;31" "${CROSS_MARK} SSH password authentication enabled" + fi + + # Check failed login attempts + if [ -f "/var/log/auth.log" ]; then + local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) + if [ "$failed_attempts" -gt 0 ]; then + print_color "0;33" "${WARNING_MARK} Found $failed_attempts failed login attempts" + fi + fi + + # Check listening ports + echo "Open ports:" + netstat -tuln | grep LISTEN +} + +check_memory_pressure() { + print_header "Memory Pressure Check" + + # Check swap usage and configuration + local swap_total=$(free -m | awk '/Swap:/ {print $2}') + local swap_used=$(free -m | awk '/Swap:/ {print $3}') + local swappiness=$(cat /proc/sys/vm/swappiness)
_:warning: Potential issue_ **Separate variable declarations from assignments in swap checks** Declaring and assigning `swap_total`, `swap_used`, and `swappiness` together can mask return values. Apply this diff to fix the issue: ```diff -local swap_total=$(free -m | awk '/Swap:/ {print $2}') -local swap_used=$(free -m | awk '/Swap:/ {print $3}') -local swappiness=$(cat /proc/sys/vm/swappiness) +local swap_total +swap_total=$(free -m | awk '/Swap:/ {print $2}') +local swap_used +swap_used=$(free -m | awk '/Swap:/ {print $3}') +local swappiness +swappiness=$(cat /proc/sys/vm/swappiness) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local swap_total swap_total=$(free -m | awk '/Swap:/ {print $2}') local swap_used swap_used=$(free -m | awk '/Swap:/ {print $3}') local swappiness swappiness=$(cat /proc/sys/vm/swappiness) ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 559-559: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 560-560: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 561-561: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) + + [[ "$root_login" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} Root SSH login disabled" || \ + print_color "0;31" "${CROSS_MARK} Root SSH login enabled" + + [[ "$password_auth" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} SSH password authentication disabled" || \ + print_color "0;31" "${CROSS_MARK} SSH password authentication enabled" + fi + + # Check failed login attempts + if [ -f "/var/log/auth.log" ]; then + local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) + if [ "$failed_attempts" -gt 0 ]; then + print_color "0;33" "${WARNING_MARK} Found $failed_attempts failed login attempts" + fi + fi + + # Check listening ports + echo "Open ports:" + netstat -tuln | grep LISTEN +} + +check_memory_pressure() { + print_header "Memory Pressure Check" + + # Check swap usage and configuration + local swap_total=$(free -m | awk '/Swap:/ {print $2}') + local swap_used=$(free -m | awk '/Swap:/ {print $3}') + local swappiness=$(cat /proc/sys/vm/swappiness) + + echo "Swap Configuration:" + if [ "$swap_total" -eq 0 ]; then + print_color "0;33" "${WARNING_MARK} No swap space configured" + else + local swap_percent=$((swap_used * 100 / swap_total)) + if [ "$swap_percent" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High swap usage: ${swap_percent}%" + else + print_color "0;32" "${CHECK_MARK} Swap usage: ${swap_percent}%" + fi + fi + echo "Swappiness value: $swappiness" + + # Check memory pressure stats if available + if [ -f "/proc/pressure/memory" ]; then + echo -e "\nMemory Pressure Statistics:" + local pressure=$(cat /proc/pressure/memory) + echo "$pressure" + + # Extract 10 second average and convert to integer + local avg10=$(echo "$pressure" | grep "avg10=" | cut -d= -f2 | cut -d" " -f1 | awk '{printf "%d", $1}') + if (( $(awk "BEGIN {print ($avg10 > 50) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High memory pressure detected" + else + print_color "0;32" "${CHECK_MARK} Normal memory pressure" + fi + fi +} + +check_docker_containers_health() { + print_header "Docker Container Health Check" + + if ! command -v docker &>/dev/null; then + print_color "0;33" "${WARNING_MARK} Docker not installed" + return + fi + + # Get all containers including stopped ones + local containers=$(docker ps -a --format "{{.Names}}") + + for container in $containers; do + echo "Container: $container" + + # Check container status + local status=$(docker inspect --format='{{.State.Status}}' "$container") + local health=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}no health check{{end}}' "$container") + local restarts=$(docker inspect --format='{{.RestartCount}}' "$container") + + # Get resource usage + local cpu=$(docker stats --no-stream --format "{{.CPUPerc}}" "$container") + local mem=$(docker stats --no-stream --format "{{.MemPerc}}" "$container") + + case $status in + "running") + print_color "0;32" "${CHECK_MARK} Status: Running" + ;; + "exited") + print_color "0;31" "${CROSS_MARK} Status: Stopped" + ;; + *) + print_color "0;33" "${WARNING_MARK} Status: $status" + ;; + esac + + echo "Health: $health" + echo "Restart Count: $restarts" + echo "CPU Usage: $cpu" + echo "Memory Usage: $mem" + echo "---" + done +} + +check_system_limits() { + print_header "System Resource Limits Check" + + local max_files=$(ulimit -n) + local max_processes=$(ulimit -u) + + echo "File descriptor limit: $max_files" + echo "Max user processes: $max_processes" + + if [ "$max_files" -lt 65535 ]; then + print_color "0;33" "${WARNING_MARK} Low file descriptor limit" + fi + + if [ "$max_processes" -lt 4096 ]; then + print_color "0;33" "${WARNING_MARK} Low process limit" + fi +} + +generate_health_report() { + print_header "Health Check Summary Report" + + # Initialize arrays for different severity levels + declare -a critical_issues=() + declare -a warnings=() + + # Collect issues from previous checks + if $ERROR_FOUND; then + critical_issues+=("Service log errors detected") + fi + + # Add disk space issues + local disk_usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g') + if [ "$disk_usage" -ge 80 ]; then + critical_issues+=("High disk usage: ${disk_usage}%") + fi + + # Add memory pressure issues + local mem_used=$(free -m | awk '/^Mem:/ { print $3 }') + local mem_total=$(free -m | awk '/^Mem:/ { print $2 }')
_:warning: Potential issue_ **Prevent masking return values by separating memory usage declarations** Declare `mem_used` and `mem_total` separately from their assignments. Apply this diff to fix the issue: ```diff -local mem_used=$(free -m | awk '/^Mem:/ { print $3 }') -local mem_total=$(free -m | awk '/^Mem:/ { print $2 }') +local mem_used +mem_used=$(free -m | awk '/^Mem:/ { print $3 }') +local mem_total +mem_total=$(free -m | awk '/^Mem:/ { print $2 }') ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local mem_used mem_used=$(free -m | awk '/^Mem:/ { print $3 }') local mem_total mem_total=$(free -m | awk '/^Mem:/ { print $2 }') ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 672-672: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 673-673: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) + + [[ "$root_login" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} Root SSH login disabled" || \ + print_color "0;31" "${CROSS_MARK} Root SSH login enabled" + + [[ "$password_auth" == *"no"* ]] && \ + print_color "0;32" "${CHECK_MARK} SSH password authentication disabled" || \ + print_color "0;31" "${CROSS_MARK} SSH password authentication enabled" + fi + + # Check failed login attempts + if [ -f "/var/log/auth.log" ]; then + local failed_attempts=$(grep "Failed password" /var/log/auth.log | wc -l) + if [ "$failed_attempts" -gt 0 ]; then + print_color "0;33" "${WARNING_MARK} Found $failed_attempts failed login attempts" + fi + fi + + # Check listening ports + echo "Open ports:" + netstat -tuln | grep LISTEN +} + +check_memory_pressure() { + print_header "Memory Pressure Check" + + # Check swap usage and configuration + local swap_total=$(free -m | awk '/Swap:/ {print $2}') + local swap_used=$(free -m | awk '/Swap:/ {print $3}') + local swappiness=$(cat /proc/sys/vm/swappiness) + + echo "Swap Configuration:" + if [ "$swap_total" -eq 0 ]; then + print_color "0;33" "${WARNING_MARK} No swap space configured" + else + local swap_percent=$((swap_used * 100 / swap_total)) + if [ "$swap_percent" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High swap usage: ${swap_percent}%" + else + print_color "0;32" "${CHECK_MARK} Swap usage: ${swap_percent}%" + fi + fi + echo "Swappiness value: $swappiness" + + # Check memory pressure stats if available + if [ -f "/proc/pressure/memory" ]; then + echo -e "\nMemory Pressure Statistics:" + local pressure=$(cat /proc/pressure/memory) + echo "$pressure" + + # Extract 10 second average and convert to integer + local avg10=$(echo "$pressure" | grep "avg10=" | cut -d= -f2 | cut -d" " -f1 | awk '{printf "%d", $1}') + if (( $(awk "BEGIN {print ($avg10 > 50) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High memory pressure detected" + else + print_color "0;32" "${CHECK_MARK} Normal memory pressure" + fi + fi +} + +check_docker_containers_health() { + print_header "Docker Container Health Check" + + if ! command -v docker &>/dev/null; then + print_color "0;33" "${WARNING_MARK} Docker not installed" + return + fi + + # Get all containers including stopped ones + local containers=$(docker ps -a --format "{{.Names}}") + + for container in $containers; do + echo "Container: $container" + + # Check container status + local status=$(docker inspect --format='{{.State.Status}}' "$container") + local health=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}no health check{{end}}' "$container") + local restarts=$(docker inspect --format='{{.RestartCount}}' "$container") + + # Get resource usage + local cpu=$(docker stats --no-stream --format "{{.CPUPerc}}" "$container") + local mem=$(docker stats --no-stream --format "{{.MemPerc}}" "$container")
_:warning: Potential issue_ **Separate declarations and assignments for resource usage variables** Declaring and assigning `cpu` and `mem` together can mask return values. Apply this diff to fix the issue: ```diff -local cpu=$(docker stats --no-stream --format "{{.CPUPerc}}" "$container") -local mem=$(docker stats --no-stream --format "{{.MemPerc}}" "$container") +local cpu +cpu=$(docker stats --no-stream --format "{{.CPUPerc}}" "$container") +local mem +mem=$(docker stats --no-stream --format "{{.MemPerc}}" "$container") ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local cpu cpu=$(docker stats --no-stream --format "{{.CPUPerc}}" "$container") local mem mem=$(docker stats --no-stream --format "{{.MemPerc}}" "$container") ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 612-612: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 613-613: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}') + + if [[ "$state" == "UP" ]]; then + print_color "0;32" "${CHECK_MARK} Interface $interface is UP" + [[ -n "$speed" ]] && echo "Speed: $speed" + else + print_color "0;31" "${CROSS_MARK} Interface $interface is DOWN" + fi + + if [[ "$errors" != "0" || "$drops" != "0" ]]; then + print_color "0;33" "${WARNING_MARK} $interface has $errors errors and $drops drops" + fi + done +} + +check_network_latency() { + print_header "Network Latency Check" + local targets=("8.8.8.8" "1.1.1.1" "google.com") + + for target in "${targets[@]}"; do + local ping_result=$(ping -c 3 $target 2>/dev/null | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + if [ -n "$ping_result" ]; then + if (( $(awk "BEGIN {print ($ping_result > 100) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High latency to $target: ${ping_result}ms" + else + print_color "0;32" "${CHECK_MARK} Good latency to $target: ${ping_result}ms" + fi + fi + done +} + +check_filesystem_health() { + print_header "File System Health Check" + + # Check inode usage + df -i | grep -v "Filesystem" | while read line; do + local fs=$(echo $line | awk '{print $1}') + local inode_usage=$(echo $line | awk '{print $5}' | sed 's/%//g') + + # Skip if inode usage is not a number + if [[ "$inode_usage" =~ ^[0-9]+$ ]]; then + if [ "$inode_usage" -gt 80 ]; then + print_color "0;31" "${CROSS_MARK} High inode usage on $fs: $inode_usage%" + else + print_color "0;32" "${CHECK_MARK} Inode usage on $fs: $inode_usage%" + fi + fi + done + + # Check mount points + mount | grep -E 'ext4|xfs|btrfs|zfs' | while read line; do + local mount_point=$(echo $line | awk '{print $3}') + if touch "$mount_point"/.test_write 2>/dev/null; then + rm "$mount_point"/.test_write + print_color "0;32" "${CHECK_MARK} Mount point $mount_point is writable" + else + print_color "0;31" "${CROSS_MARK} Mount point $mount_point is not writable" + fi + done +} + +check_time_sync() { + print_header "Time Synchronization Check" + + if command -v timedatectl &>/dev/null; then + local ntp_status=$(timedatectl | grep "NTP synchronized") + if [[ $ntp_status == *"yes"* ]]; then + print_color "0;32" "${CHECK_MARK} NTP is synchronized" + else + print_color "0;31" "${CROSS_MARK} NTP is not synchronized" + fi + + local time_status=$(timedatectl status --no-pager) + echo "System time status:" + echo "$time_status" + else + if command -v ntpq &>/dev/null; then + local ntp_peers=$(ntpq -p) + echo "NTP peers status:" + echo "$ntp_peers" + else + print_color "0;33" "${WARNING_MARK} No time synchronization service found" + fi + fi +} + +check_log_rotation() { + print_header "Log Rotation Check" + + local log_dirs=("/var/log" "/var/log/casaos") + local max_log_size=$((100 * 1024 * 1024)) # 100MB + + for dir in "${log_dirs[@]}"; do + if [ -d "$dir" ]; then + echo "Checking logs in $dir:" + find "$dir" -type f -name "*.log" -o -name "*.gz" | while read log; do + local size=$(stat -f%z "$log" 2>/dev/null || stat -c%s "$log") + if [ "$size" -gt "$max_log_size" ]; then + print_color "0;31" "${CROSS_MARK} Large log file: $log ($(numfmt --to=iec-i --suffix=B $size))" + fi + done + fi + done + + if [ -f "/etc/logrotate.d/casaos" ]; then + print_color "0;32" "${CHECK_MARK} CasaOS log rotation configured" + else + print_color "0;33" "${WARNING_MARK} No CasaOS log rotation configuration found" + fi +} + +check_security_audit() { + print_header "Security Audit Check" + + # Check SSH configuration + if [ -f "/etc/ssh/sshd_config" ]; then + local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) + local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config)
_:warning: Potential issue_ **Separate declarations and assignments in SSH configuration checks** Declaring and assigning `root_login` and `password_auth` together can mask return values. Apply this diff to fix the issue: ```diff -local root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) -local password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) +local root_login +root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) +local password_auth +password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local root_login root_login=$(grep "^PermitRootLogin" /etc/ssh/sshd_config) local password_auth password_auth=$(grep "^PasswordAuthentication" /etc/ssh/sshd_config) ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 530-530: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 531-531: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
18
bigbeartechworld
coderabbitai[bot]
@@ -381,6 +381,325 @@ check_dmesg_errors() { fi } +check_process_resources() { + print_header "Process Resource Check" + + echo "Top 5 CPU consuming processes:" + ps aux --sort=-%cpu | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $3}' + + echo -e "\nTop 5 Memory consuming processes:" + ps aux --sort=-%mem | head -6 | tail -5 | \ + awk '{printf "%-20s %5s%%\n", $11, $4}' + + local zombie_count=$(ps aux | grep -w Z | wc -l) + if [ "$zombie_count" -gt 0 ]; then + print_color "0;31" "${CROSS_MARK} Found $zombie_count zombie processes" + else + print_color "0;32" "${CHECK_MARK} No zombie processes found" + fi +} + +check_network_interfaces() { + print_header "Network Interface Check" + + for interface in $(ip -o link show | awk -F': ' '{print $2}'); do + # Skip loopback + [[ "$interface" == "lo" ]] && continue + + # Check link status + local state=$(ip link show $interface | grep -oP 'state \K\w+') + local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') + local errors=$(ip -s link show $interface | awk '/errors/{print $2}') + local drops=$(ip -s link show $interface | awk '/drops/{print $2}')
_:warning: Potential issue_ **Separate variable declarations from assignments to prevent masking return values** Declaring and assigning variables `state`, `speed`, `errors`, and `drops` in the same lines can mask the return values of the commands. It's best practice to declare variables separately. Apply this diff to fix the issue: ```diff -local state=$(ip link show $interface | grep -oP 'state \K\w+') -local speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') -local errors=$(ip -s link show $interface | awk '/errors/{print $2}') -local drops=$(ip -s link show $interface | awk '/drops/{print $2}') +local state +state=$(ip link show $interface | grep -oP 'state \K\w+') +local speed +speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') +local errors +errors=$(ip -s link show $interface | awk '/errors/{print $2}') +local drops +drops=$(ip -s link show $interface | awk '/drops/{print $2}') ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local state state=$(ip link show $interface | grep -oP 'state \K\w+') local speed speed=$(ethtool $interface 2>/dev/null | grep "Speed:" | awk '{print $2}') local errors errors=$(ip -s link show $interface | awk '/errors/{print $2}') local drops drops=$(ip -s link show $interface | awk '/drops/{print $2}') ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 411-411: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 412-412: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 413-413: Declare and assign separately to avoid masking return values. (SC2155) --- [warning] 414-414: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
19
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,248 @@ +#!/usr/bin/env bash + +# BigBearCasaOS Complete Toolkit - Diagnostics and Fixes +# Run with sudo permissions + +# Set text colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Check if running as root +if [ "$EUID" -ne 0 ]; then + echo -e "${RED}Please run as root (use sudo)${NC}" + exit 1 +fi + +# Function to print header +print_header() { + echo "================================================" + echo "$1" + echo "================================================" + echo +} + +# Function to display menu +show_menu() { + clear + print_header "BigBearCasaOS Toolkit V0.0.1" + + echo "Here are some links:" + echo "https://community.bigbeartechworld.com" + echo "https://github.com/BigBearTechWorld" + echo "" + echo "If you would like to support me, please consider buying me a tea:" + echo "https://ko-fi.com/bigbeartechworld" + echo "" + + echo "====================" + echo "1. Run Diagnostics - Collect system information and logs for troubleshooting" + echo "2. Fix Docker Permissions - Reset directory permissions and ownership for Docker" + echo "3. Fix Docker Overlay2 Issues - Repair storage driver problems and rebuild Docker structure" + echo "4. Full System Reset - Clean reinstall of Docker and CasaOS (Backs up existing data from /var/lib/docker)" + echo "5. Exit - Close the toolkit" + read -p "Enter your choice (1-5): " choice +} + + +# Function to collect diagnostic information +run_diagnostics() { + echo -e "${GREEN}Starting CasaOS diagnostic collection...${NC}" + + # Create output directory + timestamp=$(date +%Y%m%d_%H%M%S) + output_dir="casaos_diagnostics_${timestamp}" + mkdir -p "$output_dir" + + # Function to collect command output + collect_output() { + local cmd="$1" + local output_file="$2" + echo -e "${YELLOW}Collecting: ${cmd}${NC}" + eval "$cmd" > "$output_dir/$output_file" 2>&1 + } + + # Collect System Information + collect_output "uname -a" "system_info.txt" + collect_output "free -h" "memory_info.txt" + collect_output "df -h" "disk_info.txt" + collect_output "docker info" "docker_info.txt" + collect_output "docker ps -a" "docker_containers.txt" + collect_output "docker images" "docker_images.txt" + collect_output "ls -la /var/lib/docker" "docker_directory_structure.txt" + collect_output "systemctl status docker" "docker_service_status.txt" + collect_output "systemctl status casaos" "casaos_service_status.txt" + collect_output "journalctl -u docker --no-pager -n 200" "docker_logs.txt" + collect_output "journalctl -u casaos --no-pager -n 200" "casaos_logs.txt" + + # Compress and cleanup + tar czf "casaos_diagnostics_${timestamp}.tar.gz" "$output_dir" + rm -rf "$output_dir" + + echo -e "${GREEN}Diagnostic collection complete!${NC}" + echo -e "Diagnostic file created: ${YELLOW}casaos_diagnostics_${timestamp}.tar.gz${NC}" +} + +# Function to fix Docker permissions +fix_docker_permissions() { + echo -e "${YELLOW}Fixing Docker permissions...${NC}" + + # Ensure Docker is running + if ! systemctl is-active --quiet docker; then + systemctl start docker + fi + + # Create necessary directories + mkdir -p /var/lib/docker/tmp + chmod 755 /var/lib/docker/tmp + + # Reset permissions + chown -R root:root /var/lib/docker + chmod -R 755 /var/lib/docker + + # Clean up and restart + docker system prune -f + systemctl restart docker + systemctl restart casaos + + echo -e "${GREEN}Docker permissions have been reset!${NC}" +} + +# Function to fix Overlay2 issues +fix_overlay2() { + echo -e "${YELLOW}Fixing Docker overlay2 issues...${NC}" + + # Stop services + systemctl stop docker + systemctl stop casaos + + # Backup existing Docker root + if [ -d "/var/lib/docker" ]; then + mv /var/lib/docker /var/lib/docker.bak.$(date +%Y%m%d_%H%M%S)
_:warning: Potential issue_ **Fix potential word splitting in backup timestamp.** The current implementation might cause issues with word splitting. ```diff - mv /var/lib/docker /var/lib/docker.bak.$(date +%Y%m%d_%H%M%S) + mv /var/lib/docker "/var/lib/docker.bak.$(date +%Y%m%d_%H%M%S)" ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion mv /var/lib/docker "/var/lib/docker.bak.$(date +%Y%m%d_%H%M%S)" ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary> [warning] 122-122: Quote this to prevent word splitting. (SC2046) </details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
19
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,248 @@ +#!/usr/bin/env bash + +# BigBearCasaOS Complete Toolkit - Diagnostics and Fixes +# Run with sudo permissions + +# Set text colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Check if running as root +if [ "$EUID" -ne 0 ]; then + echo -e "${RED}Please run as root (use sudo)${NC}" + exit 1 +fi + +# Function to print header +print_header() { + echo "================================================" + echo "$1" + echo "================================================" + echo +} + +# Function to display menu +show_menu() { + clear + print_header "BigBearCasaOS Toolkit V0.0.1" + + echo "Here are some links:" + echo "https://community.bigbeartechworld.com" + echo "https://github.com/BigBearTechWorld" + echo "" + echo "If you would like to support me, please consider buying me a tea:" + echo "https://ko-fi.com/bigbeartechworld" + echo "" + + echo "====================" + echo "1. Run Diagnostics - Collect system information and logs for troubleshooting" + echo "2. Fix Docker Permissions - Reset directory permissions and ownership for Docker" + echo "3. Fix Docker Overlay2 Issues - Repair storage driver problems and rebuild Docker structure" + echo "4. Full System Reset - Clean reinstall of Docker and CasaOS (Backs up existing data from /var/lib/docker)" + echo "5. Exit - Close the toolkit" + read -p "Enter your choice (1-5): " choice +} + + +# Function to collect diagnostic information +run_diagnostics() { + echo -e "${GREEN}Starting CasaOS diagnostic collection...${NC}" + + # Create output directory + timestamp=$(date +%Y%m%d_%H%M%S) + output_dir="casaos_diagnostics_${timestamp}" + mkdir -p "$output_dir" + + # Function to collect command output + collect_output() { + local cmd="$1" + local output_file="$2" + echo -e "${YELLOW}Collecting: ${cmd}${NC}" + eval "$cmd" > "$output_dir/$output_file" 2>&1 + } + + # Collect System Information + collect_output "uname -a" "system_info.txt" + collect_output "free -h" "memory_info.txt" + collect_output "df -h" "disk_info.txt" + collect_output "docker info" "docker_info.txt" + collect_output "docker ps -a" "docker_containers.txt" + collect_output "docker images" "docker_images.txt" + collect_output "ls -la /var/lib/docker" "docker_directory_structure.txt" + collect_output "systemctl status docker" "docker_service_status.txt" + collect_output "systemctl status casaos" "casaos_service_status.txt" + collect_output "journalctl -u docker --no-pager -n 200" "docker_logs.txt" + collect_output "journalctl -u casaos --no-pager -n 200" "casaos_logs.txt" + + # Compress and cleanup + tar czf "casaos_diagnostics_${timestamp}.tar.gz" "$output_dir" + rm -rf "$output_dir" + + echo -e "${GREEN}Diagnostic collection complete!${NC}" + echo -e "Diagnostic file created: ${YELLOW}casaos_diagnostics_${timestamp}.tar.gz${NC}" +} + +# Function to fix Docker permissions +fix_docker_permissions() { + echo -e "${YELLOW}Fixing Docker permissions...${NC}" + + # Ensure Docker is running + if ! systemctl is-active --quiet docker; then + systemctl start docker + fi + + # Create necessary directories + mkdir -p /var/lib/docker/tmp + chmod 755 /var/lib/docker/tmp + + # Reset permissions + chown -R root:root /var/lib/docker + chmod -R 755 /var/lib/docker + + # Clean up and restart + docker system prune -f + systemctl restart docker + systemctl restart casaos + + echo -e "${GREEN}Docker permissions have been reset!${NC}" +} + +# Function to fix Overlay2 issues +fix_overlay2() { + echo -e "${YELLOW}Fixing Docker overlay2 issues...${NC}" + + # Stop services + systemctl stop docker + systemctl stop casaos + + # Backup existing Docker root + if [ -d "/var/lib/docker" ]; then + mv /var/lib/docker /var/lib/docker.bak.$(date +%Y%m%d_%H%M%S) + fi + + # Create fresh directory structure + mkdir -p /var/lib/docker + mkdir -p /var/lib/docker/overlay2 + mkdir -p /var/lib/docker/overlay2/l + mkdir -p /var/lib/docker/tmp + + # Set permissions + chown -R root:root /var/lib/docker + chmod -R 755 /var/lib/docker + chmod 700 /var/lib/docker/overlay2/l + + # Configure Docker daemon + mkdir -p /etc/docker + cat > /etc/docker/daemon.json <<EOL +{ + "storage-driver": "overlay2", + "storage-opts": [ + "overlay2.override_kernel_check=true" + ] +} +EOL + + # Restart services + systemctl daemon-reload + systemctl start docker + systemctl start casaos + + # Clean up + docker system prune -af --volumes + + echo -e "${GREEN}Overlay2 fix complete!${NC}" +} +# Function for full system reset +full_reset() { + echo -e "${RED}WARNING: This will remove all Docker containers, images, and reset CasaOS settings!${NC}" + read -p "Are you sure you want to continue? (y/N): " confirm + if [[ $confirm == [yY] ]]; then + echo -e "${YELLOW}Performing full system reset...${NC}" + + # Stop services + systemctl stop docker + systemctl stop casaos + + # Backup and clean Docker + timestamp=$(date +%Y%m%d_%H%M%S) + if [ -d "/var/lib/docker" ]; then + mv /var/lib/docker "/var/lib/docker.backup_${timestamp}" + fi + + # Backup CasaOS data + if [ -d "/var/lib/casaos" ]; then + mv /var/lib/casaos "/var/lib/casaos.backup_${timestamp}" + fi + + # Remove Docker configuration + rm -rf /etc/docker + + # Remove CasaOS + curl -fsSL https://get.casaos.io/uninstall | sudo bash + + # Reinstall CasaOS + curl -fsSL https://get.casaos.io | sudo bash + + # Reinstall Docker configuration + mkdir -p /etc/docker + cat > /etc/docker/daemon.json <<EOL +{ + "storage-driver": "overlay2", + "storage-opts": [ + "overlay2.override_kernel_check=true" + ] +} +EOL + + # Create fresh Docker directory structure + mkdir -p /var/lib/docker + mkdir -p /var/lib/docker/overlay2 + mkdir -p /var/lib/docker/overlay2/l + mkdir -p /var/lib/docker/tmp + + # Set permissions + chown -R root:root /var/lib/docker + chmod -R 755 /var/lib/docker + chmod 700 /var/lib/docker/overlay2/l + + # Restart services + systemctl daemon-reload + systemctl start docker + systemctl start casaos + + echo -e "${GREEN}Full system reset complete!${NC}" + else + echo "Reset cancelled." + fi + +}
_:warning: Potential issue_ **Address security concerns in full system reset.** The current implementation has several security risks: 1. Unverified script execution from the internet 2. No checksum verification 3. No network connectivity check 4. No validation of backup success Consider implementing these security measures: ```diff full_reset() { echo -e "${RED}WARNING: This will remove all Docker containers, images, and reset CasaOS settings!${NC}" read -p "Are you sure you want to continue? (y/N): " confirm if [[ $confirm == [yY] ]]; then echo -e "${YELLOW}Performing full system reset...${NC}" + # Check network connectivity + if ! ping -c 1 get.casaos.io >/dev/null 2>&1; then + echo -e "${RED}Error: Cannot reach CasaOS servers${NC}" + return 1 + fi + # Stop services systemctl stop docker systemctl stop casaos # Backup and clean Docker timestamp=$(date +%Y%m%d_%H%M%S) if [ -d "/var/lib/docker" ]; then mv /var/lib/docker "/var/lib/docker.backup_${timestamp}" + # Validate backup + if [ ! -d "/var/lib/docker.backup_${timestamp}" ]; then + echo -e "${RED}Error: Docker backup failed${NC}" + return 1 + fi fi # Backup CasaOS data if [ -d "/var/lib/casaos" ]; then mv /var/lib/casaos "/var/lib/casaos.backup_${timestamp}" + # Validate backup + if [ ! -d "/var/lib/casaos.backup_${timestamp}" ]; then + echo -e "${RED}Error: CasaOS backup failed${NC}" + return 1 + fi fi # Remove Docker configuration rm -rf /etc/docker # Remove CasaOS - curl -fsSL https://get.casaos.io/uninstall | sudo bash + # Download and verify uninstall script + curl -fsSL https://get.casaos.io/uninstall -o /tmp/casaos_uninstall + # TODO: Add checksum verification + chmod +x /tmp/casaos_uninstall + /tmp/casaos_uninstall + rm -f /tmp/casaos_uninstall # Reinstall CasaOS - curl -fsSL https://get.casaos.io | sudo bash + # Download and verify install script + curl -fsSL https://get.casaos.io -o /tmp/casaos_install + # TODO: Add checksum verification + chmod +x /tmp/casaos_install + /tmp/casaos_install + rm -f /tmp/casaos_install ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
19
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,248 @@ +#!/usr/bin/env bash + +# BigBearCasaOS Complete Toolkit - Diagnostics and Fixes +# Run with sudo permissions + +# Set text colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Check if running as root +if [ "$EUID" -ne 0 ]; then + echo -e "${RED}Please run as root (use sudo)${NC}" + exit 1 +fi
_:hammer_and_wrench: Refactor suggestion_ **Add shell safety options and version check.** Consider adding these safety measures at the start of the script: ```diff #!/usr/bin/env bash +# Exit on error, undefined vars, and pipe failures +set -euo pipefail + +# Ensure bash version >= 4 +if ((BASH_VERSINFO[0] < 4)); then + echo "Bash version 4 or higher is required" + exit 1 +fi + # BigBearCasaOS Complete Toolkit - Diagnostics and Fixes ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion #!/usr/bin/env bash # Exit on error, undefined vars, and pipe failures set -euo pipefail # Ensure bash version >= 4 if ((BASH_VERSINFO[0] < 4)); then echo "Bash version 4 or higher is required" exit 1 fi # BigBearCasaOS Complete Toolkit - Diagnostics and Fixes # Run with sudo permissions # Set text colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Check if running as root if [ "$EUID" -ne 0 ]; then echo -e "${RED}Please run as root (use sudo)${NC}" exit 1 fi ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
19
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,248 @@ +#!/usr/bin/env bash + +# BigBearCasaOS Complete Toolkit - Diagnostics and Fixes +# Run with sudo permissions + +# Set text colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Check if running as root +if [ "$EUID" -ne 0 ]; then + echo -e "${RED}Please run as root (use sudo)${NC}" + exit 1 +fi + +# Function to print header +print_header() { + echo "================================================" + echo "$1" + echo "================================================" + echo +} + +# Function to display menu +show_menu() { + clear + print_header "BigBearCasaOS Toolkit V0.0.1" + + echo "Here are some links:" + echo "https://community.bigbeartechworld.com" + echo "https://github.com/BigBearTechWorld" + echo "" + echo "If you would like to support me, please consider buying me a tea:" + echo "https://ko-fi.com/bigbeartechworld" + echo "" + + echo "====================" + echo "1. Run Diagnostics - Collect system information and logs for troubleshooting" + echo "2. Fix Docker Permissions - Reset directory permissions and ownership for Docker" + echo "3. Fix Docker Overlay2 Issues - Repair storage driver problems and rebuild Docker structure" + echo "4. Full System Reset - Clean reinstall of Docker and CasaOS (Backs up existing data from /var/lib/docker)" + echo "5. Exit - Close the toolkit" + read -p "Enter your choice (1-5): " choice +} + + +# Function to collect diagnostic information +run_diagnostics() { + echo -e "${GREEN}Starting CasaOS diagnostic collection...${NC}" + + # Create output directory + timestamp=$(date +%Y%m%d_%H%M%S) + output_dir="casaos_diagnostics_${timestamp}" + mkdir -p "$output_dir" + + # Function to collect command output + collect_output() { + local cmd="$1" + local output_file="$2" + echo -e "${YELLOW}Collecting: ${cmd}${NC}" + eval "$cmd" > "$output_dir/$output_file" 2>&1 + } + + # Collect System Information + collect_output "uname -a" "system_info.txt" + collect_output "free -h" "memory_info.txt" + collect_output "df -h" "disk_info.txt" + collect_output "docker info" "docker_info.txt" + collect_output "docker ps -a" "docker_containers.txt" + collect_output "docker images" "docker_images.txt" + collect_output "ls -la /var/lib/docker" "docker_directory_structure.txt" + collect_output "systemctl status docker" "docker_service_status.txt" + collect_output "systemctl status casaos" "casaos_service_status.txt" + collect_output "journalctl -u docker --no-pager -n 200" "docker_logs.txt" + collect_output "journalctl -u casaos --no-pager -n 200" "casaos_logs.txt" + + # Compress and cleanup + tar czf "casaos_diagnostics_${timestamp}.tar.gz" "$output_dir" + rm -rf "$output_dir" + + echo -e "${GREEN}Diagnostic collection complete!${NC}" + echo -e "Diagnostic file created: ${YELLOW}casaos_diagnostics_${timestamp}.tar.gz${NC}" +} + +# Function to fix Docker permissions +fix_docker_permissions() { + echo -e "${YELLOW}Fixing Docker permissions...${NC}" + + # Ensure Docker is running + if ! systemctl is-active --quiet docker; then + systemctl start docker + fi + + # Create necessary directories + mkdir -p /var/lib/docker/tmp + chmod 755 /var/lib/docker/tmp + + # Reset permissions + chown -R root:root /var/lib/docker + chmod -R 755 /var/lib/docker + + # Clean up and restart + docker system prune -f + systemctl restart docker + systemctl restart casaos + + echo -e "${GREEN}Docker permissions have been reset!${NC}" +}
_:warning: Potential issue_ **Add safety measures to Docker permission fixes.** The current implementation has several potential risks: 1. No backup before permission changes 2. Forced system prune without warning 3. No verification of permission changes Consider implementing these safety measures: ```diff fix_docker_permissions() { echo -e "${YELLOW}Fixing Docker permissions...${NC}" + # Backup permissions + find /var/lib/docker -printf '%m %u %g %p\n' > "/tmp/docker_perms_backup_$(date +%Y%m%d_%H%M%S)" + + # Warn about system prune + echo -e "${RED}WARNING: This will remove all unused containers, networks, and images${NC}" + read -p "Continue with system prune? (y/N): " confirm + [[ $confirm != [yY] ]] && return 1 + # Ensure Docker is running if ! systemctl is-active --quiet docker; then systemctl start docker fi # Create necessary directories mkdir -p /var/lib/docker/tmp chmod 755 /var/lib/docker/tmp # Reset permissions chown -R root:root /var/lib/docker chmod -R 755 /var/lib/docker # Clean up and restart docker system prune -f systemctl restart docker systemctl restart casaos + # Verify permissions + echo -e "${YELLOW}Verifying permissions...${NC}" + find /var/lib/docker -not -user root -o -not -group root 2>/dev/null | grep -q . + if [ $? -eq 0 ]; then + echo -e "${RED}Warning: Some files still have incorrect ownership${NC}" + return 1 + fi + echo -e "${GREEN}Docker permissions have been reset!${NC}" } ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion fix_docker_permissions() { echo -e "${YELLOW}Fixing Docker permissions...${NC}" # Backup permissions find /var/lib/docker -printf '%m %u %g %p\n' > "/tmp/docker_perms_backup_$(date +%Y%m%d_%H%M%S)" # Warn about system prune echo -e "${RED}WARNING: This will remove all unused containers, networks, and images${NC}" read -p "Continue with system prune? (y/N): " confirm [[ $confirm != [yY] ]] && return 1 # Ensure Docker is running if ! systemctl is-active --quiet docker; then systemctl start docker fi # Create necessary directories mkdir -p /var/lib/docker/tmp chmod 755 /var/lib/docker/tmp # Reset permissions chown -R root:root /var/lib/docker chmod -R 755 /var/lib/docker # Clean up and restart docker system prune -f systemctl restart docker systemctl restart casaos # Verify permissions echo -e "${YELLOW}Verifying permissions...${NC}" find /var/lib/docker -not -user root -o -not -group root 2>/dev/null | grep -q . if [ $? -eq 0 ]; then echo -e "${RED}Warning: Some files still have incorrect ownership${NC}" return 1 fi echo -e "${GREEN}Docker permissions have been reset!${NC}" } ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
19
bigbeartechworld
coderabbitai[bot]
@@ -0,0 +1,248 @@ +#!/usr/bin/env bash + +# BigBearCasaOS Complete Toolkit - Diagnostics and Fixes +# Run with sudo permissions + +# Set text colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Check if running as root +if [ "$EUID" -ne 0 ]; then + echo -e "${RED}Please run as root (use sudo)${NC}" + exit 1 +fi + +# Function to print header +print_header() { + echo "================================================" + echo "$1" + echo "================================================" + echo +} + +# Function to display menu +show_menu() { + clear + print_header "BigBearCasaOS Toolkit V0.0.1" + + echo "Here are some links:" + echo "https://community.bigbeartechworld.com" + echo "https://github.com/BigBearTechWorld" + echo "" + echo "If you would like to support me, please consider buying me a tea:" + echo "https://ko-fi.com/bigbeartechworld" + echo "" + + echo "====================" + echo "1. Run Diagnostics - Collect system information and logs for troubleshooting" + echo "2. Fix Docker Permissions - Reset directory permissions and ownership for Docker" + echo "3. Fix Docker Overlay2 Issues - Repair storage driver problems and rebuild Docker structure" + echo "4. Full System Reset - Clean reinstall of Docker and CasaOS (Backs up existing data from /var/lib/docker)" + echo "5. Exit - Close the toolkit" + read -p "Enter your choice (1-5): " choice +} + + +# Function to collect diagnostic information +run_diagnostics() { + echo -e "${GREEN}Starting CasaOS diagnostic collection...${NC}" + + # Create output directory + timestamp=$(date +%Y%m%d_%H%M%S) + output_dir="casaos_diagnostics_${timestamp}" + mkdir -p "$output_dir" + + # Function to collect command output + collect_output() { + local cmd="$1" + local output_file="$2" + echo -e "${YELLOW}Collecting: ${cmd}${NC}" + eval "$cmd" > "$output_dir/$output_file" 2>&1 + } + + # Collect System Information + collect_output "uname -a" "system_info.txt" + collect_output "free -h" "memory_info.txt" + collect_output "df -h" "disk_info.txt" + collect_output "docker info" "docker_info.txt" + collect_output "docker ps -a" "docker_containers.txt" + collect_output "docker images" "docker_images.txt" + collect_output "ls -la /var/lib/docker" "docker_directory_structure.txt" + collect_output "systemctl status docker" "docker_service_status.txt" + collect_output "systemctl status casaos" "casaos_service_status.txt" + collect_output "journalctl -u docker --no-pager -n 200" "docker_logs.txt" + collect_output "journalctl -u casaos --no-pager -n 200" "casaos_logs.txt" + + # Compress and cleanup + tar czf "casaos_diagnostics_${timestamp}.tar.gz" "$output_dir" + rm -rf "$output_dir" + + echo -e "${GREEN}Diagnostic collection complete!${NC}" + echo -e "Diagnostic file created: ${YELLOW}casaos_diagnostics_${timestamp}.tar.gz${NC}" +} + +# Function to fix Docker permissions +fix_docker_permissions() { + echo -e "${YELLOW}Fixing Docker permissions...${NC}" + + # Ensure Docker is running + if ! systemctl is-active --quiet docker; then + systemctl start docker + fi + + # Create necessary directories + mkdir -p /var/lib/docker/tmp + chmod 755 /var/lib/docker/tmp + + # Reset permissions + chown -R root:root /var/lib/docker + chmod -R 755 /var/lib/docker + + # Clean up and restart + docker system prune -f + systemctl restart docker + systemctl restart casaos + + echo -e "${GREEN}Docker permissions have been reset!${NC}" +} + +# Function to fix Overlay2 issues +fix_overlay2() { + echo -e "${YELLOW}Fixing Docker overlay2 issues...${NC}" + + # Stop services + systemctl stop docker + systemctl stop casaos + + # Backup existing Docker root + if [ -d "/var/lib/docker" ]; then + mv /var/lib/docker /var/lib/docker.bak.$(date +%Y%m%d_%H%M%S) + fi + + # Create fresh directory structure + mkdir -p /var/lib/docker + mkdir -p /var/lib/docker/overlay2 + mkdir -p /var/lib/docker/overlay2/l + mkdir -p /var/lib/docker/tmp + + # Set permissions + chown -R root:root /var/lib/docker + chmod -R 755 /var/lib/docker + chmod 700 /var/lib/docker/overlay2/l + + # Configure Docker daemon + mkdir -p /etc/docker + cat > /etc/docker/daemon.json <<EOL +{ + "storage-driver": "overlay2", + "storage-opts": [ + "overlay2.override_kernel_check=true" + ] +} +EOL + + # Restart services + systemctl daemon-reload + systemctl start docker + systemctl start casaos + + # Clean up + docker system prune -af --volumes + + echo -e "${GREEN}Overlay2 fix complete!${NC}" +}
_:hammer_and_wrench: Refactor suggestion_ **Enhance overlay2 fix implementation.** Consider these improvements: 1. Add disk space check before backup 2. Make configuration values configurable 3. Validate overlay2 support ```diff fix_overlay2() { echo -e "${YELLOW}Fixing Docker overlay2 issues...${NC}" + # Check if overlay2 is supported + if ! grep -q overlay /proc/filesystems; then + echo -e "${RED}Error: overlay2 storage driver not supported by kernel${NC}" + return 1 + fi + + # Check available disk space (need at least double the current Docker root size) + docker_size=$(du -sm /var/lib/docker 2>/dev/null | cut -f1) + free_space=$(df -m /var/lib | awk 'NR==2 {print $4}') + if [ "$free_space" -lt "$((docker_size * 2))" ]; then + echo -e "${RED}Error: Insufficient disk space for backup${NC}" + return 1 + fi + # Stop services systemctl stop docker systemctl stop casaos ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion fix_overlay2() { echo -e "${YELLOW}Fixing Docker overlay2 issues...${NC}" # Check if overlay2 is supported if ! grep -q overlay /proc/filesystems; then echo -e "${RED}Error: overlay2 storage driver not supported by kernel${NC}" return 1 fi # Check available disk space (need at least double the current Docker root size) docker_size=$(du -sm /var/lib/docker 2>/dev/null | cut -f1) free_space=$(df -m /var/lib | awk 'NR==2 {print $4}') if [ "$free_space" -lt "$((docker_size * 2))" ]; then echo -e "${RED}Error: Insufficient disk space for backup${NC}" return 1 fi # Stop services systemctl stop docker systemctl stop casaos # Backup existing Docker root if [ -d "/var/lib/docker" ]; then mv /var/lib/docker /var/lib/docker.bak.$(date +%Y%m%d_%H%M%S) fi # Create fresh directory structure mkdir -p /var/lib/docker mkdir -p /var/lib/docker/overlay2 mkdir -p /var/lib/docker/overlay2/l mkdir -p /var/lib/docker/tmp # Set permissions chown -R root:root /var/lib/docker chmod -R 755 /var/lib/docker chmod 700 /var/lib/docker/overlay2/l # Configure Docker daemon mkdir -p /etc/docker cat > /etc/docker/daemon.json <<EOL { "storage-driver": "overlay2", "storage-opts": [ "overlay2.override_kernel_check=true" ] } EOL # Restart services systemctl daemon-reload systemctl start docker systemctl start casaos # Clean up docker system prune -af --volumes echo -e "${GREEN}Overlay2 fix complete!${NC}" } ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary> [warning] 122-122: Quote this to prevent word splitting. (SC2046) </details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
14
bigbeartechworld
coderabbitai[bot]
@@ -326,18 +326,43 @@ check_docker_ports() { echo " You can do this by running 'sudo ufw status verbose'" } -# Check for sudo privileges -if [ "$EUID" -ne 0 ]; then - print_color "0;33" "${WARNING_MARK} This script may require sudo privileges for full functionality." - echo "Some checks might fail or provide incomplete information without sudo." - echo "Consider running the script with sudo if you encounter permission-related issues." - echo - read -p "Do you want to continue without sudo? (y/N) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo "Exiting. Please run the script again with sudo." - exit 1 +check_root_privileges() { + if [ "$EUID" -ne 0 ]; then + print_color "0;33" "${WARNING_MARK} This script requires root privileges for full functionality." + echo "Some checks might fail or provide incomplete information without root access." + echo "Consider running the script with sudo if you encounter permission-related issues." + echo + read -p "Do you want to continue without root privileges? (y/N) " -n 1 -r + echo + REPLY=${REPLY,,} # convert to lowercase + if [[ $REPLY != "y" ]]; then + echo "Exiting. Please run the script again with sudo." + exit 1 + fi + fi +} + +check_sudo_privileges() { + if ! sudo -n true 2>/dev/null; then + print_color "0;33" "${WARNING_MARK} You are running as root, but might not have full sudo privileges." + echo "Some checks might still fail or provide incomplete information." + echo + read -p "Do you want to continue? (y/N) " -n 1 -r + echo + REPLY=${REPLY,,} # convert to lowercase + if [[ $REPLY != "y" ]]; then + echo "Exiting. Please ensure you have full sudo privileges and run the script again." + exit 1 + fi fi +}
_:warning: Potential issue_ **Unnecessary sudo privilege check when running as root** The `check_sudo_privileges` function is called when the script is running as root (`EUID=0`). However, since the root user inherently has all privileges, checking for sudo access is redundant. Additionally, root may not have sudo configured, which can lead to unexpected errors. Consider modifying the logic to check for sudo privileges when the script is **not** run as root (`EUIDβ‰ 0`). Apply this diff to adjust the logic: ```diff # If running as root, optionally check for sudo -if [ "$EUID" -eq 0 ]; then +if [ "$EUID" -ne 0 ]; then check_sudo_privileges fi ``` This change ensures that `check_sudo_privileges` is called only when the script is executed by a non-root user. > Committable suggestion was skipped due to low confidence. --- _:hammer_and_wrench: Refactor suggestion_ **Improve sudo privileges check to handle password prompts** The `check_sudo_privileges` function uses `sudo -n true` to check for sudo access without a password prompt. If the user doesn't have passwordless sudo configured, this check will fail even if they have sudo access, causing potential confusion. Consider modifying the sudo check to handle scenarios where a password is required or to provide clearer guidance to the user. You might adjust the function as follows: ```diff if ! sudo -l &>/dev/null; then print_color "0;33" "${WARNING_MARK} You might not have sudo privileges." echo "Some checks might fail or provide incomplete information." echo read -p "Do you want to continue? (y/N) " -n 1 -r echo REPLY=${REPLY,,} # convert to lowercase if [[ $REPLY != "y" ]]; then echo "Exiting. Please ensure you have sudo privileges and run the script again." exit 1 fi fi ``` This modification uses `sudo -l` to check if the user can execute sudo commands, accommodating situations where a password may be required. <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion check_sudo_privileges() { if ! sudo -l &>/dev/null; then print_color "0;33" "${WARNING_MARK} You might not have sudo privileges." echo "Some checks might fail or provide incomplete information." echo read -p "Do you want to continue? (y/N) " -n 1 -r echo REPLY=${REPLY,,} # convert to lowercase if [[ $REPLY != "y" ]]; then echo "Exiting. Please ensure you have sudo privileges and run the script again." exit 1 fi fi } ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
11
bigbeartechworld
coderabbitai[bot]
@@ -287,6 +287,45 @@ check_system_updates() { fi } +check_docker_ports() { + print_header "Docker Container Port Check" + + # Check if Docker is installed and running + if ! command -v docker &> /dev/null || ! docker info &> /dev/null; then + print_color "0;33" "${WARNING_MARK} Docker is not installed or not running. Skipping Docker port check." + return + fi + + # Check if UFW is installed and active + if ! command -v ufw &> /dev/null || ! ufw status | grep -q "Status: active"; then + print_color "0;33" "${WARNING_MARK} UFW is not installed or not active. Skipping firewall check for Docker ports." + return + fi + + # Get UFW rules + ufw_rules=$(sudo ufw status | grep -E '^[0-9]+' | awk '{print $1}') + + # Get all running Docker containers + containers=$(docker ps --format "{{.Names}}") + + for container in $containers; do + # Get port mappings for each container + ports=$(docker port $container | awk '{print $3}' | cut -d ':' -f2) + + for port in $ports; do + if echo "$ufw_rules" | grep -q "^$port$"; then
_:warning: Potential issue_ **Improve parsing of Docker port mappings** The current method of extracting port numbers may fail if the output format varies or if containers have multiple port mappings. The command assumes a specific output format. Consider using a more robust parsing method: ```diff - ports=$(docker port $container | awk '{print $3}' | cut -d ':' -f2) + ports=$(docker port $container | awk -F'[: ]+' '/->/ {print $NF}') ``` This change handles different output formats and more reliably extracts the port numbers. <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion ports=$(docker port $container | awk -F'[: ]+' '/->/ {print $NF}') for port in $ports; do if echo "$ufw_rules" | grep -q "^$port$"; then ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
11
bigbeartechworld
coderabbitai[bot]
@@ -287,6 +287,45 @@ check_system_updates() { fi } +check_docker_ports() { + print_header "Docker Container Port Check" + + # Check if Docker is installed and running + if ! command -v docker &> /dev/null || ! docker info &> /dev/null; then + print_color "0;33" "${WARNING_MARK} Docker is not installed or not running. Skipping Docker port check." + return + fi + + # Check if UFW is installed and active + if ! command -v ufw &> /dev/null || ! ufw status | grep -q "Status: active"; then + print_color "0;33" "${WARNING_MARK} UFW is not installed or not active. Skipping firewall check for Docker ports." + return + fi + + # Get UFW rules + ufw_rules=$(sudo ufw status | grep -E '^[0-9]+' | awk '{print $1}') + + # Get all running Docker containers + containers=$(docker ps --format "{{.Names}}") + + for container in $containers; do + # Get port mappings for each container + ports=$(docker port $container | awk '{print $3}' | cut -d ':' -f2) + + for port in $ports; do + if echo "$ufw_rules" | grep -q "^$port$"; then + print_color "0;32" "${CHECK_MARK} Port $port for container $container is allowed by UFW." + else + print_color "0;31" "${CROSS_MARK} Port $port for container $container might be blocked by UFW." + fi + done + done
_:warning: Potential issue_ **Handle containers with no port mappings gracefully** If a container has no port mappings, the variable `ports` may be empty, which could cause issues in the subsequent loop. Add a check to handle containers without port mappings: ```diff for container in $containers; do # Get port mappings for each container ports=$(docker port $container | awk -F'[: ]+' '/->/ {print $NF}') + if [ -z "$ports" ]; then + print_color "0;33" "${WARNING_MARK} Container $container has no port mappings." + continue + fi for port in $ports; do ``` > Committable suggestion was skipped due to low confidence. <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
11
bigbeartechworld
coderabbitai[bot]
@@ -287,6 +287,45 @@ check_system_updates() { fi } +check_docker_ports() { + print_header "Docker Container Port Check" + + # Check if Docker is installed and running + if ! command -v docker &> /dev/null || ! docker info &> /dev/null; then + print_color "0;33" "${WARNING_MARK} Docker is not installed or not running. Skipping Docker port check." + return + fi + + # Check if UFW is installed and active + if ! command -v ufw &> /dev/null || ! ufw status | grep -q "Status: active"; then + print_color "0;33" "${WARNING_MARK} UFW is not installed or not active. Skipping firewall check for Docker ports." + return + fi + + # Get UFW rules + ufw_rules=$(sudo ufw status | grep -E '^[0-9]+' | awk '{print $1}') + + # Get all running Docker containers + containers=$(docker ps --format "{{.Names}}") + + for container in $containers; do + # Get port mappings for each container + ports=$(docker port $container | awk '{print $3}' | cut -d ':' -f2) + + for port in $ports; do + if echo "$ufw_rules" | grep -q "^$port$"; then + print_color "0;32" "${CHECK_MARK} Port $port for container $container is allowed by UFW." + else + print_color "0;31" "${CROSS_MARK} Port $port for container $container might be blocked by UFW." + fi + done + done + + echo + print_color "0;33" "Note: Please manually verify UFW rules for more complex configurations." + echo " You can do this by running 'sudo ufw status verbose'" +} +
_:warning: Potential issue_ **Fix incorrect parsing of UFW rules in `check_docker_ports` function** The current method for parsing UFW rules may not accurately retrieve the list of allowed ports. The command assumes that `ufw status` output starts with line numbers, which is not the case. Additionally, using `sudo` within the script can cause it to hang if not run with the appropriate permissions. Apply this diff to correct the parsing of UFW rules: ```diff - ufw_rules=$(sudo ufw status | grep -E '^[0-9]+' | awk '{print $1}') + ufw_rules=$(ufw status | awk '/ALLOW/ {print $1}') ``` This change extracts the allowed ports without relying on line numbers and avoids using `sudo`. <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion check_docker_ports() { print_header "Docker Container Port Check" # Check if Docker is installed and running if ! command -v docker &> /dev/null || ! docker info &> /dev/null; then print_color "0;33" "${WARNING_MARK} Docker is not installed or not running. Skipping Docker port check." return fi # Check if UFW is installed and active if ! command -v ufw &> /dev/null || ! ufw status | grep -q "Status: active"; then print_color "0;33" "${WARNING_MARK} UFW is not installed or not active. Skipping firewall check for Docker ports." return fi # Get UFW rules ufw_rules=$(ufw status | awk '/ALLOW/ {print $1}') # Get all running Docker containers containers=$(docker ps --format "{{.Names}}") for container in $containers; do # Get port mappings for each container ports=$(docker port $container | awk '{print $3}' | cut -d ':' -f2) for port in $ports; do if echo "$ufw_rules" | grep -q "^$port$"; then print_color "0;32" "${CHECK_MARK} Port $port for container $container is allowed by UFW." else print_color "0;31" "${CROSS_MARK} Port $port for container $container might be blocked by UFW." fi done done echo print_color "0;33" "Note: Please manually verify UFW rules for more complex configurations." echo " You can do this by running 'sudo ufw status verbose'" } ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
8
bigbeartechworld
coderabbitai[bot]
@@ -140,23 +140,152 @@ check_dns_resolution() { "registry.hub.docker.com" "gcr.io" "azurecr.io" - "ghcr.io", + "ghcr.io" "registry.gitlab.com" ) + local retries=3 + local timeout=5 + local dns_servers=("8.8.8.8" "1.1.1.1" "9.9.9.9" "208.67.222.222") print_header "DNS Resolution Check:" + # Verify basic network connectivity + if ! ping -c 1 8.8.8.8 &>/dev/null; then + print_color "0;31" "${CROSS_MARK} Network connectivity issue: Unable to reach 8.8.8.8" + return + fi + for registry in "${registries[@]}"; do - if nslookup "$registry" &>/dev/null; then - print_color "0;32" "${CHECK_MARK} DNS resolution for $registry is successful" - else + local success=false + for dns_server in "${dns_servers[@]}"; do + for ((i=1; i<=retries; i++)); do + if timeout $timeout nslookup "$registry" "$dns_server" &>/dev/null; then + print_color "0;32" "${CHECK_MARK} DNS resolution for $registry is successful using DNS server $dns_server" + success=true + break 2 + else + echo "Attempt $i of $retries for $registry using DNS server $dns_server failed" + fi + done + done + + if [ "$success" = false ]; then print_color "0;31" "${CROSS_MARK} DNS resolution for $registry failed" echo "Debugging info for $registry:" - nslookup "$registry" 2>&1 | tee /dev/stderr + nslookup "$registry" 2>&1 + # Alternative check with dig for more detailed output + if command -v dig &> /dev/null; then + echo "Dig output:" + dig +short "$registry" @8.8.8.8 + fi + fi + done +} + +# Function to check Docker status +check_docker_status() { + print_header "Docker Status Check" + if command -v docker &> /dev/null; then + if docker info &> /dev/null; then + print_color "0;32" "${CHECK_MARK} Docker is running" + else + print_color "0;31" "${CROSS_MARK} Docker is installed but not running" + fi + else + print_color "0;31" "${CROSS_MARK} Docker is not installed" + fi +} + +# Function to check storage health +check_storage_health() { + print_header "Storage Health Check" + local disks=$(lsblk -ndo NAME,TYPE | awk '$2=="disk"{print $1}') + for disk in $disks; do + if smartctl -H /dev/$disk &> /dev/null; then + local health=$(smartctl -H /dev/$disk | grep "SMART overall-health") + if [[ $health == *"PASSED"* ]]; then + print_color "0;32" "${CHECK_MARK} /dev/$disk is healthy" + else + print_color "0;31" "${CROSS_MARK} /dev/$disk may have issues" + fi + else + print_color "0;33" "${WARNING_MARK} Unable to check health of /dev/$disk" fi done } +# Function to check disk space +check_disk_space() { + print_header "Disk Space Check" + local threshold=80 + local usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g') + if [ "$usage" -ge "$threshold" ]; then + print_color "0;31" "${CROSS_MARK} Disk usage is at ${usage}%, which is above the threshold of ${threshold}%" + else + print_color "0;32" "${CHECK_MARK} Disk usage is at ${usage}%, which is below the threshold of ${threshold}%" + fi +} + +# Function to check CPU load +check_cpu_load() { + print_header "CPU Load Check" + local load=$(uptime | awk -F'load average:' '{ print $2 }' | cut -d, -f1 | xargs) + local cores=$(nproc) + local threshold=$(awk "BEGIN {print $cores * 0.7}") + if (( $(awk "BEGIN {print ($load > $threshold) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} CPU load is high: ${load} (Threshold: ${threshold})" + else + print_color "0;32" "${CHECK_MARK} CPU load is acceptable: ${load} (Threshold: ${threshold})" + fi +} + +# Function to check memory usage +check_memory_usage() { + print_header "Memory Usage Check" + local total_mem=$(free -m | awk '/^Mem:/ { print $2 }') + local used_mem=$(free -m | awk '/^Mem:/ { print $3 }') + local threshold=$(awk "BEGIN {print int($total_mem * 0.8)}") + if (( $(awk "BEGIN {print ($used_mem > $threshold) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} Memory usage is high: ${used_mem}MB used of ${total_mem}MB (Threshold: ${threshold}MB)" + else + print_color "0;32" "${CHECK_MARK} Memory usage is acceptable: ${used_mem}MB used of ${total_mem}MB (Threshold: ${threshold}MB)" + fi +} + +# Function to check system temperature +check_system_temperature() { + print_header "System Temperature Check" + if command -v sensors &> /dev/null; then + sensors | grep -E 'Core|temp' | while read -r line; do + local temp=$(echo "$line" | awk '{print $2}' | sed 's/+//' | sed 's/Β°C//') + if (( $(awk "BEGIN {print ($temp > 80) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} High temperature detected: ${line}" + else + print_color "0;32" "${CHECK_MARK} Temperature is normal: ${line}" + fi + done + elif [ -f "/sys/class/thermal/thermal_zone0/temp" ]; then + local temp=$(awk '{print $1/1000}' /sys/class/thermal/thermal_zone0/temp)
_:warning: Potential issue_ **Avoid declaring and assigning 'local' variables in the same line to prevent masking return values** Also in the alternative temperature check, ensure variables are declared and assigned separately. Apply this diff: ```diff - local temp=$(awk '{print $1/1000}' /sys/class/thermal/thermal_zone0/temp) + local temp + temp=$(awk '{print $1/1000}' /sys/class/thermal/thermal_zone0/temp) ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local temp temp=$(awk '{print $1/1000}' /sys/class/thermal/thermal_zone0/temp) ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 268-268: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
8
bigbeartechworld
coderabbitai[bot]
@@ -140,23 +140,152 @@ check_dns_resolution() { "registry.hub.docker.com" "gcr.io" "azurecr.io" - "ghcr.io", + "ghcr.io" "registry.gitlab.com" ) + local retries=3 + local timeout=5 + local dns_servers=("8.8.8.8" "1.1.1.1" "9.9.9.9" "208.67.222.222") print_header "DNS Resolution Check:" + # Verify basic network connectivity + if ! ping -c 1 8.8.8.8 &>/dev/null; then + print_color "0;31" "${CROSS_MARK} Network connectivity issue: Unable to reach 8.8.8.8" + return + fi + for registry in "${registries[@]}"; do - if nslookup "$registry" &>/dev/null; then - print_color "0;32" "${CHECK_MARK} DNS resolution for $registry is successful" - else + local success=false + for dns_server in "${dns_servers[@]}"; do + for ((i=1; i<=retries; i++)); do + if timeout $timeout nslookup "$registry" "$dns_server" &>/dev/null; then + print_color "0;32" "${CHECK_MARK} DNS resolution for $registry is successful using DNS server $dns_server" + success=true + break 2 + else + echo "Attempt $i of $retries for $registry using DNS server $dns_server failed" + fi + done + done + + if [ "$success" = false ]; then print_color "0;31" "${CROSS_MARK} DNS resolution for $registry failed" echo "Debugging info for $registry:" - nslookup "$registry" 2>&1 | tee /dev/stderr + nslookup "$registry" 2>&1 + # Alternative check with dig for more detailed output + if command -v dig &> /dev/null; then + echo "Dig output:" + dig +short "$registry" @8.8.8.8 + fi + fi + done +} + +# Function to check Docker status +check_docker_status() { + print_header "Docker Status Check" + if command -v docker &> /dev/null; then + if docker info &> /dev/null; then + print_color "0;32" "${CHECK_MARK} Docker is running" + else + print_color "0;31" "${CROSS_MARK} Docker is installed but not running" + fi + else + print_color "0;31" "${CROSS_MARK} Docker is not installed" + fi +} + +# Function to check storage health +check_storage_health() { + print_header "Storage Health Check" + local disks=$(lsblk -ndo NAME,TYPE | awk '$2=="disk"{print $1}') + for disk in $disks; do + if smartctl -H /dev/$disk &> /dev/null; then + local health=$(smartctl -H /dev/$disk | grep "SMART overall-health") + if [[ $health == *"PASSED"* ]]; then + print_color "0;32" "${CHECK_MARK} /dev/$disk is healthy" + else + print_color "0;31" "${CROSS_MARK} /dev/$disk may have issues" + fi + else + print_color "0;33" "${WARNING_MARK} Unable to check health of /dev/$disk" fi done } +# Function to check disk space +check_disk_space() { + print_header "Disk Space Check" + local threshold=80 + local usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g')
_:warning: Potential issue_ **Avoid declaring and assigning 'local' variables in the same line to prevent masking return values** In the `check_disk_space` function, declaring and assigning variables separately ensures that return values are not inadvertently masked. Apply this diff: ```diff - local usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g') + local usage + usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g') ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local usage usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g') ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 221-221: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
big-bear-scripts
github_2023
others
8
bigbeartechworld
coderabbitai[bot]
@@ -140,23 +140,152 @@ check_dns_resolution() { "registry.hub.docker.com" "gcr.io" "azurecr.io" - "ghcr.io", + "ghcr.io" "registry.gitlab.com" ) + local retries=3 + local timeout=5 + local dns_servers=("8.8.8.8" "1.1.1.1" "9.9.9.9" "208.67.222.222") print_header "DNS Resolution Check:" + # Verify basic network connectivity + if ! ping -c 1 8.8.8.8 &>/dev/null; then + print_color "0;31" "${CROSS_MARK} Network connectivity issue: Unable to reach 8.8.8.8" + return + fi + for registry in "${registries[@]}"; do - if nslookup "$registry" &>/dev/null; then - print_color "0;32" "${CHECK_MARK} DNS resolution for $registry is successful" - else + local success=false + for dns_server in "${dns_servers[@]}"; do + for ((i=1; i<=retries; i++)); do + if timeout $timeout nslookup "$registry" "$dns_server" &>/dev/null; then + print_color "0;32" "${CHECK_MARK} DNS resolution for $registry is successful using DNS server $dns_server" + success=true + break 2 + else + echo "Attempt $i of $retries for $registry using DNS server $dns_server failed" + fi + done + done + + if [ "$success" = false ]; then print_color "0;31" "${CROSS_MARK} DNS resolution for $registry failed" echo "Debugging info for $registry:" - nslookup "$registry" 2>&1 | tee /dev/stderr + nslookup "$registry" 2>&1 + # Alternative check with dig for more detailed output + if command -v dig &> /dev/null; then + echo "Dig output:" + dig +short "$registry" @8.8.8.8 + fi + fi + done +} + +# Function to check Docker status +check_docker_status() { + print_header "Docker Status Check" + if command -v docker &> /dev/null; then + if docker info &> /dev/null; then + print_color "0;32" "${CHECK_MARK} Docker is running" + else + print_color "0;31" "${CROSS_MARK} Docker is installed but not running" + fi + else + print_color "0;31" "${CROSS_MARK} Docker is not installed" + fi +} + +# Function to check storage health +check_storage_health() { + print_header "Storage Health Check" + local disks=$(lsblk -ndo NAME,TYPE | awk '$2=="disk"{print $1}') + for disk in $disks; do + if smartctl -H /dev/$disk &> /dev/null; then + local health=$(smartctl -H /dev/$disk | grep "SMART overall-health") + if [[ $health == *"PASSED"* ]]; then + print_color "0;32" "${CHECK_MARK} /dev/$disk is healthy" + else + print_color "0;31" "${CROSS_MARK} /dev/$disk may have issues" + fi + else + print_color "0;33" "${WARNING_MARK} Unable to check health of /dev/$disk" fi done } +# Function to check disk space +check_disk_space() { + print_header "Disk Space Check" + local threshold=80 + local usage=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g') + if [ "$usage" -ge "$threshold" ]; then + print_color "0;31" "${CROSS_MARK} Disk usage is at ${usage}%, which is above the threshold of ${threshold}%" + else + print_color "0;32" "${CHECK_MARK} Disk usage is at ${usage}%, which is below the threshold of ${threshold}%" + fi +} + +# Function to check CPU load +check_cpu_load() { + print_header "CPU Load Check" + local load=$(uptime | awk -F'load average:' '{ print $2 }' | cut -d, -f1 | xargs) + local cores=$(nproc) + local threshold=$(awk "BEGIN {print $cores * 0.7}") + if (( $(awk "BEGIN {print ($load > $threshold) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} CPU load is high: ${load} (Threshold: ${threshold})" + else + print_color "0;32" "${CHECK_MARK} CPU load is acceptable: ${load} (Threshold: ${threshold})" + fi +} + +# Function to check memory usage +check_memory_usage() { + print_header "Memory Usage Check" + local total_mem=$(free -m | awk '/^Mem:/ { print $2 }') + local used_mem=$(free -m | awk '/^Mem:/ { print $3 }') + local threshold=$(awk "BEGIN {print int($total_mem * 0.8)}") + if (( $(awk "BEGIN {print ($used_mem > $threshold) ? 1 : 0}") )); then + print_color "0;31" "${CROSS_MARK} Memory usage is high: ${used_mem}MB used of ${total_mem}MB (Threshold: ${threshold}MB)" + else + print_color "0;32" "${CHECK_MARK} Memory usage is acceptable: ${used_mem}MB used of ${total_mem}MB (Threshold: ${threshold}MB)" + fi +} + +# Function to check system temperature +check_system_temperature() { + print_header "System Temperature Check" + if command -v sensors &> /dev/null; then + sensors | grep -E 'Core|temp' | while read -r line; do + local temp=$(echo "$line" | awk '{print $2}' | sed 's/+//' | sed 's/Β°C//')
_:warning: Potential issue_ **Avoid declaring and assigning 'local' variables in the same line to prevent masking return values** In the temperature parsing within `check_system_temperature`, separating declaration and assignment is advisable. Apply this diff: ```diff - local temp=$(echo "$line" | awk '{print $2}' | sed 's/+//' | sed 's/Β°C//') + local temp + temp=$(echo "$line" | awk '{print $2}' | sed 's/+//' | sed 's/Β°C//') ``` <!-- suggestion_start --> <details> <summary>πŸ“ Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion local temp temp=$(echo "$line" | awk '{print $2}' | sed 's/+//' | sed 's/Β°C//') ````` </details> <!-- suggestion_end --> <details> <summary>🧰 Tools</summary> <details> <summary>πŸͺ› Shellcheck</summary><blockquote> [warning] 260-260: Declare and assign separately to avoid masking return values. (SC2155) </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->