diff options
Diffstat (limited to 'multimedia/plexmediaserver-plexpass/files/plexmediaserver_plexpass.in')
-rw-r--r-- | multimedia/plexmediaserver-plexpass/files/plexmediaserver_plexpass.in | 92 |
1 files changed, 28 insertions, 64 deletions
diff --git a/multimedia/plexmediaserver-plexpass/files/plexmediaserver_plexpass.in b/multimedia/plexmediaserver-plexpass/files/plexmediaserver_plexpass.in index fe1165d8a77..b3b1af40186 100644 --- a/multimedia/plexmediaserver-plexpass/files/plexmediaserver_plexpass.in +++ b/multimedia/plexmediaserver-plexpass/files/plexmediaserver_plexpass.in @@ -3,50 +3,49 @@ # # $FreeBSD$ # -# PROVIDE: plexmediaserver_plexpass +# PROVIDE: %%PORTNAME%% # REQUIRE: LOGIN # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf to enable the Plex Media Server: # -# plexmediaserver_plexpass_enable="YES" +# %%PORTNAME%%_enable="YES" # -# plexmediaserver_plexpass_support_path="%%SUPPORT_PATH%%" # Plex data: logs, media metadata, settings, etc +# %%PORTNAME%%_support_path="%%PREFIX%%/plexdata" # Plex data: logs, media metadata, settings, etc # -# plexmediaserver_plexpass_tmp="/var/tmp/plex" # configure tmp directory used for the transcoding process if desired +# %%PORTNAME%%_tmp="/var/tmp/plex" # configure tmp directory used for the transcoding process if desired # -# plexmediaserver_plexpass_maxplugins="6" # Maximum number of background plugin procs. May have to raise in rare cases. +# %%PORTNAME%%_maxplugins="6" # Maximum number of background plugin procs. May have to raise in rare cases. # . /etc/rc.subr -name=plexmediaserver_plexpass -rcvar=plexmediaserver_plexpass_enable +name=%%PORTNAME%% +rcvar=%%PORTNAME%%_enable load_rc_config $name -: ${plexmediaserver_plexpass_enable:=NO} -: ${plexmediaserver_plexpass_support_path="%%SUPPORT_PATH%%"} -: ${plexmediaserver_plexpass_user="%%USERS%%"} -: ${plexmediaserver_plexpass_group="%%GROUPS%%"} -: ${plexmediaserver_plexpass_maxplugins=6} +: ${%%PORTNAME%%_enable:=NO} +: ${%%PORTNAME%%_support_path="%%PREFIX%%/plexdata"} +: ${%%PORTNAME%%_user="%%USERS%%"} +: ${%%PORTNAME%%_group="%%GROUPS%%"} +: ${%%PORTNAME%%_maxplugins=6} -extra_commands=status +command=/usr/sbin/daemon +procname="%%DATADIR%%/Plex_Media_Server" +command_args="-f ${procname}" start_precmd=plex_precmd -start_cmd=plex_startcmd -status_cmd=plex_statuscmd -stop_cmd=plex_stopcmd pidfile=/var/run/plex/plex.pid plex_precmd() { - export SUPPORT_PATH="${plexmediaserver_plexpass_support_path}" - export HOME="${plexmediaserver_plexpass_support_path}/Plex Media Server" - export PYTHONHOME="%%SCRIPT_PATH%%/Resources/Python" - export SCRIPTPATH="%%SCRIPT_PATH%%" + export SUPPORT_PATH="${plexmediaserver_support_path}" + export HOME="${plexmediaserver_support_path}/Plex Media Server" + export PYTHONHOME="%%DATADIR%%/Resources/Python" + export SCRIPTPATH="%%DATADIR%%" export LD_LIBRARY_PATH="${SCRIPTPATH}" export PLEX_MEDIA_SERVER_HOME="${SCRIPTPATH}" - export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=${plexmediaserver_plexpass_maxplugins} - export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=${plexmediaserver_plexpass_support_path} + export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=${plexmediaserver_maxplugins} + export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=${plexmediaserver_support_path} export PLEX_MEDIA_SERVER_PIDFILE=${pidfile} export PATH="${SCRIPTPATH}/Resources/Python/bin:${PATH}" export LC_ALL="C" @@ -54,51 +53,16 @@ plex_precmd() ulimit -s 3000 if [ ! -d ${pidfile%/*} ]; then - install -d -o ${plexmediaserver_plexpass_user} ${pidfile%/*}; + install -d -o ${plexmediaserver_user} ${pidfile%/*}; fi - if [ ! -d "${plexmediaserver_plexpass_support_path}/Plex Media Server" ]; then - install -d -g ${plexmediaserver_plexpass_group} -o ${plexmediaserver_plexpass_user} "${plexmediaserver_plexpass_support_path}/Plex Media Server"; + if [ ! -d "${plexmediaserver_support_path}/Plex Media Server" ]; then + install -d -g ${plexmediaserver_group} -o ${plexmediaserver_user} "${plexmediaserver_support_path}/Plex Media Server"; fi - - if [ ${plexmediaserver_plexpass_tmp} ]; then - export TMPDIR=${plexmediaserver_plexpass_tmp}; - install -d -g ${plexmediaserver_plexpass_group} -o ${plexmediaserver_plexpass_user} "${plexmediaserver_plexpass_tmp}"; - fi -} - -plex_startcmd() -{ - if [ -f "${pidfile}" ] && (pgrep -F ${pidfile} Plex >/dev/null); then - echo "${name} is already running with pid: $(cat ${pidfile})"; - else - echo "Starting ${name}." - /usr/sbin/daemon -u ${plexmediaserver_plexpass_user} -f '%%SCRIPT_PATH%%/Plex Media Server' - fi -} - -plex_statuscmd() -{ - if [ -f "${pidfile}" ] && (pgrep -F ${pidfile} Plex >/dev/null); then - echo "${name} is running with pid: $(cat ${pidfile})"; - else - echo "${name} is not running."; - exit 1; - fi -} - -plex_stopcmd() -{ - if [ -f "${pidfile}" ] && (pgrep -F ${pidfile} Plex >/dev/null); then - main_pid=$(cat ${pidfile}); - child_pids=$(pgrep -P ${main_pid}); - all_pids="${main_pid} ${child_pids}" - kill ${sig_stop} ${all_pids}; - wait_for_pids ${all_pids}; - rm ${pidfile} - else - echo "${name} is not running."; - exit 1; + + if [ ${plexmediaserver_tmp} ]; then + export TMPDIR=${plexmediaserver_tmp}; + install -d -g ${plexmediaserver_group} -o ${plexmediaserver_user} "${plexmediaserver_tmp}"; fi } |