Skip to content

Commit 03edfce

Browse files
authored
fix(bazarr): store data in /var/lib/bazarr instead of inside /opt/bazarr (#16098)
* fix(bazarr): store data in /var/lib/bazarr instead of inside /opt/bazarr The installer creates /var/lib/bazarr and update_script() uses it as the "is Bazarr installed" guard, but nothing pointed Bazarr at it. Bazarr defaults its data directory to <install dir>/data, resolved from its own source file rather than WorkingDirectory, so a stock container kept config/ db/ backup/ cache/ log/ restore/ in /opt/bazarr/data - the directory fetch_and_deploy_gh_release redeploys over - while /var/lib/bazarr stayed empty. Pass -c /var/lib/bazarr in the unit, matching the -data= flag the other *arr scripts use. bazarr.py re-execs its child with sys.argv[1:], so the flag survives the restart Bazarr performs while loading its config. update_script() gains a one-time migration for existing installs. It runs outside the release check so containers already on the latest version are migrated too, is skipped when the unit already names a data directory, refuses (before stopping the service) when both locations hold data, and copies before removing so a failed migration leaves the original database in place. Fixes #16097 * fix(bazarr): drop explanatory comments per review
1 parent bc488e4 commit 03edfce

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

ct/bazarr.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ function update_script() {
2828
msg_error "No ${APP} Installation Found!"
2929
exit
3030
fi
31+
32+
if ! grep -qE -- "bazarr\.py.*[[:space:]](-c|--config)([[:space:]]|=)" /etc/systemd/system/bazarr.service 2>/dev/null; then
33+
if [[ -d /opt/bazarr/data && ! -L /opt/bazarr/data && -n "$(ls -A /var/lib/bazarr/ 2>/dev/null)" ]]; then
34+
msg_error "/opt/bazarr/data and /var/lib/bazarr both contain data - refusing to merge them. Keep the copy you want in /var/lib/bazarr, remove /opt/bazarr/data, then run the update again."
35+
exit 1
36+
fi
37+
38+
msg_info "Moving Bazarr data to /var/lib/bazarr"
39+
systemctl stop bazarr
40+
if [[ -L /opt/bazarr/data ]]; then
41+
rm -f /opt/bazarr/data
42+
elif [[ -d /opt/bazarr/data ]]; then
43+
if ! cp -a /opt/bazarr/data/. /var/lib/bazarr/; then
44+
systemctl start bazarr
45+
msg_error "Could not copy /opt/bazarr/data to /var/lib/bazarr - nothing was removed."
46+
exit 1
47+
fi
48+
rm -rf /opt/bazarr/data
49+
fi
50+
sed -i -E "s|^(ExecStart=.*bazarr\.py.*)$|\1 -c /var/lib/bazarr|" /etc/systemd/system/bazarr.service
51+
systemctl daemon-reload
52+
systemctl start bazarr
53+
msg_ok "Moved Bazarr data to /var/lib/bazarr"
54+
fi
55+
3156
if check_for_gh_release "bazarr" "morpheus65535/bazarr"; then
3257
msg_info "Stopping Service"
3358
systemctl stop bazarr

install/bazarr-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ UMask=0002
3636
Restart=on-failure
3737
RestartSec=5
3838
Type=simple
39-
ExecStart=/opt/bazarr/venv/bin/python3 /opt/bazarr/bazarr.py
39+
ExecStart=/opt/bazarr/venv/bin/python3 /opt/bazarr/bazarr.py -c /var/lib/bazarr
4040
KillSignal=SIGINT
4141
TimeoutStopSec=20
4242
SyslogIdentifier=bazarr

0 commit comments

Comments
 (0)