diff --git a/applications/luci-app-emby/root/usr/libexec/istorec/emby.sh b/applications/luci-app-emby/root/usr/libexec/istorec/emby.sh index 4ec8314..a308037 100755 --- a/applications/luci-app-emby/root/usr/libexec/istorec/emby.sh +++ b/applications/luci-app-emby/root/usr/libexec/istorec/emby.sh @@ -62,8 +62,8 @@ usage() { echo " install Install the emby" echo " upgrade Upgrade the emby" echo " rm/start/stop/restart Remove/Start/Stop/Restart the emby" - echo " status Plex status" - echo " port Plex port" + echo " status Emby status" + echo " port Emby port" } case ${ACTION} in diff --git a/applications/luci-app-photoprism/Makefile b/applications/luci-app-photoprism/Makefile new file mode 100644 index 0000000..9344ca1 --- /dev/null +++ b/applications/luci-app-photoprism/Makefile @@ -0,0 +1,18 @@ + + +include $(TOPDIR)/rules.mk + +PKG_VERSION:=1.0.0-20221106 +PKG_RELEASE:= + +LUCI_TITLE:=LuCI support for PhotoPrism +LUCI_PKGARCH:=all +LUCI_DEPENDS:=+docker +luci-lib-taskd + +define Package/luci-app-photoprism/conffiles +/etc/config/photoprism +endef + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/applications/luci-app-photoprism/luasrc/controller/photoprism.lua b/applications/luci-app-photoprism/luasrc/controller/photoprism.lua new file mode 100755 index 0000000..bc3c913 --- /dev/null +++ b/applications/luci-app-photoprism/luasrc/controller/photoprism.lua @@ -0,0 +1,7 @@ + +module("luci.controller.photoprism", package.seeall) + +function index() + entry({"admin", "services", "photoprism"}, alias("admin", "services", "photoprism", "config"), _("PhotoPrism"), 30).dependent = true + entry({"admin", "services", "photoprism", "config"}, cbi("photoprism")) +end diff --git a/applications/luci-app-photoprism/luasrc/model/cbi/photoprism.lua b/applications/luci-app-photoprism/luasrc/model/cbi/photoprism.lua new file mode 100644 index 0000000..40a907f --- /dev/null +++ b/applications/luci-app-photoprism/luasrc/model/cbi/photoprism.lua @@ -0,0 +1,50 @@ +--[[ +LuCI - Lua Configuration Interface +]]-- + +local taskd = require "luci.model.tasks" +local photoprism_model = require "luci.model.photoprism" +local m, s, o + +m = taskd.docker_map("photoprism", "photoprism", "/usr/libexec/istorec/photoprism.sh", + translate("PhotoPrism"), + translate("PhotoPrism® is an AI-Powered Photos App for the Decentralized Web.") + .. translate("Official website:") .. ' https://photoprism.app/') + +s = m:section(SimpleSection, translate("Service Status"), translate("PhotoPrism status:")) +s:append(Template("photoprism/status")) + +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 + +o = s:option(Value, "http_port", translate("HTTP Port").."*") +o.rmempty = false +o.default = "2342" +o.datatype = "string" +o:depends("hostnet", 0) + +o = s:option(Value, "image_name", translate("Image").."*") +o.rmempty = false +o.datatype = "string" +o:value("photoprism/photoprism:latest", "photoprism/photoprism:latest") +o:value("photoprism/photoprism:221105-armv7", "photoprism/photoprism:221105-armv7") +o.default = "photoprism/photoprism:latest" + +local blocks = photoprism_model.blocks() +local home = photoprism_model.home() + +o = s:option(Value, "config_path", translate("Config path").."*") +o.rmempty = false +o.datatype = "string" + +local paths, default_path = photoprism_model.find_paths(blocks, home, "Configs") +for _, val in pairs(paths) do + o:value(val, val) +end +o.default = default_path + +o = s:option(Value, "picture_path", translate("Picture path"), translate("Not required, all disk is mounted in") .. " /mnt") +o.datatype = "string" + +return m diff --git a/applications/luci-app-photoprism/luasrc/model/photoprism.lua b/applications/luci-app-photoprism/luasrc/model/photoprism.lua new file mode 100644 index 0000000..3cd90ad --- /dev/null +++ b/applications/luci-app-photoprism/luasrc/model/photoprism.lua @@ -0,0 +1,54 @@ +local util = require "luci.util" +local jsonc = require "luci.jsonc" + +local photoprism = {} + +photoprism.blocks = function() + local f = io.popen("lsblk -s -f -b -o NAME,FSSIZE,MOUNTPOINT --json", "r") + local vals = {} + if f then + local ret = f:read("*all") + f:close() + local obj = jsonc.parse(ret) + for _, val in pairs(obj["blockdevices"]) do + local fsize = val["fssize"] + if fsize ~= nil and string.len(fsize) > 10 and val["mountpoint"] then + -- fsize > 1G + vals[#vals+1] = val["mountpoint"] + end + end + end + return vals +end + +photoprism.home = function() + local uci = require "luci.model.uci".cursor() + 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 + +photoprism.find_paths = function(blocks, home_dirs, path_name) + local default_path = '' + local configs = {} + + default_path = home_dirs[path_name] .. "/PhotoPrism" + if #blocks == 0 then + table.insert(configs, default_path) + else + for _, val in pairs(blocks) do + table.insert(configs, val .. "/" .. path_name .. "/PhotoPrism") + end + local without_conf_dir = "/root/" .. path_name .. "/PhotoPrism" + if default_path == without_conf_dir then + default_path = configs[1] + end + end + + return configs, default_path +end + +return photoprism diff --git a/applications/luci-app-photoprism/luasrc/view/photoprism/status.htm b/applications/luci-app-photoprism/luasrc/view/photoprism/status.htm new file mode 100644 index 0000000..2e84809 --- /dev/null +++ b/applications/luci-app-photoprism/luasrc/view/photoprism/status.htm @@ -0,0 +1,31 @@ +<% +local util = require "luci.util" +local container_status = util.trim(util.exec("/usr/libexec/istorec/photoprism.sh status")) +local container_install = (string.len(container_status) > 0) +local container_running = container_status == "running" +-%> +