2
0
mirror of https://github.com/spritsail/plex-media-server.git synced 2024-11-08 18:56:22 +00:00
plex-media-server/entrypoint

36 lines
989 B
Plaintext
Raw Normal View History

2018-08-19 19:27:47 +00:00
#!/bin/sh
set -e
# ANSI colour escape sequences
RED='\033[0;31m'
RESET='\033[0m'
2018-08-19 19:27:47 +00:00
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}"
2018-08-19 19:27:47 +00:00
2>&1 echo
2>&1 echo -e "${RED}#######################################################${RESET}"
2018-08-19 19:27:47 +00:00
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
2018-08-19 19:27:47 +00:00
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"
2018-08-19 19:27:47 +00:00
EOF