2
0
mirror of https://github.com/spritsail/plex-media-server.git synced 2024-11-05 01:16:23 +00:00
plex-media-server/entrypoint

36 lines
989 B
Bash
Executable File

#!/bin/sh
set -e
# ANSI colour escape sequences
RED='\033[0;31m'
RESET='\033[0m'
if su-exec -e [ ! -w "/config" ]; then
2>&1 echo -e "${RED}####################### WARNING #######################${RESET}"
2>&1 echo
2>&1 echo -e "${RED} No permission to write in '/config' directory.${RESET}"
2>&1 echo -e "${RED} Correcting permissions to prevent a crash.${RESET}"
2>&1 echo
2>&1 echo -e "${RED}#######################################################${RESET}"
chown $SUID:$SGID /config
chmod o+rw /config
fi
exec su-exec -e sh <<EOF
# Generate a default configuration on first run, including some user-specified values
if [ ! -e "/config/Preferences.xml" ]; then
gen-config.sh
fi
# Duplicate the Plex logs to stdout (docker logs)
tail -Fn 0 "/config/Logs/Plex Media Server.log" 2>/dev/null &
# Use a random pidfile
export PLEX_MEDIA_SERVER_PIDFILE="\$(mktemp -ut pms-pid.XXXXXX)"
exec "\$PLEX_MEDIA_SERVER_HOME/Plex Media Server"
EOF