Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
81 changes: 62 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,71 @@
# Ignore generated environment variables and secrets
```bash
# Environment
.env
.env.local
.env.*

# Ignore generated hardware acceleration override
docker-compose.override.yml

# Ignore generated management script
manage.sh

# Ignore all application data, databases, and configs
configs/
data/

# Ignore generated installation and backups
torbox-media-server/
backups/
*.bak.*
# Logs and temp files
*.log
*.tmp
*.swp

# IDE/Editor files
# Editors
.vscode/
.idea/
*.swp
*.swo
*~

# Dependencies
node_modules/
.venv/
venv/
__pycache__/
.mypy_cache/
.pytest_cache/
dist/
build/
target/
.gradle/

# OS generated files
.DS_Store
Thumbs.db

# Compiled files
*.pyc
*.class
*.o
*.exe
*.dll
*.so
*.a
*.obj
*.out

# Coverage
coverage/
htmlcov/
.coverage

# Compressed files
*.zip
*.gz
*.tar
*.tgz
*.bz2
*.xz
*.7z
*.rar
*.zst
*.lz4
*.lzh
*.cab
*.arj
*.rpm
*.deb
*.Z
*.lz
*.lzo
*.tar.gz
*.tar.bz2
*.tar.xz
*.tar.zst
```
47 changes: 46 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,39 @@ gather_config() {
done
fi

# Generate or preserve admin credentials for the *arr services
if [[ -n "${EXISTING_RADARR_ADMIN_USER:-}" && -n "${EXISTING_RADARR_ADMIN_PASS:-}" ]]; then
RADARR_ADMIN_USER="$EXISTING_RADARR_ADMIN_USER"
RADARR_ADMIN_PASS="$EXISTING_RADARR_ADMIN_PASS"
SONARR_ADMIN_USER="$EXISTING_SONARR_ADMIN_USER"
SONARR_ADMIN_PASS="$EXISTING_SONARR_ADMIN_PASS"
PROWLARR_ADMIN_USER="$EXISTING_PROWLARR_ADMIN_USER"
PROWLARR_ADMIN_PASS="$EXISTING_PROWLARR_ADMIN_PASS"
log_info "Preserved existing admin credentials from previous installation."
else
RADARR_ADMIN_USER="admin"
SONARR_ADMIN_USER="admin"
PROWLARR_ADMIN_USER="admin"

# Generate secure random passwords
RADARR_ADMIN_PASS="$(openssl rand -base64 12 2>/dev/null | tr -d '/+=' | head -c 12)"
SONARR_ADMIN_PASS="$RADARR_ADMIN_PASS"
PROWLARR_ADMIN_PASS="$RADARR_ADMIN_PASS"

# Fallback if openssl fails
if [[ -z "$RADARR_ADMIN_PASS" ]]; then
RADARR_ADMIN_PASS="$(head -c 12 /dev/urandom | base64 | tr -d '/+=' | head -c 12)"
SONARR_ADMIN_PASS="$RADARR_ADMIN_PASS"
PROWLARR_ADMIN_PASS="$RADARR_ADMIN_PASS"
fi

# Validate passwords are non-empty
if [[ -z "$RADARR_ADMIN_PASS" ]]; then
log_error "Failed to generate admin passwords. Ensure openssl is installed."
exit 1
fi
fi

echo ""

# Hardware Acceleration — auto-detect, then prompt only if ambiguous
Expand Down Expand Up @@ -933,7 +966,7 @@ DECYPHARR_USER="${DECYPHARR_USER:-torbox}"
DECYPHARR_PASS="${DECYPHARR_PASS:-}"
ENV_EOF

# Preserve existing admin credentials if this is a re-run
# Preserve existing admin credentials if this is a re-run, or write newly generated ones on fresh install
if [[ -n "${EXISTING_RADARR_ADMIN_USER:-}" ]]; then
cat >> "${ENV_FILE}" << ADMIN_EOF

Comment on lines +969 to 972

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Blank admin pass on rerun 🐞 Bug ≡ Correctness

generate_env_file() decides to "preserve" admin credentials when EXISTING_RADARR_ADMIN_USER is set
even if the corresponding password is empty, so it can write empty *_ADMIN_PASS values into the new
.env and discard the newly generated credentials from gather_config(). If auth is already configured
in the services, configure_arr_auth() returns early and never corrects the .env, leaving users
without the real password.
Agent Prompt
## Issue description
`generate_env_file()` treats any non-empty `EXISTING_RADARR_ADMIN_USER` as a signal to preserve credentials, but `gather_config()` only preserves when both user *and* pass exist. This mismatch can cause `.env` to be rewritten with empty `*_ADMIN_PASS` values even though fresh credentials were generated.

## Issue Context
- Existing admin vars are parsed individually from `.env` and may be empty if the file is corrupted/edited.
- `configure_arr_auth()` exits early when auth is already configured, so it may not rewrite `.env` with the correct password.

## Fix Focus Areas
- setup.sh[592-623]
- setup.sh[969-993]
- setup.sh[2495-2501]
- setup.sh[2117-2126]

## Suggested fix
1. Change the condition in `generate_env_file()` to require both user and pass (and ideally all three service pairs) before entering the “Preserved” branch.
2. Optionally, in `check_existing_installation()`, if a `*_ADMIN_USER` is non-empty but `*_ADMIN_PASS` is empty, clear the user too (or log and treat as missing) so reruns regenerate and write fresh credentials consistently.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Expand All @@ -944,6 +977,18 @@ SONARR_ADMIN_USER="${EXISTING_SONARR_ADMIN_USER}"
SONARR_ADMIN_PASS="${EXISTING_SONARR_ADMIN_PASS}"
PROWLARR_ADMIN_USER="${EXISTING_PROWLARR_ADMIN_USER}"
PROWLARR_ADMIN_PASS="${EXISTING_PROWLARR_ADMIN_PASS}"
ADMIN_EOF
else
# Fresh install: write the newly generated admin credentials
cat >> "${ENV_FILE}" << ADMIN_EOF

# Admin Credentials (Auto-generated)
RADARR_ADMIN_USER="${RADARR_ADMIN_USER}"
RADARR_ADMIN_PASS="${RADARR_ADMIN_PASS}"
SONARR_ADMIN_USER="${SONARR_ADMIN_USER}"
SONARR_ADMIN_PASS="${SONARR_ADMIN_PASS}"
PROWLARR_ADMIN_USER="${PROWLARR_ADMIN_USER}"
PROWLARR_ADMIN_PASS="${PROWLARR_ADMIN_PASS}"
ADMIN_EOF
fi

Expand Down
Loading