Auto Updating application.yml for unmanaged lavalink #6554

Closed
opened 2025-04-07 04:54:08 +02:00 by evman · 2 comments
evman commented 2025-04-07 04:54:08 +02:00 (Migrated from github.com)

What component of Red (cog, command, API) would you like to see improvements on?

Audio (unmanaged lavalink instance)

Describe the enhancement you're suggesting.

I've been using Red for a few years now, and as of the last 1-2 years, I've noticed that the application.yml constantly needs updating for lavalink. This can be a headache if you are running an unmanaged instance of lavalink. I have two proposals, of how to fix this, both with logging. This would be an update to auto_update.sh mentioned in the docs.

Option 1:

#!/bin/bash
set -e
cd "$(dirname "$0")"

LOGFILE="./auto_update.log"

echo "[$(date)] --- Starting Lavalink auto-update ---" >> "$LOGFILE"

# Download Lavalink if newer
echo "[$(date)] Checking Lavalink.jar..." >> "$LOGFILE"
curl -s -LOz Lavalink.jar https://github.com/Cog-Creators/Lavalink-Jars/releases/latest/download/Lavalink.jar && \
echo "[$(date)] Lavalink.jar checked/downloaded." >> "$LOGFILE"

# Get latest version from GitHub API
LATEST_VERSION=$(curl -s https://api.github.com/repos/Cog-Creators/Red-DiscordBot/releases/latest | grep '"tag_name":' | cut -d '"' -f4)

# Build YML URL
YML_URL="https://github.com/Cog-Creators/Red-DiscordBot/releases/download/${LATEST_VERSION}/Red-DiscordBot-${LATEST_VERSION}-default-lavalink-application.yml"

echo "[$(date)] Fetching application.yml from $YML_URL" >> "$LOGFILE"
curl -s -L -o application.yml "$YML_URL" && \
echo "[$(date)] application.yml updated to ${LATEST_VERSION}" >> "$LOGFILE"

echo "[$(date)] --- Update complete ---" >> "$LOGFILE"

Option 2:

#!/bin/bash
set -e
cd "$(dirname "$0")"

LOGFILE="./auto_update.log"

echo "[$(date)] --- Starting Lavalink & plugin auto-update ---" >> "$LOGFILE"

# Download Lavalink if it's newer
echo "[$(date)] Checking for updated Lavalink.jar..." | tee -a "$LOGFILE"
curl -s -LOz Lavalink.jar https://github.com/Cog-Creators/Lavalink-Jars/releases/latest/download/Lavalink.jar && \
echo "[$(date)] Lavalink.jar checked/downloaded." | tee -a "$LOGFILE"

# Get the latest YouTube plugin version
LATEST_PLUGIN_VERSION=$(curl -s "https://maven.lavalink.dev/releases/dev/lavalink/youtube/youtube-plugin/maven-metadata.xml" | grep '<latest>' | sed -E 's/.*<latest>([^<]+)<\/latest>.*/\1/')

YML_FILE="./application.yml"

if [[ -n "$LATEST_PLUGIN_VERSION" ]]; then
  echo "[$(date)] Found latest plugin version: $LATEST_PLUGIN_VERSION" | tee -a "$LOGFILE"

  CURRENT_VERSION=$(grep -oP 'dev.lavalink.youtube:youtube-plugin:\K[0-9.]+' "$YML_FILE" || echo "none")

  if [[ "$CURRENT_VERSION" != "$LATEST_PLUGIN_VERSION" ]]; then
    echo "[$(date)] Updating plugin version from $CURRENT_VERSION to $LATEST_PLUGIN_VERSION" | tee -a "$LOGFILE"
    sed -i "s|dev.lavalink.youtube:youtube-plugin:.*|dev.lavalink.youtube:youtube-plugin:${LATEST_PLUGIN_VERSION}|" "$YML_FILE"
    echo "[$(date)] application.yml updated." | tee -a "$LOGFILE"
  else
    echo "[$(date)] Plugin version already up-to-date ($CURRENT_VERSION)." | tee -a "$LOGFILE"
  fi
else
  echo "[$(date)] Failed to retrieve latest plugin version!" | tee -a "$LOGFILE"
fi

echo "[$(date)] --- Update complete ---" | tee -a "$LOGFILE"```
### What component of Red (cog, command, API) would you like to see improvements on? Audio (unmanaged lavalink instance) ### Describe the enhancement you're suggesting. I've been using Red for a few years now, and as of the last 1-2 years, I've noticed that the application.yml constantly needs updating for lavalink. This can be a headache if you are running an unmanaged instance of lavalink. I have two proposals, of how to fix this, both with logging. This would be an update to auto_update.sh mentioned in the docs. Option 1: ```bash #!/bin/bash set -e cd "$(dirname "$0")" LOGFILE="./auto_update.log" echo "[$(date)] --- Starting Lavalink auto-update ---" >> "$LOGFILE" # Download Lavalink if newer echo "[$(date)] Checking Lavalink.jar..." >> "$LOGFILE" curl -s -LOz Lavalink.jar https://github.com/Cog-Creators/Lavalink-Jars/releases/latest/download/Lavalink.jar && \ echo "[$(date)] Lavalink.jar checked/downloaded." >> "$LOGFILE" # Get latest version from GitHub API LATEST_VERSION=$(curl -s https://api.github.com/repos/Cog-Creators/Red-DiscordBot/releases/latest | grep '"tag_name":' | cut -d '"' -f4) # Build YML URL YML_URL="https://github.com/Cog-Creators/Red-DiscordBot/releases/download/${LATEST_VERSION}/Red-DiscordBot-${LATEST_VERSION}-default-lavalink-application.yml" echo "[$(date)] Fetching application.yml from $YML_URL" >> "$LOGFILE" curl -s -L -o application.yml "$YML_URL" && \ echo "[$(date)] application.yml updated to ${LATEST_VERSION}" >> "$LOGFILE" echo "[$(date)] --- Update complete ---" >> "$LOGFILE" ``` Option 2: ```bash #!/bin/bash set -e cd "$(dirname "$0")" LOGFILE="./auto_update.log" echo "[$(date)] --- Starting Lavalink & plugin auto-update ---" >> "$LOGFILE" # Download Lavalink if it's newer echo "[$(date)] Checking for updated Lavalink.jar..." | tee -a "$LOGFILE" curl -s -LOz Lavalink.jar https://github.com/Cog-Creators/Lavalink-Jars/releases/latest/download/Lavalink.jar && \ echo "[$(date)] Lavalink.jar checked/downloaded." | tee -a "$LOGFILE" # Get the latest YouTube plugin version LATEST_PLUGIN_VERSION=$(curl -s "https://maven.lavalink.dev/releases/dev/lavalink/youtube/youtube-plugin/maven-metadata.xml" | grep '<latest>' | sed -E 's/.*<latest>([^<]+)<\/latest>.*/\1/') YML_FILE="./application.yml" if [[ -n "$LATEST_PLUGIN_VERSION" ]]; then echo "[$(date)] Found latest plugin version: $LATEST_PLUGIN_VERSION" | tee -a "$LOGFILE" CURRENT_VERSION=$(grep -oP 'dev.lavalink.youtube:youtube-plugin:\K[0-9.]+' "$YML_FILE" || echo "none") if [[ "$CURRENT_VERSION" != "$LATEST_PLUGIN_VERSION" ]]; then echo "[$(date)] Updating plugin version from $CURRENT_VERSION to $LATEST_PLUGIN_VERSION" | tee -a "$LOGFILE" sed -i "s|dev.lavalink.youtube:youtube-plugin:.*|dev.lavalink.youtube:youtube-plugin:${LATEST_PLUGIN_VERSION}|" "$YML_FILE" echo "[$(date)] application.yml updated." | tee -a "$LOGFILE" else echo "[$(date)] Plugin version already up-to-date ($CURRENT_VERSION)." | tee -a "$LOGFILE" fi else echo "[$(date)] Failed to retrieve latest plugin version!" | tee -a "$LOGFILE" fi echo "[$(date)] --- Update complete ---" | tee -a "$LOGFILE"```
vrozaksen commented 2026-03-22 03:39:13 +01:00 (Migrated from github.com)

@evman I'm currently building rootles image for lavalink v3 if you are interested, added your auto update feature to it :)
https://github.com/vrozaksen/containers/pkgs/container/red-lavalink

@evman I'm currently building rootles image for lavalink v3 if you are interested, added your auto update feature to it :) https://github.com/vrozaksen/containers/pkgs/container/red-lavalink
Owner

Die Ursache liegt außerhalb von Red (Discord, YouTube, Lavalink-Plugins oder andere Abhängigkeiten) und lässt sich hier nicht sinnvoll beheben. Deshalb schließe ich das Issue.


Generated by Claude Code

Die Ursache liegt außerhalb von Red (Discord, YouTube, Lavalink-Plugins oder andere Abhängigkeiten) und lässt sich hier nicht sinnvoll beheben. Deshalb schließe ich das Issue. --- _Generated by [Claude Code](https://claude.ai/code)_
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#6554
No description provided.