mirror of
https://github.com/spritsail/plex-media-server.git
synced 2024-12-20 11:34:36 +00:00
Merge branch 'master' into pass
This commit is contained in:
commit
b073d8f6da
39
entrypoint
39
entrypoint
@ -3,29 +3,54 @@ set -e
|
|||||||
|
|
||||||
# ANSI colour escape sequences
|
# ANSI colour escape sequences
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
|
CYANBOLD='\033[1;36m'
|
||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
|
|
||||||
if su-exec -e [ ! -w "/config" ]; then
|
CONFIG_DIR="/config"
|
||||||
|
OLD_CONFIG="/config/Plex Media Server"
|
||||||
|
|
||||||
|
if [ -d "$OLD_CONFIG" ] && mountpoint -q "$OLD_CONFIG"; then
|
||||||
|
rm -rf /var/lib/plexmediaserver
|
||||||
|
ln -sf "$CONFIG_DIR" /var/lib/plexmediaserver
|
||||||
|
|
||||||
|
2>&1 echo -e "${RED}####################### NOTICE #######################${RESET}"
|
||||||
|
2>&1 echo
|
||||||
|
2>&1 echo -e "${RED} The config mountpoint has changed!${RESET}"
|
||||||
|
2>&1 echo -e "${RED} Please change the volume as follows:${RESET}"
|
||||||
|
2>&1 echo
|
||||||
|
2>&1 echo -e "${CYANBOLD} '$OLD_CONFIG'${RESET} -> ${CYANBOLD}'$CONFIG_DIR'${RESET}"
|
||||||
|
2>&1 echo
|
||||||
|
2>&1 echo -e "${RED}######################################################${RESET}"
|
||||||
|
2>&1 echo
|
||||||
|
|
||||||
|
CONFIG_DIR="$OLD_CONFIG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if su-exec -e [ ! -w "$CONFIG_DIR" ]; then
|
||||||
2>&1 echo -e "${RED}####################### WARNING #######################${RESET}"
|
2>&1 echo -e "${RED}####################### WARNING #######################${RESET}"
|
||||||
2>&1 echo
|
2>&1 echo
|
||||||
2>&1 echo -e "${RED} No permission to write in '/config' directory.${RESET}"
|
2>&1 echo -e "${RED} No permission to write in '$CONFIG_DIR' directory.${RESET}"
|
||||||
2>&1 echo -e "${RED} Correcting permissions to prevent a crash.${RESET}"
|
2>&1 echo -e "${RED} Correcting permissions to prevent a crash.${RESET}"
|
||||||
2>&1 echo
|
2>&1 echo
|
||||||
2>&1 echo -e "${RED}#######################################################${RESET}"
|
2>&1 echo -e "${RED}#######################################################${RESET}"
|
||||||
|
2>&1 echo
|
||||||
|
|
||||||
chown $SUID:$SGID /config
|
chown $SUID:$SGID "$CONFIG_DIR"
|
||||||
chmod o+rw /config
|
chmod o+rw "$CONFIG_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
export CONFIG_DIR
|
||||||
|
export PREF_FILE="$CONFIG_DIR/Preferences.xml"
|
||||||
|
|
||||||
exec su-exec -e sh <<EOF
|
exec su-exec -e sh <<EOF
|
||||||
|
|
||||||
# Generate a default configuration on first run, including some user-specified values
|
# Generate a default configuration on first run, including some user-specified values
|
||||||
if [ ! -e "/config/Preferences.xml" ]; then
|
if [ ! -e "\$PREF_FILE" ]; then
|
||||||
gen-config.sh
|
source gen-config.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Duplicate the Plex logs to stdout (docker logs)
|
# Duplicate the Plex logs to stdout (docker logs)
|
||||||
tail -Fn 0 "/config/Logs/Plex Media Server.log" 2>/dev/null &
|
tail -Fn 0 "\$CONFIG_DIR/Logs/Plex Media Server.log" 2>/dev/null &
|
||||||
|
|
||||||
# Use a random pidfile
|
# Use a random pidfile
|
||||||
export PLEX_MEDIA_SERVER_PIDFILE="\$(mktemp -ut pms-pid.XXXXXX)"
|
export PLEX_MEDIA_SERVER_PIDFILE="\$(mktemp -ut pms-pid.XXXXXX)"
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
PREF_FILE="${1:-/config/Preferences.xml}"
|
CONFIG_DIR="${CONFIG_DIR:-/config}"
|
||||||
|
PREF_FILE="${PREF_FILE:-"$CONFIG_DIR/Preferences.xml"}"
|
||||||
|
|
||||||
getPref() {
|
getPref() {
|
||||||
xmlstarlet sel -T -t -m "/Preferences" -v "@$1" -n "${PREF_FILE}"
|
xmlstarlet sel -T -t -m "/Preferences" -v "@$1" -n "${PREF_FILE}"
|
||||||
@ -16,7 +17,7 @@ setPref() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Create a default config file allowing external access
|
# Create a default config file allowing external access
|
||||||
echo -e $'<?xml version="1.0" encoding="utf-8"?>\n<Preferences />' > "/config/Preferences.xml"
|
echo -e $'<?xml version="1.0" encoding="utf-8"?>\n<Preferences />' > "${PREF_FILE}"
|
||||||
|
|
||||||
# Enforced defaults. These can be changed manually afterwards.
|
# Enforced defaults. These can be changed manually afterwards.
|
||||||
setPref "AcceptedEULA" "1"
|
setPref "AcceptedEULA" "1"
|
||||||
|
Loading…
Reference in New Issue
Block a user