Refactor: Slskd & Soularr (#11674)

This commit is contained in:
Chris
2026-02-10 17:04:56 -05:00
committed by GitHub
parent a16dfb6d82
commit ac308c931e
3 changed files with 104 additions and 94 deletions

View File

@@ -3,7 +3,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
# Copyright (c) 2021-2026 community-scripts ORG # Copyright (c) 2021-2026 community-scripts ORG
# Author: vhsdream # Author: vhsdream
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/slskd/slskd, https://soularr.net # Source: https://github.com/slskd/slskd, https://github.com/mrusse/soularr
APP="slskd" APP="slskd"
var_tags="${var_tags:-arr;p2p}" var_tags="${var_tags:-arr;p2p}"
@@ -24,50 +24,65 @@ function update_script() {
check_container_storage check_container_storage
check_container_resources check_container_resources
if [[ ! -d /opt/slskd ]] || [[ ! -d /opt/soularr ]]; then if [[ ! -d /opt/slskd ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No Slskd Installation Found!"
exit exit
fi fi
RELEASE=$(curl -s https://api.github.com/repos/slskd/slskd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') if check_for_gh_release "Slskd" "slskd/slskd"; then
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then msg_info "Stopping Service(s)"
msg_info "Stopping Service" systemctl stop slskd
systemctl stop slskd soularr.timer soularr.service [[ -f /etc/systemd/system/soularr.service ]] && systemctl stop soularr.timer soularr.service
msg_info "Stopped Service" msg_ok "Stopped Service(s)"
msg_info "Updating $APP to v${RELEASE}" msg_info "Backing up config"
tmp_file=$(mktemp) cp /opt/slskd/config/slskd.yml /opt/slskd.yml.bak
curl -fsSL "https://github.com/slskd/slskd/releases/download/${RELEASE}/slskd-${RELEASE}-linux-x64.zip" -o $tmp_file msg_ok "Backed up config"
$STD unzip -oj $tmp_file slskd -d /opt/${APP}
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated $APP to v${RELEASE}"
msg_info "Starting Service" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Slskd" "slskd/slskd" "prebuild" "latest" "/opt/slskd" "slskd-*-linux-x64.zip"
msg_info "Restoring config"
mv /opt/slskd.yml.bak /opt/slskd/config/slskd.yml
msg_ok "Restored config"
msg_info "Starting Service(s)"
systemctl start slskd systemctl start slskd
msg_ok "Started Service" [[ -f /etc/systemd/system/soularr.service ]] && systemctl start soularr.timer
rm -rf $tmp_file msg_ok "Started Service(s)"
else msg_ok "Updated Slskd successfully!"
msg_ok "No ${APP} update required. ${APP} is already at v${RELEASE}"
fi fi
msg_info "Updating Soularr" [[ -d /opt/soularr ]] && if check_for_gh_release "Soularr" "mrusse/soularr"; then
cp /opt/soularr/config.ini /opt/config.ini.bak if systemctl is-active soularr.timer >/dev/null; then
cp /opt/soularr/run.sh /opt/run.sh.bak msg_info "Stopping Timer and Service"
cd /tmp systemctl stop soularr.timer soularr.service
rm -rf /opt/soularr msg_ok "Stopped Timer and Service"
curl -fsSL -o main.zip https://github.com/mrusse/soularr/archive/refs/heads/main.zip fi
$STD unzip main.zip
mv soularr-main /opt/soularr
cd /opt/soularr
$STD pip install -r requirements.txt
mv /opt/config.ini.bak /opt/soularr/config.ini
mv /opt/run.sh.bak /opt/soularr/run.sh
rm -rf /tmp/main.zip
msg_ok "Updated soularr"
msg_info "Starting soularr timer" msg_info "Backing up Soularr config"
systemctl start soularr.timer cp /opt/soularr/config.ini /opt/soularr_config.ini.bak
msg_ok "Started soularr timer" cp /opt/soularr/run.sh /opt/soularr_run.sh.bak
exit msg_ok "Backed up Soularr config"
PYTHON_VERSION="3.11" setup_uv
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Soularr" "mrusse/soularr" "tarball" "latest" "/opt/soularr"
msg_info "Updating Soularr"
cd /opt/soularr
$STD uv venv -c venv
$STD source venv/bin/activate
$STD uv pip install -r requirements.txt
deactivate
msg_ok "Updated Soularr"
msg_info "Restoring Soularr config"
mv /opt/soularr_config.ini.bak /opt/soularr/config.ini
mv /opt/soularr_run.sh.bak /opt/soularr/run.sh
msg_ok "Restored Soularr config"
msg_info "Starting Soularr Timer"
systemctl restart soularr.timer
msg_ok "Started Soularr Timer"
msg_ok "Updated Soularr successfully!"
fi
} }
start start

View File

@@ -1,5 +1,5 @@
{ {
"name": "slskd", "name": "Slskd",
"slug": "slskd", "slug": "slskd",
"categories": [ "categories": [
11 11
@@ -35,10 +35,6 @@
{ {
"text": "See /opt/slskd/config/slskd.yml to add your Soulseek credentials", "text": "See /opt/slskd/config/slskd.yml to add your Soulseek credentials",
"type": "info" "type": "info"
},
{
"text": "This LXC includes Soularr; it needs to be configured (/opt/soularr/config.ini) before it will work",
"type": "info"
} }
] ]
} }

View File

@@ -3,7 +3,7 @@
# Copyright (c) 2021-2026 community-scripts ORG # Copyright (c) 2021-2026 community-scripts ORG
# Author: vhsdream # Author: vhsdream
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/slskd/slskd/, https://soularr.net # Source: https://github.com/slskd/slskd/, https://github.com/mrusse/soularr
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color color
@@ -13,71 +13,71 @@ setting_up_container
network_check network_check
update_os update_os
msg_info "Installing Dependencies" fetch_and_deploy_gh_release "Slskd" "slskd/slskd" "prebuild" "latest" "/opt/slskd" "slskd-*-linux-x64.zip"
$STD apt install -y \
python3-pip
msg_ok "Installed Dependencies"
msg_info "Setup ${APPLICATION}" msg_info "Configuring Slskd"
tmp_file=$(mktemp)
RELEASE=$(curl -s https://api.github.com/repos/slskd/slskd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/slskd/slskd/releases/download/${RELEASE}/slskd-${RELEASE}-linux-x64.zip" -o $tmp_file
$STD unzip $tmp_file -d /opt/${APPLICATION}
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
JWT_KEY=$(openssl rand -base64 44) JWT_KEY=$(openssl rand -base64 44)
SLSKD_API_KEY=$(openssl rand -base64 44) SLSKD_API_KEY=$(openssl rand -base64 44)
cp /opt/${APPLICATION}/config/slskd.example.yml /opt/${APPLICATION}/config/slskd.yml cp /opt/slskd/config/slskd.example.yml /opt/slskd/config/slskd.yml
sed -i \ sed -i \
-e "\|web:|,\|cidr|s|^#||" \ -e '/web:/,/cidr/s/^# //' \
-e "\|https:|,\|5031|s|false|true|" \ -e '/https:/,/port: 5031/s/false/true/' \
-e '/port: 5030/,/socket/s/,.*$//' \
-e '/content_path:/,/authentication/s/false/true/' \
-e "\|api_keys|,\|cidr|s|<some.*$|$SLSKD_API_KEY|; \ -e "\|api_keys|,\|cidr|s|<some.*$|$SLSKD_API_KEY|; \
s|role: readonly|role: readwrite|; \ s|role: readonly|role: readwrite|; \
s|0.0.0.0/0,::/0|& # Replace this with your subnet|" \ s|0.0.0.0/0,::/0|& # Replace this with your subnet|" \
-e "\|soulseek|,\|write_queue|s|^#||" \
-e "\|jwt:|,\|ttl|s|key: ~|key: $JWT_KEY|" \ -e "\|jwt:|,\|ttl|s|key: ~|key: $JWT_KEY|" \
-e "s|^ picture|# picture|" \ -e '/soulseek/,/write_queue/s/^# //' \
/opt/${APPLICATION}/config/slskd.yml -e 's/^.*picture/#&/' /opt/slskd/config/slskd.yml
msg_ok "Setup ${APPLICATION}" msg_ok "Configured Slskd"
msg_info "Installing Soularr" read -rp "${TAB3}Do you want to install Soularr? y/N " soularr
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED if [[ ${soularr,,} =~ ^(y|yes)$ ]]; then
cd /tmp PYTHON_VERSION="3.11" setup_uv
curl -fsSL -o main.zip https://github.com/mrusse/soularr/archive/refs/heads/main.zip fetch_and_deploy_gh_release "Soularr" "mrusse/soularr" "tarball" "latest" "/opt/soularr"
$STD unzip main.zip cd /opt/soularr
mv soularr-main /opt/soularr $STD uv venv venv
cd /opt/soularr $STD source venv/bin/activate
$STD pip install -r requirements.txt $STD uv pip install -r requirements.txt
sed -i \ sed -i \
-e "\|[Slskd]|,\|host_url|s|yourslskdapikeygoeshere|$SLSKD_API_KEY|" \ -e "\|[Slskd]|,\|host_url|s|yourslskdapikeygoeshere|$SLSKD_API_KEY|" \
-e "/host_url/s/slskd/localhost/" \ -e "/host_url/s/slskd/localhost/" \
/opt/soularr/config.ini /opt/soularr/config.ini
sed -i \ cat <<EOF >/opt/soularr/run.sh
-e "/#This\|#Default\|INTERVAL/{N;d;}" \ #!/usr/bin/env bash
-e "/while\|#Pass/d" \
-e "\|python|s|app|opt/soularr|; s|python|python3|" \
-e "/dt/,+2d" \
/opt/soularr/run.sh
sed -i -E "/(soularr.py)/s/.{5}$//; /if/,/fi/s/.{4}//" /opt/soularr/run.sh
chmod +x /opt/soularr/run.sh
msg_ok "Installed Soularr"
msg_info "Creating Services" if ps aux | grep "[s]oularr.py" >/dev/null; then
cat <<EOF >/etc/systemd/system/${APPLICATION}.service echo "Soularr is already running. Exiting..."
exit 1
else
source /opt/soularr/venv/bin/activate
uv run python3 -u /opt/soularr/soularr.py --config-dir /opt/soularr
fi
EOF
chmod +x /opt/soularr/run.sh
deactivate
msg_ok "Installed Soularr"
fi
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/slskd.service
[Unit] [Unit]
Description=${APPLICATION} Service Description=Slskd Service
After=network.target After=network.target
Wants=network.target Wants=network.target
[Service] [Service]
WorkingDirectory=/opt/${APPLICATION} WorkingDirectory=/opt/slskd
ExecStart=/opt/${APPLICATION}/slskd --config /opt/${APPLICATION}/config/slskd.yml ExecStart=/opt/slskd/slskd --config /opt/slskd/config/slskd.yml
Restart=always Restart=always
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
cat <<EOF >/etc/systemd/system/soularr.timer if [[ -d /opt/soularr ]]; then
cat <<EOF >/etc/systemd/system/soularr.timer
[Unit] [Unit]
Description=Soularr service timer Description=Soularr service timer
RefuseManualStart=no RefuseManualStart=no
@@ -85,15 +85,15 @@ RefuseManualStop=no
[Timer] [Timer]
Persistent=true Persistent=true
# run every 5 minutes # run every 10 minutes
OnCalendar=*-*-* *:0/5:00 OnCalendar=*-*-* *:0/10:00
Unit=soularr.service Unit=soularr.service
[Install] [Install]
WantedBy=timers.target WantedBy=timers.target
EOF EOF
cat <<EOF >/etc/systemd/system/soularr.service cat <<EOF >/etc/systemd/system/soularr.service
[Unit] [Unit]
Description=Soularr service Description=Soularr service
After=network.target slskd.service After=network.target slskd.service
@@ -106,10 +106,9 @@ ExecStart=/bin/bash -c /opt/soularr/run.sh
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
systemctl enable -q --now ${APPLICATION} msg_warn "Add your Lidarr API key to Soularr in '/opt/soularr/config.ini', then run 'systemctl enable --now soularr.timer'"
systemctl enable -q soularr.timer fi
rm -rf $tmp_file systemctl enable -q --now slskd
rm -rf /tmp/main.zip
msg_ok "Created Services" msg_ok "Created Services"
motd_ssh motd_ssh