git.iko.soy/typeable/nixpkgs
on master help sign in
plex: Don't overwrite primary database on restart

This change fixes two major issues: 1. If you don't use SIGQUIT to stop Plex it will corrupt its own database :( 2. Newer versions of Plex keep metadata in the `com.plexapp.plugins.library.db` database. This is the file that we copy into `/var/lib/plex/.skeleton`. If we copy the empty database on top of this one the user will lose their entire library metadata. This change skips the copy if the file already exists.

commit5a50b266624bceee5243c6eadf86d958768bfa6c authorPeter Jones <pjones@devalot.com> dateFri 14 Apr 2017, 11:19 (10 years ago) parent3ed0d7e
1 file changed+4−1
nixos/modules/services/misc/plex.nix+4−1
nixos/modules/services/misc/plex.nix+4−1
@@ -93,7 +93,9 @@ in
9393 # why this is done.
9494 test -d "${cfg.dataDir}/.skeleton" || mkdir "${cfg.dataDir}/.skeleton"
9595 for db in "com.plexapp.plugins.library.db"; do
96− cp "${cfg.package}/usr/lib/plexmediaserver/Resources/base_$db" "${cfg.dataDir}/.skeleton/$db"
96+ if [ ! -e "${cfg.dataDir}/.skeleton/$db" ]; then
97+ cp "${cfg.package}/usr/lib/plexmediaserver/Resources/base_$db" "${cfg.dataDir}/.skeleton/$db"
98+ fi
9799 chmod u+w "${cfg.dataDir}/.skeleton/$db"
98100 chown ${cfg.user}:${cfg.group} "${cfg.dataDir}/.skeleton/$db"
99101 done
@@ -136,6 +138,7 @@ in
136138 Group = cfg.group;
137139 PermissionsStartOnly = "true";
138140 ExecStart = "/bin/sh -c ${cfg.package}/usr/lib/plexmediaserver/Plex\\ Media\\ Server";
141+ KillSignal = "SIGQUIT";
139142 Restart = "on-failure";
140143 };
141144 environment = {