Skip to content

Commit ac308c9

Browse files
authored
Refactor: Slskd & Soularr (#11674)
1 parent a16dfb6 commit ac308c9

3 files changed

Lines changed: 107 additions & 97 deletions

File tree

ct/slskd.sh

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
33
# Copyright (c) 2021-2026 community-scripts ORG
44
# Author: vhsdream
55
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6-
# Source: https://github.com/slskd/slskd, https://soularr.net
6+
# Source: https://github.com/slskd/slskd, https://github.com/mrusse/soularr
77

88
APP="slskd"
99
var_tags="${var_tags:-arr;p2p}"
@@ -24,50 +24,65 @@ function update_script() {
2424
check_container_storage
2525
check_container_resources
2626

27-
if [[ ! -d /opt/slskd ]] || [[ ! -d /opt/soularr ]]; then
28-
msg_error "No ${APP} Installation Found!"
27+
if [[ ! -d /opt/slskd ]]; then
28+
msg_error "No Slskd Installation Found!"
2929
exit
3030
fi
3131

32-
RELEASE=$(curl -s https://api.github.com/repos/slskd/slskd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
33-
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
34-
msg_info "Stopping Service"
35-
systemctl stop slskd soularr.timer soularr.service
36-
msg_info "Stopped Service"
32+
if check_for_gh_release "Slskd" "slskd/slskd"; then
33+
msg_info "Stopping Service(s)"
34+
systemctl stop slskd
35+
[[ -f /etc/systemd/system/soularr.service ]] && systemctl stop soularr.timer soularr.service
36+
msg_ok "Stopped Service(s)"
3737

38-
msg_info "Updating $APP to v${RELEASE}"
39-
tmp_file=$(mktemp)
40-
curl -fsSL "https://github.com/slskd/slskd/releases/download/${RELEASE}/slskd-${RELEASE}-linux-x64.zip" -o $tmp_file
41-
$STD unzip -oj $tmp_file slskd -d /opt/${APP}
42-
echo "${RELEASE}" >/opt/${APP}_version.txt
43-
msg_ok "Updated $APP to v${RELEASE}"
38+
msg_info "Backing up config"
39+
cp /opt/slskd/config/slskd.yml /opt/slskd.yml.bak
40+
msg_ok "Backed up config"
4441

45-
msg_info "Starting Service"
42+
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Slskd" "slskd/slskd" "prebuild" "latest" "/opt/slskd" "slskd-*-linux-x64.zip"
43+
44+
msg_info "Restoring config"
45+
mv /opt/slskd.yml.bak /opt/slskd/config/slskd.yml
46+
msg_ok "Restored config"
47+
48+
msg_info "Starting Service(s)"
4649
systemctl start slskd
47-
msg_ok "Started Service"
48-
rm -rf $tmp_file
49-
else
50-
msg_ok "No ${APP} update required. ${APP} is already at v${RELEASE}"
50+
[[ -f /etc/systemd/system/soularr.service ]] && systemctl start soularr.timer
51+
msg_ok "Started Service(s)"
52+
msg_ok "Updated Slskd successfully!"
5153
fi
52-
msg_info "Updating Soularr"
53-
cp /opt/soularr/config.ini /opt/config.ini.bak
54-
cp /opt/soularr/run.sh /opt/run.sh.bak
55-
cd /tmp
56-
rm -rf /opt/soularr
57-
curl -fsSL -o main.zip https://github.com/mrusse/soularr/archive/refs/heads/main.zip
58-
$STD unzip main.zip
59-
mv soularr-main /opt/soularr
60-
cd /opt/soularr
61-
$STD pip install -r requirements.txt
62-
mv /opt/config.ini.bak /opt/soularr/config.ini
63-
mv /opt/run.sh.bak /opt/soularr/run.sh
64-
rm -rf /tmp/main.zip
65-
msg_ok "Updated soularr"
54+
[[ -d /opt/soularr ]] && if check_for_gh_release "Soularr" "mrusse/soularr"; then
55+
if systemctl is-active soularr.timer >/dev/null; then
56+
msg_info "Stopping Timer and Service"
57+
systemctl stop soularr.timer soularr.service
58+
msg_ok "Stopped Timer and Service"
59+
fi
60+
61+
msg_info "Backing up Soularr config"
62+
cp /opt/soularr/config.ini /opt/soularr_config.ini.bak
63+
cp /opt/soularr/run.sh /opt/soularr_run.sh.bak
64+
msg_ok "Backed up Soularr config"
6665

67-
msg_info "Starting soularr timer"
68-
systemctl start soularr.timer
69-
msg_ok "Started soularr timer"
70-
exit
66+
PYTHON_VERSION="3.11" setup_uv
67+
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Soularr" "mrusse/soularr" "tarball" "latest" "/opt/soularr"
68+
msg_info "Updating Soularr"
69+
cd /opt/soularr
70+
$STD uv venv -c venv
71+
$STD source venv/bin/activate
72+
$STD uv pip install -r requirements.txt
73+
deactivate
74+
msg_ok "Updated Soularr"
75+
76+
msg_info "Restoring Soularr config"
77+
mv /opt/soularr_config.ini.bak /opt/soularr/config.ini
78+
mv /opt/soularr_run.sh.bak /opt/soularr/run.sh
79+
msg_ok "Restored Soularr config"
80+
81+
msg_info "Starting Soularr Timer"
82+
systemctl restart soularr.timer
83+
msg_ok "Started Soularr Timer"
84+
msg_ok "Updated Soularr successfully!"
85+
fi
7186
}
7287

7388
start

frontend/public/json/slskd.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "slskd",
2+
"name": "Slskd",
33
"slug": "slskd",
44
"categories": [
55
11
@@ -35,10 +35,6 @@
3535
{
3636
"text": "See /opt/slskd/config/slskd.yml to add your Soulseek credentials",
3737
"type": "info"
38-
},
39-
{
40-
"text": "This LXC includes Soularr; it needs to be configured (/opt/soularr/config.ini) before it will work",
41-
"type": "info"
4238
}
4339
]
4440
}

install/slskd-install.sh

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (c) 2021-2026 community-scripts ORG
44
# Author: vhsdream
55
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6-
# Source: https://github.com/slskd/slskd/, https://soularr.net
6+
# Source: https://github.com/slskd/slskd/, https://github.com/mrusse/soularr
77

88
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
99
color
@@ -13,87 +13,87 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
msg_info "Installing Dependencies"
17-
$STD apt install -y \
18-
python3-pip
19-
msg_ok "Installed Dependencies"
20-
21-
msg_info "Setup ${APPLICATION}"
22-
tmp_file=$(mktemp)
23-
RELEASE=$(curl -s https://api.github.com/repos/slskd/slskd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
24-
curl -fsSL "https://github.com/slskd/slskd/releases/download/${RELEASE}/slskd-${RELEASE}-linux-x64.zip" -o $tmp_file
25-
$STD unzip $tmp_file -d /opt/${APPLICATION}
26-
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
16+
fetch_and_deploy_gh_release "Slskd" "slskd/slskd" "prebuild" "latest" "/opt/slskd" "slskd-*-linux-x64.zip"
17+
18+
msg_info "Configuring Slskd"
2719
JWT_KEY=$(openssl rand -base64 44)
2820
SLSKD_API_KEY=$(openssl rand -base64 44)
29-
cp /opt/${APPLICATION}/config/slskd.example.yml /opt/${APPLICATION}/config/slskd.yml
21+
cp /opt/slskd/config/slskd.example.yml /opt/slskd/config/slskd.yml
3022
sed -i \
31-
-e "\|web:|,\|cidr|s|^#||" \
32-
-e "\|https:|,\|5031|s|false|true|" \
23+
-e '/web:/,/cidr/s/^# //' \
24+
-e '/https:/,/port: 5031/s/false/true/' \
25+
-e '/port: 5030/,/socket/s/,.*$//' \
26+
-e '/content_path:/,/authentication/s/false/true/' \
3327
-e "\|api_keys|,\|cidr|s|<some.*$|$SLSKD_API_KEY|; \
3428
s|role: readonly|role: readwrite|; \
3529
s|0.0.0.0/0,::/0|& # Replace this with your subnet|" \
36-
-e "\|soulseek|,\|write_queue|s|^#||" \
3730
-e "\|jwt:|,\|ttl|s|key: ~|key: $JWT_KEY|" \
38-
-e "s|^ picture|# picture|" \
39-
/opt/${APPLICATION}/config/slskd.yml
40-
msg_ok "Setup ${APPLICATION}"
41-
42-
msg_info "Installing Soularr"
43-
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
44-
cd /tmp
45-
curl -fsSL -o main.zip https://github.com/mrusse/soularr/archive/refs/heads/main.zip
46-
$STD unzip main.zip
47-
mv soularr-main /opt/soularr
48-
cd /opt/soularr
49-
$STD pip install -r requirements.txt
50-
sed -i \
51-
-e "\|[Slskd]|,\|host_url|s|yourslskdapikeygoeshere|$SLSKD_API_KEY|" \
52-
-e "/host_url/s/slskd/localhost/" \
53-
/opt/soularr/config.ini
54-
sed -i \
55-
-e "/#This\|#Default\|INTERVAL/{N;d;}" \
56-
-e "/while\|#Pass/d" \
57-
-e "\|python|s|app|opt/soularr|; s|python|python3|" \
58-
-e "/dt/,+2d" \
59-
/opt/soularr/run.sh
60-
sed -i -E "/(soularr.py)/s/.{5}$//; /if/,/fi/s/.{4}//" /opt/soularr/run.sh
61-
chmod +x /opt/soularr/run.sh
62-
msg_ok "Installed Soularr"
63-
64-
msg_info "Creating Services"
65-
cat <<EOF >/etc/systemd/system/${APPLICATION}.service
31+
-e '/soulseek/,/write_queue/s/^# //' \
32+
-e 's/^.*picture/#&/' /opt/slskd/config/slskd.yml
33+
msg_ok "Configured Slskd"
34+
35+
read -rp "${TAB3}Do you want to install Soularr? y/N " soularr
36+
if [[ ${soularr,,} =~ ^(y|yes)$ ]]; then
37+
PYTHON_VERSION="3.11" setup_uv
38+
fetch_and_deploy_gh_release "Soularr" "mrusse/soularr" "tarball" "latest" "/opt/soularr"
39+
cd /opt/soularr
40+
$STD uv venv venv
41+
$STD source venv/bin/activate
42+
$STD uv pip install -r requirements.txt
43+
sed -i \
44+
-e "\|[Slskd]|,\|host_url|s|yourslskdapikeygoeshere|$SLSKD_API_KEY|" \
45+
-e "/host_url/s/slskd/localhost/" \
46+
/opt/soularr/config.ini
47+
cat <<EOF >/opt/soularr/run.sh
48+
#!/usr/bin/env bash
49+
50+
if ps aux | grep "[s]oularr.py" >/dev/null; then
51+
echo "Soularr is already running. Exiting..."
52+
exit 1
53+
else
54+
source /opt/soularr/venv/bin/activate
55+
uv run python3 -u /opt/soularr/soularr.py --config-dir /opt/soularr
56+
fi
57+
EOF
58+
chmod +x /opt/soularr/run.sh
59+
deactivate
60+
msg_ok "Installed Soularr"
61+
fi
62+
63+
msg_info "Creating Service"
64+
cat <<EOF >/etc/systemd/system/slskd.service
6665
[Unit]
67-
Description=${APPLICATION} Service
66+
Description=Slskd Service
6867
After=network.target
6968
Wants=network.target
7069
7170
[Service]
72-
WorkingDirectory=/opt/${APPLICATION}
73-
ExecStart=/opt/${APPLICATION}/slskd --config /opt/${APPLICATION}/config/slskd.yml
71+
WorkingDirectory=/opt/slskd
72+
ExecStart=/opt/slskd/slskd --config /opt/slskd/config/slskd.yml
7473
Restart=always
7574
7675
[Install]
7776
WantedBy=multi-user.target
7877
EOF
7978

80-
cat <<EOF >/etc/systemd/system/soularr.timer
79+
if [[ -d /opt/soularr ]]; then
80+
cat <<EOF >/etc/systemd/system/soularr.timer
8181
[Unit]
8282
Description=Soularr service timer
8383
RefuseManualStart=no
8484
RefuseManualStop=no
8585
8686
[Timer]
8787
Persistent=true
88-
# run every 5 minutes
89-
OnCalendar=*-*-* *:0/5:00
88+
# run every 10 minutes
89+
OnCalendar=*-*-* *:0/10:00
9090
Unit=soularr.service
9191
9292
[Install]
9393
WantedBy=timers.target
9494
EOF
9595

96-
cat <<EOF >/etc/systemd/system/soularr.service
96+
cat <<EOF >/etc/systemd/system/soularr.service
9797
[Unit]
9898
Description=Soularr service
9999
After=network.target slskd.service
@@ -106,10 +106,9 @@ ExecStart=/bin/bash -c /opt/soularr/run.sh
106106
[Install]
107107
WantedBy=multi-user.target
108108
EOF
109-
systemctl enable -q --now ${APPLICATION}
110-
systemctl enable -q soularr.timer
111-
rm -rf $tmp_file
112-
rm -rf /tmp/main.zip
109+
msg_warn "Add your Lidarr API key to Soularr in '/opt/soularr/config.ini', then run 'systemctl enable --now soularr.timer'"
110+
fi
111+
systemctl enable -q --now slskd
113112
msg_ok "Created Services"
114113

115114
motd_ssh

0 commit comments

Comments
 (0)