plex implements
This commit is contained in:
parent
b536df07a2
commit
1f377cf0b7
@ -14,7 +14,7 @@ m = taskd.docker_map("plex", "plex", "/usr/libexec/istorec/plex.sh",
|
||||
s = m:section(SimpleSection, translate("Service Status"), translate("Plex status:"))
|
||||
s:append(Template("plex/status"))
|
||||
|
||||
s = m:section(TypedSection, "plex", translate("Setup"), translate("The following parameters will only take effect during installation or upgrade:"))
|
||||
s = m:section(TypedSection, "main", translate("Setup"), translate("The following parameters will only take effect during installation or upgrade:"))
|
||||
s.addremove=false
|
||||
s.anonymous=true
|
||||
|
||||
@ -22,8 +22,7 @@ o = s:option(Flag, "hostnet", translate("Host network"), translate("Plex running
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "claim_token", translate("Plex Claim").."<b>*</b>")
|
||||
o.rmempty = false
|
||||
o = s:option(Value, "claim_token", translate("Plex Claim"))
|
||||
o.datatype = "string"
|
||||
|
||||
o = s:option(Value, "port", translate("Port").."<b>*</b>")
|
||||
@ -46,7 +45,7 @@ o = s:option(Value, "config_path", translate("Config path").."<b>*</b>")
|
||||
o.rmempty = false
|
||||
o.datatype = "string"
|
||||
|
||||
local paths, default_path = plex_model.find_paths(blocks, home, "config")
|
||||
local paths, default_path = plex_model.find_paths(blocks, home, "Configs")
|
||||
for _, val in pairs(paths) do
|
||||
o:value(val, val)
|
||||
end
|
||||
@ -54,11 +53,10 @@ o.default = default_path
|
||||
|
||||
o = s:option(Value, "media_path", translate("Media path"))
|
||||
o.datatype = "string"
|
||||
o.default = plex_model.media_path(home)
|
||||
|
||||
o = s:option(Value, "cache_path", translate("Transcode cache path"), translate("Default use 'transcodes' in 'config path' if not set, please make sure there has enough space"))
|
||||
o.datatype = "string"
|
||||
local paths, default_path = plex_model.find_paths(blocks, home, "transcodes")
|
||||
local paths, default_path = plex_model.find_paths(blocks, home, "Caches")
|
||||
for _, val in pairs(paths) do
|
||||
o:value(val, val)
|
||||
end
|
||||
|
@ -23,32 +23,32 @@ end
|
||||
|
||||
plex.home = function()
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local data = uci:get_first("linkease", "linkease", "local_home", "/root")
|
||||
return data
|
||||
local home_dirs = {}
|
||||
home_dirs["main_dir"] = uci:get_first("quickstart", "main", "main_dir", "/root")
|
||||
home_dirs["Configs"] = uci:get_first("quickstart", "main", "conf_dir", home_dirs["main_dir"].."/Configs")
|
||||
home_dirs["Downloads"] = uci:get_first("quickstart", "main", "dl_dir", home_dirs["main_dir"].."/Downloads")
|
||||
home_dirs["Caches"] = uci:get_first("quickstart", "main", "tmp_dir", home_dirs["main_dir"].."/Caches")
|
||||
return home_dirs
|
||||
end
|
||||
|
||||
plex.find_paths = function(blocks, home, path_name)
|
||||
plex.find_paths = function(blocks, home_dirs, path_name)
|
||||
local default_path = ''
|
||||
local configs = {}
|
||||
|
||||
default_path = home_dirs[path_name] .. "/Plex"
|
||||
if #blocks == 0 then
|
||||
default_path = home .. "/Programs/plex/" .. path_name
|
||||
table.insert(configs, default_path)
|
||||
else
|
||||
for _, val in pairs(blocks) do
|
||||
table.insert(configs, val .. "/Programs/plex/" .. path_name)
|
||||
table.insert(configs, val .. "/" .. path_name .. "/Plex")
|
||||
end
|
||||
local without_conf_dir = "/root/" .. path_name .. "/Plex"
|
||||
if default_path == without_conf_dir then
|
||||
default_path = configs[1]
|
||||
end
|
||||
default_path = configs[1]
|
||||
end
|
||||
|
||||
return configs, default_path
|
||||
end
|
||||
|
||||
plex.media_path = function(home)
|
||||
if home == "/root" then
|
||||
return ""
|
||||
else
|
||||
return home .. "/Downloads"
|
||||
end
|
||||
end
|
||||
|
||||
return plex
|
||||
|
@ -1,4 +1,4 @@
|
||||
config plex
|
||||
config main
|
||||
option 'hostnet' '0'
|
||||
option 'claim_token' ''
|
||||
option 'port' '32400'
|
||||
|
@ -5,13 +5,13 @@ ACTION=${1}
|
||||
shift 1
|
||||
|
||||
do_install() {
|
||||
local hostnet=`uci get plex.@plex[0].hostnet 2>/dev/null`
|
||||
local claim_token==`uci get plex.@plex[0].claim_token 2>/dev/null`
|
||||
local port=`uci get plex.@plex[0].port 2>/dev/null`
|
||||
local image_name=`uci get plex.@plex[0].image_name 2>/dev/null`
|
||||
local config=`uci get plex.@plex[0].config_path 2>/dev/null`
|
||||
local media=`uci get plex.@plex[0].media_path 2>/dev/null`
|
||||
local cache=`uci get plex.@plex[0].cache_path 2>/dev/null`
|
||||
local hostnet=`uci get plex.@main[0].hostnet 2>/dev/null`
|
||||
local claim_token==`uci get plex.@main[0].claim_token 2>/dev/null`
|
||||
local port=`uci get plex.@main[0].port 2>/dev/null`
|
||||
local image_name=`uci get plex.@main[0].image_name 2>/dev/null`
|
||||
local config=`uci get plex.@main[0].config_path 2>/dev/null`
|
||||
local media=`uci get plex.@main[0].media_path 2>/dev/null`
|
||||
local cache=`uci get plex.@main[0].cache_path 2>/dev/null`
|
||||
|
||||
[ -z "$image_name" ] && image_name="plexinc/pms-docker:latest"
|
||||
echo "docker pull ${image_name}"
|
||||
@ -25,7 +25,7 @@ do_install() {
|
||||
|
||||
[ -z "$port" ] && port=32400
|
||||
|
||||
local cmd="docker run --restart=unless-stopped -d -e PLEX_CLAIM="$claim_token" -v \"$config:/config\" "
|
||||
local cmd="docker run --restart=unless-stopped -d -h PlexServer -v \"$config:/config\" "
|
||||
|
||||
if [ -d /dev/dri ]; then
|
||||
cmd="$cmd\
|
||||
@ -43,7 +43,6 @@ do_install() {
|
||||
-p 3005:3005/tcp \
|
||||
-p 8324:8324/tcp \
|
||||
-p 32469:32469/tcp \
|
||||
-p 1900:1900/udp \
|
||||
-p 32410:32410/udp \
|
||||
-p 32412:32412/udp \
|
||||
-p 32413:32413/udp \
|
||||
@ -54,12 +53,14 @@ do_install() {
|
||||
local tz="`cat /tmp/TZ`"
|
||||
[ -z "$tz" ] || cmd="$cmd -e TZ=$tz"
|
||||
|
||||
[ -z "$cache" ] || cmd="$cmd -v \"$cache:/config/transcodes\""
|
||||
[ -z "$media" ] || cmd="$cmd -v \"$media:/media\""
|
||||
[ -z "$claim_token" ] || cmd="$cmd -e \"PLEX_CLAIM=$claim_token\""
|
||||
|
||||
[ -z "$cache" ] || cmd="$cmd -v \"$cache:/transcode\""
|
||||
[ -z "$media" ] || cmd="$cmd -v \"$media:/data\""
|
||||
|
||||
cmd="$cmd -v /mnt:/mnt"
|
||||
mountpoint -q /mnt && cmd="$cmd:rslave"
|
||||
cmd="$cmd --name plex \"$IMAGE_NAME\""
|
||||
cmd="$cmd --name plex \"$image_name\""
|
||||
|
||||
echo "$cmd"
|
||||
eval "$cmd"
|
||||
@ -71,8 +72,8 @@ usage() {
|
||||
echo " install Install the plex"
|
||||
echo " upgrade Upgrade the plex"
|
||||
echo " rm/start/stop/restart Remove/Start/Stop/Restart the plex"
|
||||
echo " status Heimdall status"
|
||||
echo " port Heimdall port"
|
||||
echo " status Plex status"
|
||||
echo " port Plex port"
|
||||
}
|
||||
|
||||
case ${ACTION} in
|
||||
@ -92,7 +93,8 @@ case ${ACTION} in
|
||||
docker ps --all -f 'name=plex' --format '{{.State}}'
|
||||
;;
|
||||
"port")
|
||||
docker ps --all -f 'name=plex' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
|
||||
local port=`uci get plex.@main[0].port 2>/dev/null`
|
||||
echo $port
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
|
Loading…
x
Reference in New Issue
Block a user