Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
16629f7
Delete proxmox directory
AquaHorizonGaming Jan 4, 2026
c553786
Add files via upload
AquaHorizonGaming Jan 4, 2026
715555b
Refactor Proxmox LXC installer script for clarity
AquaHorizonGaming Jan 4, 2026
53d5420
Add files via upload
AquaHorizonGaming Jan 4, 2026
e1c792c
Delete ubuntu/New Text Document.txt
AquaHorizonGaming Jan 4, 2026
f145477
Add files via upload
AquaHorizonGaming Jan 4, 2026
6d04766
Rename install-riven.sh to install.sh
AquaHorizonGaming Jan 4, 2026
470938f
Refactor install.sh for better readability and logic
AquaHorizonGaming Jan 4, 2026
d6bedff
Refactor dependency check and command detection
AquaHorizonGaming Jan 4, 2026
af27509
Update Docker Compose URL in install script
AquaHorizonGaming Jan 4, 2026
83a1eb8
Fix docker-compose URL in install script
AquaHorizonGaming Jan 4, 2026
02866f7
Refactor command detection and update comments
AquaHorizonGaming Jan 4, 2026
39a4d47
Refactor install script for clarity and efficiency
AquaHorizonGaming Jan 4, 2026
acda2fc
Delete ubuntu/install.sh
AquaHorizonGaming Jan 4, 2026
cfe06f8
Add installation script for Riven on Ubuntu
AquaHorizonGaming Jan 4, 2026
f08672b
Update docker-compose.yml
AquaHorizonGaming Jan 4, 2026
24f4f70
Refactor docker-compose.yml for Riven services
AquaHorizonGaming Jan 4, 2026
9e6cb5e
Enhance install script with improved checks and layout
AquaHorizonGaming Jan 4, 2026
18e87dc
Revise configuration instructions in install.sh
AquaHorizonGaming Jan 4, 2026
442b758
Add README for Riven Ubuntu Installer
AquaHorizonGaming Jan 4, 2026
b21c2c9
Fix formatting in ubuntu readme.md
AquaHorizonGaming Jan 4, 2026
10808bf
Add installation instructions to readme
AquaHorizonGaming Jan 4, 2026
efa8921
Improve readme formatting and section headers
AquaHorizonGaming Jan 4, 2026
334e22f
Revise Proxmox host installation instructions
AquaHorizonGaming Jan 4, 2026
4aaeb3c
Revise README for better organization and detail
AquaHorizonGaming Jan 4, 2026
a32a685
Change script URLs in README for installation
AquaHorizonGaming Jan 4, 2026
6bc6a79
Remove version from docker-compose.yml
AquaHorizonGaming Jan 4, 2026
39b9455
Update healthcheck syntax for services
AquaHorizonGaming Jan 4, 2026
a8233a8
Update docker-compose.yml with new services and healthchecks
AquaHorizonGaming Jan 4, 2026
fd12c05
Refactor riven-install.sh for clarity and functionality
AquaHorizonGaming Jan 4, 2026
2e73616
Update README.md
AquaHorizonGaming Jan 5, 2026
9ed9403
Refactor install script for improved clarity and safety
AquaHorizonGaming Jan 5, 2026
df2f6e2
Update ORIGIN environment variable in docker-compose.yml
AquaHorizonGaming Jan 5, 2026
26238d1
Update docker-compose.yml for NVIDIA and health checks
AquaHorizonGaming Jan 5, 2026
79fbcb1
Refactor install script for clarity and structure
AquaHorizonGaming Jan 5, 2026
87deb50
Refactor install.sh for better structure and validation
AquaHorizonGaming Jan 5, 2026
833f13f
Refactor install.sh for clarity and enhancements
AquaHorizonGaming Jan 5, 2026
895d33b
📝 Add docstrings to `AquaHorizonGaming-patch-1`
coderabbitai[bot] Jan 5, 2026
f38f411
Merge pull request #2 from AquaHorizonGaming/coderabbitai/docstrings/…
AquaHorizonGaming Jan 5, 2026
0b5256f
Merge pull request #1 from AquaHorizonGaming/AquaHorizonGaming-patch-1
AquaHorizonGaming Jan 5, 2026
3a7fdf9
Add environment variables for updaters and downloaders
AquaHorizonGaming Jan 5, 2026
8178487
Refactor media server setup in install.sh
AquaHorizonGaming Jan 5, 2026
5e64e8a
📝 Add docstrings to `AquaHorizonGaming-patch-2`
coderabbitai[bot] Jan 5, 2026
c517541
Merge pull request #4 from AquaHorizonGaming/coderabbitai/docstrings/…
AquaHorizonGaming Jan 5, 2026
5de0d07
Merge pull request #3 from AquaHorizonGaming/AquaHorizonGaming-patch-2
AquaHorizonGaming Jan 5, 2026
4dcad20
Refactor install.sh for clarity and structure
AquaHorizonGaming Jan 5, 2026
15e0582
Remove /dev/dri device mapping from services
AquaHorizonGaming Jan 5, 2026
53c67db
Update docker-compose.yml
AquaHorizonGaming Jan 5, 2026
b71ec72
Update install.sh
AquaHorizonGaming Jan 5, 2026
0739542
Refactor network settings in docker-compose.yml
AquaHorizonGaming Jan 5, 2026
ebebd12
Delete proxmox directory
AquaHorizonGaming Jan 6, 2026
036644f
Add files via upload
AquaHorizonGaming Jan 6, 2026
1358025
Delete proxmox
AquaHorizonGaming Jan 6, 2026
02340f6
Add files via upload
AquaHorizonGaming Jan 6, 2026
e2ad13c
Add changelog for Proxmox Riven Installer version 1.2
AquaHorizonGaming Jan 6, 2026
0b57405
Revise README for improved clarity and organization
AquaHorizonGaming Jan 6, 2026
9cce47c
Update installation script URL for Proxmox
AquaHorizonGaming Jan 6, 2026
adb0b81
Update BASE_URL for LXC installer components
AquaHorizonGaming Jan 6, 2026
f182126
Change install script URL in README
AquaHorizonGaming Jan 6, 2026
08617df
Update docker-compose URL in install script
AquaHorizonGaming Jan 6, 2026
f2c6a8e
Fix Riven installation script URL in README
AquaHorizonGaming Jan 6, 2026
f2a4fcb
Fix Ubuntu installer script URL in README
AquaHorizonGaming Jan 6, 2026
addb915
Rename repository from 'Riven Distributables' to 'Riven Scripts'
AquaHorizonGaming Jan 6, 2026
bf1d1a8
Add confirmation message for Riven startup
AquaHorizonGaming Jan 6, 2026
18a96c8
Merge pull request #5 from AquaHorizonGaming/AquaHorizonGaming-patch-1
AquaHorizonGaming Jan 6, 2026
c4f32c2
Update README.md
AquaHorizonGaming Jan 6, 2026
256dc20
Update install.sh
AquaHorizonGaming Jan 7, 2026
f31d951
Create docker-compose.media.yml
AquaHorizonGaming Jan 7, 2026
9fd5898
Update install.sh
AquaHorizonGaming Jan 7, 2026
ee97341
Update docker-compose.media.yml
AquaHorizonGaming Jan 7, 2026
67823cc
Update docker-compose.yml
AquaHorizonGaming Jan 7, 2026
5f3ae75
Update install.sh
AquaHorizonGaming Jan 7, 2026
33823aa
Update install.sh
AquaHorizonGaming Jan 7, 2026
c7b44a7
Update install.sh
AquaHorizonGaming Jan 7, 2026
d35053a
Update install.sh
AquaHorizonGaming Jan 7, 2026
ec8f23d
Update install.sh
AquaHorizonGaming Jan 7, 2026
22aca96
Update install.sh
AquaHorizonGaming Jan 7, 2026
5851218
Update install.sh
AquaHorizonGaming Jan 7, 2026
36f5852
Update docker-compose.yml
AquaHorizonGaming Jan 7, 2026
46cf8fc
Update docker-compose.yml
AquaHorizonGaming Jan 7, 2026
5b08a87
Update install.sh
AquaHorizonGaming Jan 7, 2026
19f2285
Update readme.md
AquaHorizonGaming Jan 9, 2026
a248d27
Update install.sh
AquaHorizonGaming Jan 9, 2026
88fbc2e
Update install.sh
AquaHorizonGaming Jan 9, 2026
ec5491f
Update readme.md
AquaHorizonGaming Jan 9, 2026
32da6bc
Update readme.md
AquaHorizonGaming Jan 9, 2026
386d48d
Update install.sh
AquaHorizonGaming Jan 9, 2026
578dda4
Update install.sh
AquaHorizonGaming Jan 9, 2026
8ddd4ab
Update install.sh
AquaHorizonGaming Jan 9, 2026
4a3de97
Update install.sh
AquaHorizonGaming Jan 9, 2026
6b053d4
Create riven-uninstall.sh
AquaHorizonGaming Jan 9, 2026
c0a094a
Update readme.md
AquaHorizonGaming Jan 9, 2026
de234ca
Update readme.md
AquaHorizonGaming Jan 9, 2026
89d7a80
Update readme.md
AquaHorizonGaming Jan 9, 2026
d18725e
Create riven-update.sh
AquaHorizonGaming Jan 9, 2026
742a3d4
Update readme.md
AquaHorizonGaming Jan 9, 2026
7197573
Update readme.md
AquaHorizonGaming Jan 9, 2026
fad468c
Update readme.md
AquaHorizonGaming Jan 9, 2026
4865d5f
Update readme.md
AquaHorizonGaming Jan 9, 2026
7cc408f
Update readme.md
AquaHorizonGaming Jan 9, 2026
6f7a7d7
Update readme.md
AquaHorizonGaming Jan 9, 2026
c3d0cda
Update readme.md
AquaHorizonGaming Jan 9, 2026
244dddc
Update install.sh
AquaHorizonGaming Jan 9, 2026
f514614
Update install.sh
AquaHorizonGaming Jan 9, 2026
193bcbf
Update install.sh
AquaHorizonGaming Jan 9, 2026
696605d
Update install.sh
AquaHorizonGaming Jan 9, 2026
38cb7bd
Update install.sh
AquaHorizonGaming Jan 9, 2026
2dea217
Update install.sh
AquaHorizonGaming Jan 9, 2026
c39415a
Update install.sh
AquaHorizonGaming Jan 9, 2026
395e105
Fix Docker install logic and avoid installer hang
AquaHorizonGaming Jan 11, 2026
4330501
Update install.sh
AquaHorizonGaming Jan 11, 2026
d3ff007
Skip reinstall of existing system dependencies
AquaHorizonGaming Jan 11, 2026
2e4ab18
Update install.sh
AquaHorizonGaming Jan 11, 2026
42f508e
Update install.sh
AquaHorizonGaming Jan 11, 2026
95da4fe
Add docker group setup and user assignment
AquaHorizonGaming Jan 11, 2026
b1f3674
Update install.sh
AquaHorizonGaming Jan 11, 2026
260d3b5
Update install.sh
AquaHorizonGaming Jan 11, 2026
91546fa
Update install.sh
AquaHorizonGaming Jan 11, 2026
dbe720b
Update install.sh
AquaHorizonGaming Jan 11, 2026
2524630
Update install.sh
AquaHorizonGaming Jan 11, 2026
3ab9293
Update install.sh
AquaHorizonGaming Jan 11, 2026
6d7f4f3
Update install.sh
AquaHorizonGaming Jan 11, 2026
19b97bc
Update install.sh
AquaHorizonGaming Jan 11, 2026
9afabfe
Update install.sh
AquaHorizonGaming Jan 11, 2026
fb9dd22
Update install.sh
AquaHorizonGaming Jan 12, 2026
2854313
Update install.sh
AquaHorizonGaming Jan 12, 2026
11e20bf
Update install.sh
AquaHorizonGaming Jan 12, 2026
747ca6f
Update install.sh
AquaHorizonGaming Jan 12, 2026
7b30a96
Update install.sh
AquaHorizonGaming Jan 12, 2026
0e7835f
Update install.sh
AquaHorizonGaming Jan 12, 2026
890681a
Update install.sh
AquaHorizonGaming Jan 12, 2026
67a65b2
Update install.sh
AquaHorizonGaming Jan 12, 2026
c936c22
Create riven-remount-cycle.sh
AquaHorizonGaming Jan 13, 2026
0aa78e4
Update readme.md
AquaHorizonGaming Jan 13, 2026
fb61906
Update riven-remount-cycle.sh
AquaHorizonGaming Jan 13, 2026
436922c
Update readme.md
AquaHorizonGaming Jan 13, 2026
7611dd0
Update riven-remount-cycle.sh
AquaHorizonGaming Jan 13, 2026
434a940
Update riven-remount-cycle.sh
AquaHorizonGaming Jan 13, 2026
0f619b4
Update riven-remount-cycle.sh
AquaHorizonGaming Jan 13, 2026
0729193
Update riven-remount-cycle.sh
AquaHorizonGaming Jan 13, 2026
12da4ca
feat: add safe remount cycle with Docker/systemd media support
AquaHorizonGaming Jan 13, 2026
b3e2c5f
chore: bump riven-remount-cycle version to v1.3
AquaHorizonGaming Jan 13, 2026
7ea56ad
fix: correct media/riven startup order and bump version to v1.4
AquaHorizonGaming Jan 13, 2026
74296f2
fix: increase startup wait to allow Riven to initialize (v1.5)
AquaHorizonGaming Jan 13, 2026
fc06f7e
chore: update riven-remount-cycle.sh to v2.0
AquaHorizonGaming Jan 13, 2026
7c8f7ef
Update README.md
AquaHorizonGaming Jan 14, 2026
f01d509
fix: stderr for URL validation
AquaHorizonGaming Jan 25, 2026
5e5b8e8
feat: multi-select scraper configuration
AquaHorizonGaming Jan 25, 2026
5532411
feat: add configuration validation summary
AquaHorizonGaming Jan 25, 2026
731e5b4
Fix: installer crash when evaluating disabled scrapers
AquaHorizonGaming Jan 25, 2026
7b45b18
Bump installer version to v0.6.8
AquaHorizonGaming Jan 25, 2026
9037c1e
Delete install.sh
AquaHorizonGaming Jan 28, 2026
63b6ad2
Adjust remount wait time and version to 3.0
AquaHorizonGaming Feb 1, 2026
bec7731
Add Riven DB maintenance and show state management script
AquaHorizonGaming Feb 3, 2026
0a94986
docs: add README for Riven database maintenance tool
AquaHorizonGaming Feb 3, 2026
9326719
docs: fix README table of contents anchors
AquaHorizonGaming Feb 3, 2026
e25155d
Add db_pegger_9000.sh for MediaItem state management
AquaHorizonGaming Feb 3, 2026
3692574
Simplify compose startup to use up --pull always
AquaHorizonGaming Feb 11, 2026
9b538b4
Merge pull request #6 from AquaHorizonGaming/codex/fix-installer-scri…
AquaHorizonGaming Feb 11, 2026
48b8128
Add --debug mode and improve installer diagnostics
AquaHorizonGaming Feb 11, 2026
38c93ae
ConflictZero: resolved merge conflicts from main into PR
wish311 Feb 11, 2026
999d2d0
Merge pull request #8 from AquaHorizonGaming/codex/fix-installer-scri…
AquaHorizonGaming Feb 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 56 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,68 @@
## Riven Distributables
# Riven Scripts

This repository contains helper scripts and installers for deploying Riven on
different platforms (for example, Proxmox VE and Unraid). Each platform has its
own subdirectory and documentation.
This repository contains official helper scripts and installers for deploying
**Riven** on supported platforms.

Each platform has its own subdirectory with a dedicated installer and
documentation.

---

## Quick start: Proxmox VE LXC
## Quick Start

### Proxmox VE (LXC)

To create a Debian 12, unprivileged LXC running Riven on a Proxmox VE host,
run this from the **Proxmox host shell**:
To create a **Debian 12 unprivileged LXC** configured to run Riven on a
**Proxmox VE host**, run the following command **from the Proxmox host shell**:

```bash
bash -c "$(wget -qLO - https://raw.githubusercontent.com/rivenmedia/distributables/main/proxmox/riven.sh)"
bash -c "$(wget -qLO - https://raw.githubusercontent.com/AquaHorizonGaming/Riven-Scripts/main/proxmox/install.sh)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check which repository URLs are accessible
echo "=== Checking AquaHorizonGaming/Riven-Scripts proxmox install.sh ==="
curl -fsSL --max-time 10 -I "https://raw.githubusercontent.com/AquaHorizonGaming/Riven-Scripts/main/proxmox/install.sh" 2>&1 | head -1

echo "=== Checking rivenmedia/distributables proxmox install.sh ==="
curl -fsSL --max-time 10 -I "https://raw.githubusercontent.com/rivenmedia/distributables/main/proxmox/install.sh" 2>&1 | head -1

echo "=== Checking AquaHorizonGaming/Riven-Scripts compose file ==="
curl -fsSL --max-time 10 -I "https://raw.githubusercontent.com/AquaHorizonGaming/Riven-Scripts/main/ubuntu/compose.yml" 2>&1 | head -1

echo "=== Checking rivenmedia/distributables compose file ==="
curl -fsSL --max-time 10 -I "https://raw.githubusercontent.com/rivenmedia/distributables/main/ubuntu/compose.yml" 2>&1 | head -1

Repository: rivenmedia/distributables

Length of output: 476


🏁 Script executed:

# Examine README.md context around the mentioned lines
echo "=== README.md context around line 19 ==="
cat -n README.md | sed -n '15,25p'

echo ""
echo "=== README.md context around line 39 ==="
cat -n README.md | sed -n '35,45p'

Repository: rivenmedia/distributables

Length of output: 1073


🏁 Script executed:

# Search for repository references in the codebase
echo "=== Repository references ==="
rg "AquaHorizonGaming|rivenmedia" --type markdown --type yaml --type json

Repository: rivenmedia/distributables

Length of output: 624


🏁 Script executed:

# Check if there's any git remote or configuration
echo "=== Git remotes ==="
git remote -v 2>/dev/null || echo "Not a git repo or remotes not available"

Repository: rivenmedia/distributables

Length of output: 227


Fix inconsistent repository references in installer URLs.

README.md lines 19 and 39 reference AquaHorizonGaming/Riven-Scripts, but this repository is rivenmedia/distributables. Additionally, ubuntu/readme.md references AquaHorizonGaming/distributables (different repo name), creating inconsistency across installation documentation.

If these are intentional upstream mirrors, clarify and align all references consistently. Otherwise, update URLs to use rivenmedia/distributables so users install from the correct repository.

🤖 Prompt for AI Agents
In @README.md at line 19, The README and related docs use inconsistent
repository URLs (e.g., the proxmox installer command in README.md and the
ubuntu/readme.md reference `AquaHorizonGaming/Riven-Scripts` and
`AquaHorizonGaming/distributables`)—update those installer URLs to consistently
point to `rivenmedia/distributables` (or explicitly document that the other URLs
are intentional mirrors), replacing the wget/curl raw.githubusercontent.com
links in README.md (line with the proxmox install command) and the installer
links in ubuntu/readme.md so all installation commands reference the same
canonical repository.

```
Comment on lines +19 to 20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider security guidance for direct script execution.

Both installer commands execute remote scripts directly (with elevated privileges for Ubuntu). While this is a common installation pattern, consider adding security guidance such as:

  • Recommending users review the script first before execution
  • Providing checksums for verification
  • Offering tagged releases instead of pulling from main branch

Example addition to documentation:

> **Security Note:** Always review scripts before executing them with elevated privileges.
> You can download and inspect the script first:
> ```bash
> curl -fsSL https://raw.githubusercontent.com/.../install.sh -o install.sh
> # Review install.sh
> sudo bash install.sh
> ```

Also applies to: 39-40

🤖 Prompt for AI Agents
In `@README.md` around lines 19 - 20, Add a security notice around the direct
remote script execution examples (the bash/wget installer commands shown at the
current installer snippets) that instructs users to review the script before
running it, shows the safer download-then-review pattern (download with
curl/wget, inspect the file, then run with sudo), recommends verifying integrity
via checksums or signatures, and suggests using tagged release URLs instead of
the main branch; place this guidance immediately adjacent to the two installer
command blocks (the ones currently using wget/curl and sudo bash) so readers see
the warning whenever they encounter those commands.


For detailed Proxmox instructions (requirements, configuration, and troubleshooting),
see:
This installer handles:
- LXC creation and configuration
- Docker + FUSE setup
- Required mount propagation for Riven
- Optional GPU passthrough support

Full Proxmox documentation:
- [`proxmox/README.md`](proxmox/README.md)

Additional installers (such as Unraid) will live in their own subdirectories
with their own README files.
---

### Ubuntu (Bare Metal / VM)

To install Riven directly on an **Ubuntu system** (VM or bare metal),
run the installer below:

```bash
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/AquaHorizonGaming/Riven-Scripts/main/ubuntu/install.sh)"
```

This installer handles:
- System dependency installation
- Docker and Docker Compose setup
- Riven service preparation and directory layout

Full Ubuntu documentation:
- [`ubuntu/readme.md`](ubuntu/readme.md)

---

## Repository Structure

```text
Riven-Scripts/
├── proxmox/ # Proxmox VE LXC installer + docs
├── ubuntu/ # Ubuntu installer + docs
└── README.md # This file
```
Comment on lines +54 to +59

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Repository structure shows incorrect directory name.

The repository structure diagram shows Riven-Scripts/ but this repository is distributables. This should be updated to match the actual repository name:

 ```text
-Riven-Scripts/
+distributables/
 ├── proxmox/        # Proxmox VE LXC installer + docs
 ├── ubuntu/         # Ubuntu installer + docs
 └── README.md       # This file

<details>
<summary>🤖 Prompt for AI Agents</summary>

In @README.md around lines 54 - 59, Replace the incorrect top-level directory
name in the README structure diagram: change the string "Riven-Scripts/" to
"distributables/" in the fenced code block so the diagram accurately reflects
this repository; keep the rest of the lines (proxmox/, ubuntu/, README.md) and
the code block formatting intact.


</details>

<!-- fingerprinting:phantom:triton:puma -->

<!-- This is an auto-generated comment by CodeRabbit -->


---

## Notes

- Each platform is self-contained and documented independently
- Always follow the README inside the platform directory for configuration
and troubleshooting
- Additional platforms can be added later using the same structure
Comment thread
coderabbitai[bot] marked this conversation as resolved.
144 changes: 144 additions & 0 deletions db-tools/db_pegger_9000.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/bin/bash

# Function to check if the Docker container is running
check_container_status() {
docker ps | grep -q "riven-db"
if [ $? -ne 0 ]; then
echo "Error: The 'riven-db' container is not running. Please start the container and try again."
exit 1
fi
}
Comment on lines +4 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Container name match is too loose.

grep -q "riven-db" matches any container whose docker ps output contains "riven-db" anywhere (e.g., image name, other columns, or a similarly-named container like my-riven-db-backup).

🛡️ Proposed fix: use docker inspect or filter
 check_container_status() {
-    docker ps | grep -q "riven-db"
-    if [ $? -ne 0 ]; then
+    if ! docker ps --filter "name=^riven-db$" --format '{{.Names}}' | grep -q '^riven-db$'; then
         echo "Error: The 'riven-db' container is not running. Please start the container and try again."
         exit 1
     fi
 }
🧰 Tools
🪛 Shellcheck (0.11.0)

[style] 6-6: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.

(SC2181)

🤖 Prompt for AI Agents
In `@db-tools/db_pegger_9000.sh` around lines 4 - 10, The container-name check in
check_container_status is too loose (grep "riven-db" can match substrings);
change the check to target the specific container name and running state (e.g.,
use docker inspect or docker ps with a name filter) so only a container named
exactly "riven-db" is considered and ensure it is running; update
check_container_status to call docker inspect --format '{{.State.Running}}'
riven-db (or docker ps --filter "name=^/riven-db$" --filter "status=running")
and handle non-running/missing results by logging the same error and exiting.


# Function to perform a backup
backup_database() {
local timestamp=$(date +"%Y-%m-%d_%H-%M-%S")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Apply Shellcheck recommendations for robustness.

Several Shellcheck hints apply:

  • SC2155: Declare and assign separately to avoid masking return values (line 14)
  • SC2162: Use read -r to prevent backslash mangling (lines 18, 41, 58, 87)
  • SC2181: Check exit codes directly (lines 6, 26, 72)
♻️ Example fixes
 backup_database() {
-    local timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
+    local timestamp
+    timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
     local backup_file="/tmp/riven_backup_${timestamp}.sql"

     echo "Do you want to create a backup of the database before proceeding?"
-    read -p "Type 'y' to back up or 'n' to skip: " backup_choice
+    read -rp "Type 'y' to back up or 'n' to skip: " backup_choice

Apply -r flag to all read calls and refactor exit-code checks:

 check_container_status() {
-    docker ps | grep -q "riven-db"
-    if [ $? -ne 0 ]; then
+    if ! docker ps | grep -q "riven-db"; then

Also applies to: 18-18, 41-41, 58-58, 87-87

🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 14-14: Declare and assign separately to avoid masking return values.

(SC2155)

🤖 Prompt for AI Agents
In `@db-tools/db_pegger_9000.sh` at line 14, Split the combined
declaration+assignment for timestamp (replace "local timestamp=$(date ...)" with
a separate declaration and assignment) to avoid masking return values; change
all read invocations to use read -r (the interactive prompts that use read at
multiple places) to prevent backslash mangling; and replace any checks against
"$?" with direct exit checks (use if ! <command> or if [ $? -ne 0 ] as
appropriate) so exit codes are evaluated robustly (search for the timestamp
variable, the read calls, and the places checking exit status/using "$?" to
locate edits).

local backup_file="/tmp/riven_backup_${timestamp}.sql"

echo "Do you want to create a backup of the database before proceeding?"
read -p "Type 'y' to back up or 'n' to skip: " backup_choice

if [[ "$backup_choice" =~ ^[Yy]$ ]]; then
echo "Creating a backup of the database..."

# Use docker exec to dump the database
docker exec riven-db pg_dump -U postgres -d riven -f "$backup_file"

if [ $? -eq 0 ]; then
echo "Backup created successfully: $backup_file"
Comment on lines +23 to +27

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Backup is written inside the container, not on the host.

pg_dump -f "$backup_file" writes to /tmp inside the container, not on the host filesystem. The backup will be lost when the container is removed or recreated. The success message misleadingly suggests the file is accessible on the host.

🐛 Proposed fix: stream the dump to the host
-        # Use docker exec to dump the database
-        docker exec riven-db pg_dump -U postgres -d riven -f "$backup_file"
+        # Stream pg_dump output to host filesystem
+        docker exec riven-db pg_dump -U postgres -d riven > "$backup_file"
📝 Committable suggestion

‼️ 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.

Suggested change
# Use docker exec to dump the database
docker exec riven-db pg_dump -U postgres -d riven -f "$backup_file"
if [ $? -eq 0 ]; then
echo "Backup created successfully: $backup_file"
# Stream pg_dump output to host filesystem
docker exec riven-db pg_dump -U postgres -d riven > "$backup_file"
if [ $? -eq 0 ]; then
echo "Backup created successfully: $backup_file"
🧰 Tools
🪛 Shellcheck (0.11.0)

[style] 26-26: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

(SC2181)

🤖 Prompt for AI Agents
In `@db-tools/db_pegger_9000.sh` around lines 23 - 27, The script currently runs
docker exec riven-db pg_dump -U postgres -d riven -f "$backup_file" which writes
the dump file inside the container; change it to stream the dump to the host by
removing the -f option and redirecting docker exec's stdout to the host
backup_file (e.g., docker exec riven-db pg_dump -U postgres -d riven and
redirect to "$backup_file" on the host), and update the success check to
validate the actual pg_dump exit status (use pipefail or check docker exec exit
code) so the echo "Backup created successfully: $backup_file" only runs when the
host file was written successfully.

else
echo "Error: Backup failed."
exit 1
fi
else
echo "No backup created. Proceeding with the reset."
fi
}

# Function to fetch and display state items with confirmation
fetch_state_items() {
local state=$1
echo "Do you want to see the items in the '$state' state?"
read -p "Type 'y' to view them or 'n' to skip: " view_choice
if [[ "$view_choice" =~ ^[Yy]$ ]]; then
echo "Fetching items in the '$state' state..."
docker exec riven-db psql -U postgres -d riven -c "SELECT id, title, last_state, scraped_times FROM \"MediaItem\" WHERE last_state = '$state';"
else
echo "Skipping viewing '$state' items."
fi
}

# Function to reset state items (Unknown, Paused, Failed)
reset_state_items() {
local state=$1
echo "You are about to reset the '$state' items to 'Indexed'."
echo "This will reset the following attributes:"
echo " - 'scraped_times' to 0"
echo " - 'scraped_at' to NULL"
echo " - 'active_stream' to NULL"
read -p "Press Enter to confirm or CTRL+C to cancel..."

# Perform the reset in the database
echo "Resetting '$state' items..."
docker exec riven-db psql -U postgres -d riven -c "
BEGIN;
UPDATE \"MediaItem\"
SET last_state = 'Indexed',
scraped_at = NULL,
scraped_times = 0,
active_stream = NULL
WHERE last_state = '$state';
COMMIT;
"
if [ $? -eq 0 ]; then
echo "'$state' items successfully reset to 'Indexed'."
else
echo "Error: Database update failed for '$state'. Rolling back changes."
docker exec riven-db psql -U postgres -d riven -c "ROLLBACK;"
exit 1
fi
Comment on lines +62 to +78

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

ROLLBACK on failure is ineffective—transaction already ended.

The psql -c command executes the entire SQL block (including COMMIT) in one shot. If the UPDATE fails, COMMIT isn't reached, but the subsequent ROLLBACK on line 76 runs in a new psql session and has no effect. Additionally, if COMMIT succeeds but the shell check fails for another reason, you'd attempt to roll back an already-committed transaction.

Consider using set -e within the SQL or checking rows affected, and removing the misleading ROLLBACK call.

🔧 Proposed fix: simplify error handling
     docker exec riven-db psql -U postgres -d riven -c "
     BEGIN;
     UPDATE \"MediaItem\"
     SET last_state = 'Indexed',
         scraped_at = NULL,
         scraped_times = 0,
         active_stream = NULL
     WHERE last_state = '$state';
     COMMIT;
     "
     if [ $? -eq 0 ]; then
         echo "'$state' items successfully reset to 'Indexed'."
     else
         echo "Error: Database update failed for '$state'."
-        docker exec riven-db psql -U postgres -d riven -c "ROLLBACK;"
         exit 1
     fi

For true atomicity with rollback on error, consider using psql with ON_ERROR_ROLLBACK or wrapping in a PL/pgSQL block with exception handling.

📝 Committable suggestion

‼️ 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.

Suggested change
docker exec riven-db psql -U postgres -d riven -c "
BEGIN;
UPDATE \"MediaItem\"
SET last_state = 'Indexed',
scraped_at = NULL,
scraped_times = 0,
active_stream = NULL
WHERE last_state = '$state';
COMMIT;
"
if [ $? -eq 0 ]; then
echo "'$state' items successfully reset to 'Indexed'."
else
echo "Error: Database update failed for '$state'. Rolling back changes."
docker exec riven-db psql -U postgres -d riven -c "ROLLBACK;"
exit 1
fi
docker exec riven-db psql -U postgres -d riven -c "
BEGIN;
UPDATE \"MediaItem\"
SET last_state = 'Indexed',
scraped_at = NULL,
scraped_times = 0,
active_stream = NULL
WHERE last_state = '$state';
COMMIT;
"
if [ $? -eq 0 ]; then
echo "'$state' items successfully reset to 'Indexed'."
else
echo "Error: Database update failed for '$state'."
exit 1
fi
🧰 Tools
🪛 Shellcheck (0.11.0)

[style] 72-72: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

(SC2181)

🤖 Prompt for AI Agents
In `@db-tools/db_pegger_9000.sh` around lines 62 - 78, The current pattern runs a
full SQL block via `docker exec riven-db psql -U postgres -d riven -c` including
`BEGIN`/`COMMIT` but then calls a separate `docker exec ... psql ... -c
"ROLLBACK;"` on shell failure which is ineffective; remove that external
`ROLLBACK` and instead ensure the single `psql` invocation performs atomic
rollback on SQL errors (e.g., invoke `psql` with psql error handling such as
--set=ON_ERROR_STOP=on or --set=ON_ERROR_ROLLBACK=on, or wrap the update in a
PL/pgSQL block with EXCEPTION handling) so the transaction around `UPDATE
"MediaItem"` for `$state` is properly rolled back when the update fails and no
misleading rollback call remains.

}

# Function to ask the user which states they want to reset
ask_reset_states() {
echo "Select which states you want to reset (you can choose multiple states):"
echo "1) Unknown"
echo "2) Paused"
echo "3) Failed"
read -p "Enter your choices (e.g., '1 3' for Unknown and Failed, '2 3' for Paused and Failed, etc.): " -a choices

# Loop through the choices and perform actions for each selected state
for choice in "${choices[@]}"; do
case $choice in
1)
fetch_state_items "Unknown"
reset_state_items "Unknown"
;;
2)
fetch_state_items "Paused"
reset_state_items "Paused"
;;
3)
fetch_state_items "Failed"
reset_state_items "Failed"
;;
*)
echo "Invalid choice: $choice. Skipping."
;;
esac
done
}

# Function to display current state counts after reset
show_current_counts() {
echo "Fetching current counts of MediaItem states..."

indexed_count=$(docker exec riven-db psql -U postgres -d riven -t -c "SELECT count(*) FROM \"MediaItem\" WHERE last_state = 'Indexed';")
paused_count=$(docker exec riven-db psql -U postgres -d riven -t -c "SELECT count(*) FROM \"MediaItem\" WHERE last_state = 'Paused';")
unknown_count=$(docker exec riven-db psql -U postgres -d riven -t -c "SELECT count(*) FROM \"MediaItem\" WHERE last_state = 'Unknown';")
failed_count=$(docker exec riven-db psql -U postgres -d riven -t -c "SELECT count(*) FROM \"MediaItem\" WHERE last_state = 'Failed';")
completed_count=$(docker exec riven-db psql -U postgres -d riven -t -c "SELECT count(*) FROM \"MediaItem\" WHERE last_state = 'Completed';")

echo "Current MediaItem States:"
echo " - Indexed: $indexed_count"
echo " - Paused: $paused_count"
echo " - Unknown: $unknown_count"
echo " - Failed: $failed_count"
echo " - Completed: $completed_count"
}
Comment on lines +111 to +127

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Counts output includes leading whitespace from psql.

psql -t outputs values with leading/trailing whitespace. The echo statements will display something like " - Indexed: 42" with extra spaces. Consider trimming.

♻️ Proposed fix: trim whitespace
-    indexed_count=$(docker exec riven-db psql -U postgres -d riven -t -c "SELECT count(*) FROM \"MediaItem\" WHERE last_state = 'Indexed';")
+    indexed_count=$(docker exec riven-db psql -U postgres -d riven -t -c "SELECT count(*) FROM \"MediaItem\" WHERE last_state = 'Indexed';" | tr -d '[:space:]')

Apply to all count variables.

🤖 Prompt for AI Agents
In `@db-tools/db_pegger_9000.sh` around lines 111 - 127, The psql outputs saved
into indexed_count, paused_count, unknown_count, failed_count and
completed_count include leading/trailing whitespace; update the docker exec psql
invocations inside show_current_counts to trim them (for example add the
unaligned flag -A: use psql -t -A -c "SELECT count(*) ..." or pipe the output
through a trim (xargs or sed) so the variables contain clean numbers) and ensure
all five count variables are changed consistently so the echo lines print
without extra spaces.


# Main script execution
echo "Starting the reset process for MediaItem states..."

# Step 1: Check if the Docker container is running
check_container_status

# Step 2: Ask the user if they want to create a backup
backup_database

# Step 3: Ask the user which states they want to reset (can select multiple)
ask_reset_states

# Step 4: Show the current counts after the reset
show_current_counts

echo "Script completed successfully."
Loading