🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
include $(TOPDIR)/rules.mk
PKG_VERSION:=1.0.2-20240822
PKG_RELEASE:=1
LUCI_TITLE:=LuCI support for Memos
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+lsblk +docker +dockerd +luci-lib-taskd
define Package/luci-app-memos/conffiles
/etc/config/memos
endef
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
+7
View File
@@ -0,0 +1,7 @@
module("luci.controller.memos", package.seeall)
function index()
entry({"admin", "services", "memos"}, alias("admin", "services", "memos", "config"), _("Memos"), 30).dependent = true
entry({"admin", "services", "memos", "config"}, cbi("memos"))
end
+44
View File
@@ -0,0 +1,44 @@
--[[
LuCI - Lua Configuration Interface
]]--
local taskd = require "luci.model.tasks"
local memos_model = require "luci.model.memos"
local m, s, o
m = taskd.docker_map("memos", "memos", "/usr/libexec/istorec/memos.sh",
translate("Memos"),
translate("Memos is an open-source, self-hosted memo hub with knowledge management and collaboration.")
.. translate("Official website:") .. ' <a href=\"https://usememos.com/\" target=\"_blank\">https://usememos.com/</a>')
s = m:section(SimpleSection, translate("Service Status"), translate("Memos status:"))
s:append(Template("memos/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").."<b>*</b>")
o.default = "5230"
o.datatype = "port"
o = s:option(Value, "image_name", translate("Image").."<b>*</b>")
o.rmempty = false
o.datatype = "string"
o:value("neosmemo/memos:latest", "neosmemo/memos:latest")
o.default = "neosmemo/memos:latest"
local blocks = memos_model.blocks()
local home = memos_model.home()
o = s:option(Value, "config_path", translate("Config path").."<b>*</b>")
o.rmempty = false
o.datatype = "string"
local paths, default_path = memos_model.find_paths(blocks, home, "Configs")
for _, val in pairs(paths) do
o:value(val, val)
end
o.default = default_path
return m
+55
View File
@@ -0,0 +1,55 @@
local util = require "luci.util"
local jsonc = require "luci.jsonc"
local memos = {}
memos.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
memos.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["Public"] = uci:get_first("quickstart", "main", "pub_dir", home_dirs["main_dir"].."/Public")
home_dirs["Downloads"] = uci:get_first("quickstart", "main", "dl_dir", home_dirs["Public"].."/Downloads")
home_dirs["Caches"] = uci:get_first("quickstart", "main", "tmp_dir", home_dirs["main_dir"].."/Caches")
return home_dirs
end
memos.find_paths = function(blocks, home_dirs, path_name)
local default_path = ''
local configs = {}
default_path = home_dirs[path_name] .. "/Memos"
if #blocks == 0 then
table.insert(configs, default_path)
else
for _, val in pairs(blocks) do
table.insert(configs, val .. "/" .. path_name .. "/Memos")
end
local without_conf_dir = "/root/" .. path_name .. "/Memos"
if default_path == without_conf_dir then
default_path = configs[1]
end
end
return configs, default_path
end
return memos
@@ -0,0 +1,31 @@
<%
local util = require "luci.util"
local container_status = util.trim(util.exec("/usr/libexec/istorec/memos.sh status"))
local container_install = (string.len(container_status) > 0)
local container_running = container_status == "running"
-%>
<div class="cbi-value">
<label class="cbi-value-title"><%:Status%></label>
<div class="cbi-value-field">
<% if container_running then %>
<button class="cbi-button cbi-button-success" disabled="true"><%:Memos is running%></button>
<% else %>
<button class="cbi-button cbi-button-negative" disabled="true"><%:Memos is not running%></button>
<% end %>
</div>
</div>
<%
if container_running then
local port=util.trim(util.exec("/usr/libexec/istorec/memos.sh port"))
if port == "" then
port="5230"
end
-%>
<div class="cbi-value cbi-value-last">
<label class="cbi-value-title">&nbsp;</label>
<div class="cbi-value-field">
<input type="button" class="btn cbi-button cbi-button-apply" name="start" value="<%:Open Memos%>" onclick="window.open('http://'+location.hostname+':<%=port%>', '_blank')">
</div>
</div>
<% end %>
+42
View File
@@ -0,0 +1,42 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Memos"
msgstr "Memos 知识管理"
msgid "Official website:"
msgstr "官方网站:"
msgid "Memos is an open-source, self-hosted memo hub with knowledge management and collaboration."
msgstr "Memos 是一个开源的极简的碎片化知识管理工具。"
msgid "Config path"
msgstr "配置文件路径"
msgid "HTTP Port"
msgstr "HTTP 端口"
msgid "Service Status"
msgstr "服务状态"
msgid "Memos status:"
msgstr "Memos 的状态信息如下:"
msgid "Setup"
msgstr "安装配置"
msgid "The following parameters will only take effect during installation or upgrade:"
msgstr "以下参数只在安装或者升级时才会生效:"
msgid "Status"
msgstr "状态"
msgid "Memos is running"
msgstr "Memos 运行中"
msgid "Memos is not running"
msgstr "Memos 未运行"
msgid "Open Memos"
msgstr "打开 Memos"
+1
View File
@@ -0,0 +1 @@
zh-cn
+5
View File
@@ -0,0 +1,5 @@
config main
option 'http_port' '5230'
option 'image_name' 'neosmemo/memos:latest'
option 'config_path' ''
@@ -0,0 +1,20 @@
#!/bin/sh
if [[ "`docker container inspect -f '{{ (index .Mounts 0).Destination }}' memos`" = "/config" ]]; then
echo "fix script bug"
config_path="`docker container inspect -f '{{ (index .Mounts 0).Source }}' memos`"
echo "backup old data"
if [[ -z "$config_path" ]]; then
docker start memos 2>/dev/null
docker exec memos cp -a /var/opt/memos/. /config/
docker stop memos 2>/dev/null
else
mkdir -p "$config_path"
docker stop memos 2>/dev/null
docker cp -a memos:/var/opt/memos/. "${config_path%/}/"
fi
echo "remove old container"
docker rm -f memos
echo "you should deploy later"
fi
exit 0
+74
View File
@@ -0,0 +1,74 @@
#!/bin/sh
# Author Xiaobao(xiaobao@linkease.com)
ACTION=${1}
shift 1
do_install() {
local http_port=`uci get memos.@main[0].http_port 2>/dev/null`
local image_name=`uci get memos.@main[0].image_name 2>/dev/null`
local config=`uci get memos.@main[0].config_path 2>/dev/null`
[ -z "$image_name" ] && image_name="neosmemo/memos:latest"
echo "docker pull ${image_name}"
docker pull ${image_name}
docker rm -f memos
if [ -z "$config" ]; then
echo "config path is empty!"
exit 1
fi
# not conflict with jellyfin
[ -z "$http_port" ] && http_port=5230
local cmd="docker run --restart=unless-stopped -d \
-v \"$config:/var/opt/memos\" \
--dns=172.17.0.1 \
-p $http_port:5230 "
local tz="`uci get system.@system[0].zonename | sed 's/ /_/g'`"
[ -z "$tz" ] || cmd="$cmd -e TZ=$tz"
cmd="$cmd -v /mnt:/mnt"
mountpoint -q /mnt && cmd="$cmd:rslave"
cmd="$cmd --name memos \"$image_name\""
echo "$cmd"
eval "$cmd"
}
usage() {
echo "usage: $0 sub-command"
echo "where sub-command is one of:"
echo " install Install the memos"
echo " upgrade Upgrade the memos"
echo " rm/start/stop/restart Remove/Start/Stop/Restart the memos"
echo " status Memos status"
echo " port Memos port"
}
case ${ACTION} in
"install")
do_install
;;
"upgrade")
do_install
;;
"rm")
docker rm -f memos
;;
"start" | "stop" | "restart")
docker ${ACTION} memos
;;
"status")
docker ps --all -f 'name=^/memos$' --format '{{.State}}'
;;
"port")
docker ps --all -f 'name=^/memos$' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
;;
*)
usage
exit 1
;;
esac
@@ -0,0 +1,11 @@
{
"luci-app-memos": {
"description": "Grant UCI access for luci-app-memos",
"read": {
"uci": [ "memos" ]
},
"write": {
"uci": [ "memos" ]
}
}
}