update jellyfin (#3)
This commit is contained in:
parent
c00d8b92d4
commit
32c7c28ea0
@ -2,16 +2,18 @@
|
|||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-jellyfin
|
PKG_VERSION:=1.0.2
|
||||||
PKG_VERSION:=1.0.1
|
PKG_RELEASE:=20211015
|
||||||
PKG_RELEASE:=20211014
|
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI support for jellyfin
|
LUCI_TITLE:=LuCI support for jellyfin
|
||||||
LUCI_PKGARCH:=all
|
LUCI_PKGARCH:=all
|
||||||
LUCI_DEPENDS:=+docker +luci-app-dockerman
|
LUCI_DEPENDS:=+docker +luci-app-dockerman
|
||||||
|
|
||||||
|
define Package/luci-app-jellyfin/conffiles
|
||||||
|
/etc/config/jellyfin
|
||||||
|
endef
|
||||||
|
|
||||||
include $(TOPDIR)/feeds/luci/luci.mk
|
include $(TOPDIR)/feeds/luci/luci.mk
|
||||||
|
|
||||||
# call BuildPackage - OpenWrt buildroot signature
|
# call BuildPackage - OpenWrt buildroot signature
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ function index()
|
|||||||
entry({"admin", "services", "jellyfin",'client'}, cbi("jellyfin/status", {hideresetbtn=true, hidesavebtn=true}), _("Jellyfin"), 20).leaf = true
|
entry({"admin", "services", "jellyfin",'client'}, cbi("jellyfin/status", {hideresetbtn=true, hidesavebtn=true}), _("Jellyfin"), 20).leaf = true
|
||||||
-- entry({'admin', 'services', 'jellyfin', 'script'}, form('jellyfin/script'), _('Script'), 20).leaf = true -- 直接配置脚本
|
-- entry({'admin', 'services', 'jellyfin', 'script'}, form('jellyfin/script'), _('Script'), 20).leaf = true -- 直接配置脚本
|
||||||
|
|
||||||
entry({"admin", "services", "jellyfin","status"}, call("container_status"))
|
entry({"admin", "services", "jellyfin","status"}, call("get_container_status"))
|
||||||
entry({"admin", "services", "jellyfin","stop"}, call("stop_container"))
|
entry({"admin", "services", "jellyfin","stop"}, post("stop_container"))
|
||||||
entry({"admin", "services", "jellyfin","start"}, call("start_container"))
|
entry({"admin", "services", "jellyfin","start"}, post("start_container"))
|
||||||
entry({"admin", "services", "jellyfin","install"}, call("install_container"))
|
entry({"admin", "services", "jellyfin","install"}, post("install_container"))
|
||||||
entry({"admin", "services", "jellyfin","uninstall"}, call("uninstall_container"))
|
entry({"admin", "services", "jellyfin","uninstall"}, post("uninstall_container"))
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -25,10 +25,10 @@ function container_status()
|
|||||||
local docker_server_version = util.exec("docker info | grep 'Server Version'")
|
local docker_server_version = util.exec("docker info | grep 'Server Version'")
|
||||||
local docker_install = (string.len(docker_path) > 0)
|
local docker_install = (string.len(docker_path) > 0)
|
||||||
local docker_start = (string.len(docker_server_version) > 0)
|
local docker_start = (string.len(docker_server_version) > 0)
|
||||||
local port = tonumber(uci:get_first(keyword, keyword, "port"))
|
local port = tonumber(uci:get_first(keyword, keyword, "port", "8096"))
|
||||||
local container_id = util.trim(util.exec("docker ps -aqf'name='"..keyword.."''"))
|
local container_id = util.trim(util.exec("docker ps -aqf 'name="..keyword.."'"))
|
||||||
local container_install = (string.len(container_id) > 0)
|
local container_install = (string.len(container_id) > 0)
|
||||||
local container_running = (sys.call("pidof '"..keyword.."' >/dev/null") == 0)
|
local container_running = container_install and (string.len(util.trim(util.exec("docker ps -qf 'id="..container_id.."'"))) > 0)
|
||||||
|
|
||||||
local status = {
|
local status = {
|
||||||
docker_install = docker_install,
|
docker_install = docker_install,
|
||||||
@ -37,11 +37,18 @@ function container_status()
|
|||||||
container_install = container_install,
|
container_install = container_install,
|
||||||
container_running = container_running,
|
container_running = container_running,
|
||||||
container_port = (port or 8096),
|
container_port = (port or 8096),
|
||||||
|
media_path = uci:get_first(keyword, keyword, "media_path", "/mnt/sda1/media"),
|
||||||
|
config_path = uci:get_first(keyword, keyword, "config_path", "/root/jellyfin/config"),
|
||||||
|
cache_path = uci:get_first(keyword, keyword, "cache_path", ""),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return status
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_container_status()
|
||||||
|
local status = container_status()
|
||||||
luci.http.prepare_content("application/json")
|
luci.http.prepare_content("application/json")
|
||||||
luci.http.write_json(status)
|
luci.http.write_json(status)
|
||||||
return status
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function stop_container()
|
function stop_container()
|
||||||
@ -58,14 +65,24 @@ end
|
|||||||
|
|
||||||
function install_container()
|
function install_container()
|
||||||
|
|
||||||
docker:write_status("jellyfin installing\n")
|
|
||||||
local dk = docker.new()
|
|
||||||
local images = dk.images:list().body
|
|
||||||
local image = util.exec("sh /usr/share/jellyfin/install.sh -l")
|
local image = util.exec("sh /usr/share/jellyfin/install.sh -l")
|
||||||
local media_path = luci.http.formvalue("media")
|
local media_path = luci.http.formvalue("media")
|
||||||
local config_path = luci.http.formvalue("config")
|
local config_path = luci.http.formvalue("config")
|
||||||
|
local cache_path = luci.http.formvalue("cache")
|
||||||
|
local port = luci.http.formvalue("port")
|
||||||
|
|
||||||
|
uci:tset(keyword, "@"..keyword.."[0]", {
|
||||||
|
media_path = media_path or "/mnt/sda1/media",
|
||||||
|
config_path = config_path or "/root/jellyfin/config",
|
||||||
|
cache_path = cache_path or "",
|
||||||
|
port = port or "8096",
|
||||||
|
})
|
||||||
|
uci:save(keyword)
|
||||||
|
uci:commit(keyword)
|
||||||
|
|
||||||
local pull_image = function(image)
|
local pull_image = function(image)
|
||||||
docker:append_status("Images: " .. "pulling" .. " " .. image .. "...\n")
|
docker:append_status("Images: " .. "pulling" .. " " .. image .. "...\n")
|
||||||
|
local dk = docker.new()
|
||||||
local res = dk.images:create({query = {fromImage=image}}, docker.pull_image_show_status_cb)
|
local res = dk.images:create({query = {fromImage=image}}, docker.pull_image_show_status_cb)
|
||||||
if res and res.code and res.code == 200 and (res.body[#res.body] and not res.body[#res.body].error and res.body[#res.body].status and (res.body[#res.body].status == "Status: Downloaded newer image for ".. image or res.body[#res.body].status == "Status: Image is up to date for ".. image)) then
|
if res and res.code and res.code == 200 and (res.body[#res.body] and not res.body[#res.body].error and res.body[#res.body].status and (res.body[#res.body].status == "Status: Downloaded newer image for ".. image or res.body[#res.body].status == "Status: Image is up to date for ".. image)) then
|
||||||
docker:append_status("done\n")
|
docker:append_status("done\n")
|
||||||
@ -78,8 +95,8 @@ function install_container()
|
|||||||
local install_jellyfin = function()
|
local install_jellyfin = function()
|
||||||
local os = require "os"
|
local os = require "os"
|
||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
local c = ("sh /usr/share/jellyfin/install.sh -m " ..media_path.. " -c " ..config_path.. " -i >/tmp/log/jellyfin.stdout 2>/tmp/log/jellyfin.stderr")
|
local c = ("sh /usr/share/jellyfin/install.sh -i >/tmp/log/jellyfin.stdout 2>/tmp/log/jellyfin.stderr")
|
||||||
-- docker:write_status(c)
|
-- docker:append_status(c)
|
||||||
|
|
||||||
local r = os.execute(c)
|
local r = os.execute(c)
|
||||||
local e = fs.readfile("/tmp/log/jellyfin.stderr")
|
local e = fs.readfile("/tmp/log/jellyfin.stderr")
|
||||||
@ -89,9 +106,9 @@ function install_container()
|
|||||||
fs.unlink("/tmp/log/jellyfin.stdout")
|
fs.unlink("/tmp/log/jellyfin.stdout")
|
||||||
|
|
||||||
if r == 0 then
|
if r == 0 then
|
||||||
docker:write_status(o)
|
docker:append_status(o)
|
||||||
else
|
else
|
||||||
docker:write_status( e )
|
docker:append_status( e )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -102,20 +119,12 @@ function install_container()
|
|||||||
-- luci.http.prepare_content("application/json")
|
-- luci.http.prepare_content("application/json")
|
||||||
-- luci.http.write_json(status)
|
-- luci.http.write_json(status)
|
||||||
|
|
||||||
local exist_image = false
|
|
||||||
if image then
|
if image then
|
||||||
for _, v in ipairs (images) do
|
docker:write_status("jellyfin installing\n")
|
||||||
if v.RepoTags and v.RepoTags[1] == image then
|
|
||||||
exist_image = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not exist_image then
|
|
||||||
pull_image(image)
|
pull_image(image)
|
||||||
install_jellyfin()
|
install_jellyfin()
|
||||||
else
|
else
|
||||||
install_jellyfin()
|
docker:write_status("jellyfin image not defined!\n")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script type="text/javascript">//<![CDATA[
|
<script type="text/javascript">//<![CDATA[
|
||||||
XHR.poll(5,'<%=url("admin/services/jellyfin/status")%>', null,
|
XHR.poll(5,'<%=url("admin/services/jellyfin/status")%>', null,
|
||||||
function (x, st) {
|
function (x, st) {
|
||||||
var tb = document.getElementById('linkease_status');
|
var tb = document.getElementById('jellyfin_status');
|
||||||
if (st && tb) {
|
if (st && tb) {
|
||||||
if (st.docker_install){
|
if (st.docker_install){
|
||||||
if (st.docker_start){
|
if (st.docker_start){
|
||||||
@ -21,27 +21,43 @@
|
|||||||
else {
|
else {
|
||||||
let config = document.getElementById('config')
|
let config = document.getElementById('config')
|
||||||
if(!config){
|
if(!config){
|
||||||
tb.innerHTML = '<br/><em><%:The Jellyfin service is not installed.%></em>'
|
var configs = [
|
||||||
+ "<br/><br/><br/>config path:"
|
{id: "media", label: "<%:Media path%><sup>*</sup>:", value: st.media_path},
|
||||||
+ "<br/><input type=\"text\" class=\"cbi-input-text\" name=\"isrc\" id=\"config\" value=\"/root/jellyfin/config\" />"
|
{id: "config", label: "<%:Config path%><sup>*</sup>:", value: st.config_path},
|
||||||
+ "<br/><br/>media path:"
|
{id: "cache", label: "<%:Transcode cache path (optional)%>:", value: st.cache_path},
|
||||||
+ "<br/><input type=\"text\" class=\"cbi-input-text\" name=\"isrc\" id=\"media\" value=\"/mnt/sda1/media\"/>"
|
{id: "port", label: "<%:Port (optional)%>:", value: st.container_port},
|
||||||
+ "<br/><br/><input class=\"btn cbi-button cbi-button-apply\" type=\"button\" value=\" <%:install Jellyfin%> \" onclick=\"install_container()\" /><br/><br/>";
|
];
|
||||||
|
tb.innerHTML = '<br/><em><%:The Jellyfin service is not installed.%></em>';
|
||||||
|
configs.forEach(function(c){
|
||||||
|
tb.innerHTML += ("<div class=\"cbi-value\"><label class=\"cbi-value-title\" for=\"" + c.id + "\">" + c.label + "</label>"
|
||||||
|
+ "<div class=\"cbi-value-field\"><input type=\"text\" class=\"cbi-input-text\" id=\"" + c.id + "\" value=\"" + c.value + "\"/></div></div>");
|
||||||
|
});
|
||||||
|
tb.innerHTML += ("<div class=\"cbi-value\"><label class=\"cbi-value-title\"></label>"
|
||||||
|
+ "<div class=\"cbi-value-field\"><input class=\"btn cbi-button cbi-button-apply\" type=\"button\" value=\" <%:install Jellyfin%> \" onclick=\"install_container()\" /></div></div><br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
tb.innerHTML = '<em><%:Docker service is not start.%></em>'
|
tb.innerHTML = '<br/><em><%:Docker service is not start.%></em>'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
tb.innerHTML = '<em><%:Docker is not installed.%></em>'
|
tb.innerHTML = '<br/><em><%:Docker is not installed.%></em>'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var xhr_post = function(url, data, cb) {
|
||||||
|
data = data || {};
|
||||||
|
data.token = '<%=token%>';
|
||||||
|
cb || docker_status_message('notice', '<img src="/luci-static/resources/icons/loading.gif" alt="" style="vertical-align:middle" />');
|
||||||
|
new XHR().post(url, data, (x, d) => {
|
||||||
|
cb || docker_status_message();
|
||||||
|
cb && cb(x, d);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function open_container(x) {
|
function open_container(x) {
|
||||||
Url = "http://" + window.location.hostname + ":" + x
|
Url = "http://" + window.location.hostname + ":" + x
|
||||||
// alert(Url)
|
// alert(Url)
|
||||||
@ -53,9 +69,7 @@
|
|||||||
|
|
||||||
function stop_container(x) {
|
function stop_container(x) {
|
||||||
|
|
||||||
XHR.get(STOP_URL, { container_id: x }, (x, d) => {
|
xhr_post(STOP_URL, { container_id: x });
|
||||||
alert(" 关闭容器'" + d.container_id + "' ");
|
|
||||||
});
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,9 +77,7 @@
|
|||||||
|
|
||||||
function start_container(x) {
|
function start_container(x) {
|
||||||
|
|
||||||
XHR.get(START_URL, { container_id: x }, (x, d) => {
|
xhr_post(START_URL, { container_id: x });
|
||||||
// alert(" 打开容器'" + d.container_id + "' ");
|
|
||||||
});
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,9 +85,7 @@
|
|||||||
|
|
||||||
function uninstall_container(x) {
|
function uninstall_container(x) {
|
||||||
|
|
||||||
XHR.get(UNINSTALL_URL, { container_id: x }, (x, d) => {
|
xhr_post(UNINSTALL_URL, { container_id: x });
|
||||||
// alert(" 删除容器'" + d.container_id + "' ");
|
|
||||||
});
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,25 +94,31 @@
|
|||||||
function install_container(x) {
|
function install_container(x) {
|
||||||
let config = document.getElementById('config')
|
let config = document.getElementById('config')
|
||||||
let media = document.getElementById('media')
|
let media = document.getElementById('media')
|
||||||
|
let cache = document.getElementById('cache')
|
||||||
|
let port = document.getElementById('port').value
|
||||||
let media_path = media.value
|
let media_path = media.value
|
||||||
let config_path = config.value
|
let config_path = config.value
|
||||||
|
let cache_path = cache.value
|
||||||
|
|
||||||
uci_confirm_docker()
|
if (media_path == "" || config_path == "") {
|
||||||
XHR.get(INSTALL_URL, { media: media_path,config:config_path }, (x, d) => {
|
alert("<%:Media path and Config path could not be empty!%>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
xhr_post(INSTALL_URL, { media: media_path, config: config_path, cache: cache_path, port: port }, (x, d) => {
|
||||||
// alert(" 删除容器'" + d.image_name + "' ");
|
// alert(" 删除容器'" + d.image_name + "' ");
|
||||||
location.reload()
|
location.reload()
|
||||||
});
|
});
|
||||||
|
uci_confirm_docker();
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
//]]></script>
|
//]]></script>
|
||||||
|
|
||||||
<fieldset class="cbi-section">
|
<fieldset class="cbi-section">
|
||||||
<!-- <legend>
|
<fieldset class="cbi-section-node" id="jellyfin_status">
|
||||||
<%:Jellyfin Status%>
|
|
||||||
</legend> -->
|
|
||||||
<p id="linkease_status">
|
|
||||||
<em>
|
<em>
|
||||||
<%:Collecting data...%>
|
<%:Collecting data...%>
|
||||||
</em>
|
</em>
|
||||||
</p>
|
</fieldset>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -25,3 +25,17 @@ msgstr "安装Jellyfin"
|
|||||||
msgid "Collecting data..."
|
msgid "Collecting data..."
|
||||||
msgstr "收集数据..."
|
msgstr "收集数据..."
|
||||||
|
|
||||||
|
msgid "Media path"
|
||||||
|
msgstr "媒体文件路径"
|
||||||
|
|
||||||
|
msgid "Config path"
|
||||||
|
msgstr "配置数据路径"
|
||||||
|
|
||||||
|
msgid "Transcode cache path (optional)"
|
||||||
|
msgstr "转码缓存路径(选填)"
|
||||||
|
|
||||||
|
msgid "Port (optional)"
|
||||||
|
msgstr "端口(选填)"
|
||||||
|
|
||||||
|
msgid "Media path and Config path could not be empty!"
|
||||||
|
msgstr "媒体文件路径和配置数据路径不能为空!"
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
config jellyfin
|
config jellyfin
|
||||||
option 'port' '8096'
|
option 'port' '8096'
|
||||||
option 'enabled' '1'
|
option 'image' 'jjm2473/jellyfin-rtk:latest'
|
||||||
|
option 'media_path' '/mnt/sda1/media'
|
||||||
|
option 'config_path' '/root/jellyfin/config'
|
||||||
|
option 'cache_path' ''
|
||||||
|
@ -1,9 +1,25 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
image_name="jjm2473/jellyfin-rtk:latest"
|
|
||||||
config="/root/jellyfin/config"
|
image_name=`uci get jellyfin.@jellyfin[0].image 2>/dev/null`
|
||||||
media="/mnt/sda1/media"
|
|
||||||
|
[ -z "$image_name" ] && image_name="jjm2473/jellyfin-rtk:latest"
|
||||||
|
|
||||||
install(){
|
install(){
|
||||||
|
local media=`uci get jellyfin.@jellyfin[0].media_path 2>/dev/null`
|
||||||
|
local config=`uci get jellyfin.@jellyfin[0].config_path 2>/dev/null`
|
||||||
|
local cache=`uci get jellyfin.@jellyfin[0].cache_path 2>/dev/null`
|
||||||
|
local port=`uci get jellyfin.@jellyfin[0].port 2>/dev/null`
|
||||||
|
|
||||||
|
if [ -z "$media" -o -z "$config"]; then
|
||||||
|
echo "media path or config path is empty!" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local cachev
|
||||||
|
[ -z "$cache" ] || cachev="-v $cache:/config/transcodes"
|
||||||
|
|
||||||
|
[ -z "$port" ] && port=8096
|
||||||
|
|
||||||
docker run --restart=unless-stopped -d \
|
docker run --restart=unless-stopped -d \
|
||||||
--device /dev/rpc0:/dev/rpc0 \
|
--device /dev/rpc0:/dev/rpc0 \
|
||||||
--device /dev/rpc1:/dev/rpc1 \
|
--device /dev/rpc1:/dev/rpc1 \
|
||||||
@ -27,22 +43,16 @@ install(){
|
|||||||
-v /var/tmp/vowb:/var/tmp/vowb \
|
-v /var/tmp/vowb:/var/tmp/vowb \
|
||||||
--pid=host \
|
--pid=host \
|
||||||
--dns=172.17.0.1 \
|
--dns=172.17.0.1 \
|
||||||
-p 8096:8096 -v $config:/config -v $media:/media --name myjellyfin-rtk $image_name
|
-p $port:8096 -v "$config:/config" $cachev -v "$media:/media" --name myjellyfin-rtk "$image_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while getopts ":ilc:m:" optname
|
while getopts ":il" optname
|
||||||
do
|
do
|
||||||
case "$optname" in
|
case "$optname" in
|
||||||
"l")
|
"l")
|
||||||
echo -n $image_name
|
echo -n $image_name
|
||||||
;;
|
;;
|
||||||
"c")
|
|
||||||
config=$OPTARG
|
|
||||||
;;
|
|
||||||
"m")
|
|
||||||
media=$OPTARG
|
|
||||||
;;
|
|
||||||
"i")
|
"i")
|
||||||
install
|
install
|
||||||
;;
|
;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user