Skip to content

Commit 57b8017

Browse files
committed
Update Soularr install & update
1 parent 1edb423 commit 57b8017

2 files changed

Lines changed: 92 additions & 73 deletions

File tree

ct/slskd.sh

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,39 @@ function update_script() {
5151
msg_ok "Started Service(s)"
5252
msg_ok "Updated successfully!"
5353
fi
54-
# [[ -d /opt/soularr ]] && if check_for_gh_release "Soularr" "mrusse/soularr"; then
55-
# if systemctl is-active soularr.timer; 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-
# $STD pip install -r requirements.txt
65-
# mv /opt/config.ini.bak /opt/soularr/config.ini
66-
# mv /opt/run.sh.bak /opt/soularr/run.sh
67-
# rm -rf /tmp/main.zip
68-
# msg_ok "Updated soularr"
69-
#
70-
# msg_info "Starting soularr timer"
71-
# systemctl start soularr.timer
72-
# msg_ok "Started soularr timer"
73-
# fi
54+
[[ -d /opt/soularr ]] && if check_for_gh_release "Soularr" "mrusse/soularr"; then
55+
if systemctl is-active soularr.timer; 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"
65+
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+
mv /opt/config.ini.bak /opt/soularr/config.ini
74+
mv /opt/run.sh.bak /opt/soularr/run.sh
75+
deactivate
76+
msg_ok "Updated Soularr"
77+
78+
msg_info "Restoring Soularr config"
79+
mv /opt/soularr_config.ini.bak /opt/soularr/config.ini
80+
mv /opt/soularr_run.sh.bak /opt/soularr/run.sh
81+
msg_ok "Restored Soularr config"
82+
83+
msg_info "Starting Soularr Timer"
84+
systemctl restart soularr.timer
85+
msg_ok "Started Soularr Timer"
86+
fi
7487
}
7588

7689
start

install/slskd-install.sh

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,33 @@ sed -i \
3232
-e 's/^.*picture/#&/' /opt/slskd/config/slskd.yml
3333
msg_ok "Configured Slskd"
3434

35-
# read -rp "${TAB3}Do you want to install Soularr? y/N " soularr
36-
# if [[ ${soularr,,} =~ ^(y|yes)$ ]]; then
37-
# msg_info "Installing Dependencies"
38-
# $STD apt install -y python3-pip
39-
# msg_ok "Installed Dependencies"
40-
# cd /opt/soularr
41-
# $STD pip install -r requirements.txt
42-
# sed -i \
43-
# -e "\|[Slskd]|,\|host_url|s|yourslskdapikeygoeshere|$SLSKD_API_KEY|" \
44-
# -e "/host_url/s/slskd/localhost/" \
45-
# /opt/soularr/config.ini
46-
# sed -i \
47-
# -e "/#This\|#Default\|INTERVAL/{N;d;}" \
48-
# -e "/while\|#Pass/d" \
49-
# -e "\|python|s|app|opt/soularr|; s|python|python3|" \
50-
# -e "/dt/,+2d" \
51-
# /opt/soularr/run.sh
52-
# sed -i -E "/(soularr.py)/s/.{5}$//; /if/,/fi/s/.{4}//" /opt/soularr/run.sh
53-
# chmod +x /opt/soularr/run.sh
54-
# msg_ok "Installed Soularr"
55-
# fi
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
5662

5763
msg_info "Creating Service"
5864
cat <<EOF >/etc/systemd/system/slskd.service
@@ -70,38 +76,38 @@ Restart=always
7076
WantedBy=multi-user.target
7177
EOF
7278

73-
# if [[ -d /opt/soularr ]]; then
74-
# cat <<EOF >/etc/systemd/system/soularr.timer
75-
# [Unit]
76-
# Description=Soularr service timer
77-
# RefuseManualStart=no
78-
# RefuseManualStop=no
79-
#
80-
# [Timer]
81-
# Persistent=true
82-
# # run every 5 minutes
83-
# OnCalendar=*-*-* *:0/5:00
84-
# Unit=soularr.service
85-
#
86-
# [Install]
87-
# WantedBy=timers.target
88-
# EOF
89-
#
90-
# cat <<EOF >/etc/systemd/system/soularr.service
91-
# [Unit]
92-
# Description=Soularr service
93-
# After=network.target slskd.service
94-
#
95-
# [Service]
96-
# Type=simple
97-
# WorkingDirectory=/opt/soularr
98-
# ExecStart=/bin/bash -c /opt/soularr/run.sh
99-
#
100-
# [Install]
101-
# WantedBy=multi-user.target
102-
# EOF
103-
# msg_warn "Add your Lidarr API key to Soularr in '/opt/soularr/config.ini', then run 'systemctl enable --now soularr.timer'"
104-
# fi
79+
if [[ -d /opt/soularr ]]; then
80+
cat <<EOF >/etc/systemd/system/soularr.timer
81+
[Unit]
82+
Description=Soularr service timer
83+
RefuseManualStart=no
84+
RefuseManualStop=no
85+
86+
[Timer]
87+
Persistent=true
88+
# run every 10 minutes
89+
OnCalendar=*-*-* *:0/10:00
90+
Unit=soularr.service
91+
92+
[Install]
93+
WantedBy=timers.target
94+
EOF
95+
96+
cat <<EOF >/etc/systemd/system/soularr.service
97+
[Unit]
98+
Description=Soularr service
99+
After=network.target slskd.service
100+
101+
[Service]
102+
Type=simple
103+
WorkingDirectory=/opt/soularr
104+
ExecStart=/bin/bash -c /opt/soularr/run.sh
105+
106+
[Install]
107+
WantedBy=multi-user.target
108+
EOF
109+
msg_warn "Add your Lidarr API key to Soularr in '/opt/soularr/config.ini', then run 'systemctl enable --now soularr.timer'"
110+
fi
105111
systemctl enable -q --now slskd
106112
msg_ok "Created Services"
107113

0 commit comments

Comments
 (0)