2
0
mirror of https://github.com/spritsail/plex-media-server.git synced 2025-06-25 19:30:55 +00:00

Allow server claiming at any time

This commit is contained in:
2018-10-04 12:48:52 +01:00
parent e36ec1723e
commit dac8a21edc
5 changed files with 94 additions and 36 deletions

14
plex-util.sh Normal file
View File

@ -0,0 +1,14 @@
CONFIG_DIR="${CONFIG_DIR:-/config}"
PREF_FILE="${PREF_FILE:-"$CONFIG_DIR/Preferences.xml"}"
getPref() {
xmlstarlet sel -T -t -m "/Preferences" -v "@$1" -n "${PREF_FILE}"
}
setPref() {
count="$(xmlstarlet sel -t -v "count(/Preferences/@$1)" "${PREF_FILE}")"
if [ $(($count + 0)) -gt 0 ]; then
xmlstarlet ed --inplace --update "/Preferences/@$1" -v "$2" "${PREF_FILE}" 2>/dev/null
else
xmlstarlet ed --inplace --insert "/Preferences" --type attr -n "$1" -v "$2" "${PREF_FILE}" 2>/dev/null
fi
}