• R/O
  • HTTP
  • SSH
  • HTTPS

luci: Commit

LuCI - OpenWrt Configuration Interface


Commit MetaInfo

Révision7917af38704161e62335b8622a908674c709899f (tree)
l'heure2022-05-12 17:42:32
Auteurzxlhhyccc <45259624+zxlhhyccc@user...>
CommiterTianling Shen

Message de Log

luci-app-syncthing: compat with official service

(cherry picked from commit 42af7a536d5cf677c402431b34240fdfc9a8fd67)

Change Summary

Modification

--- a/applications/luci-app-syncthing/Makefile
+++ b/applications/luci-app-syncthing/Makefile
@@ -1,15 +1,9 @@
1-# Copyright (C) 2016 Openwrt.org
2-#
3-# This is free software, licensed under the Apache License, Version 2.0 .
4-#
5-
61 include $(TOPDIR)/rules.mk
72
83 LUCI_TITLE:=LuCI support for syncthing
94 LUCI_DEPENDS:=+syncthing
105 LUCI_PKGARCH:=all
11-PKG_VERSION:=1.0
12-PKG_RELEASE:=2
6+PKG_RELEASE:=$(COMMITCOUNT)
137
148 include ../../luci.mk
159
--- a/applications/luci-app-syncthing/luasrc/model/cbi/syncthing.lua
+++ b/applications/luci-app-syncthing/luasrc/model/cbi/syncthing.lua
@@ -3,17 +3,50 @@
33
44 require("nixio.fs")
55
6-m = Map("syncthing", translate("SyncThing Synchronization Tool"))
6+m = Map("syncthing", translate("Syncthing Synchronization Tool"))
77
88 m:section(SimpleSection).template = "syncthing/syncthing_status"
99
10-s = m:section(TypedSection, "setting", translate("Settings"))
10+s = m:section(TypedSection, "syncthing")
11+s.addremove = false
1112 s.anonymous = true
1213
13-s:option(Flag, "enabled", translate("Enable"))
14-
15-s:option(Value, "port", translate("port")).default = 8384
16-s.rmempty = true
14+o = s:option(Flag, "enabled", translate("Enabled"))
15+o.default = 0
16+o.rmempty = false
17+
18+gui_address = s:option(Value, "gui_address", translate("GUI access address"))
19+gui_address.description = translate("Use 0.0.0.0:8384 to monitor all access.")
20+gui_address.default = "http://0.0.0.0:8384"
21+gui_address.placeholder = "http://0.0.0.0:8384"
22+gui_address.rmempty = false
23+
24+home = s:option(Value, "home", translate("Configuration file directory"))
25+home.description = translate("Only the configuration saved in /etc/syncthing will be automatically backed up!")
26+home.default = "/etc/syncthing"
27+home.placeholder = "/etc/syncthing"
28+home.rmempty = false
29+
30+user = s:option(ListValue, "user", translate("User"))
31+user.description = translate("The default is syncthing, but it may cause permission denied. Syncthing officially does not recommend running as root.")
32+user:value("", translate("syncthing"))
33+for u in luci.util.execi("cat /etc/passwd | cut -d ':' -f1") do
34+ user:value(u)
35+end
36+
37+macprocs = s:option(Value, "macprocs", translate("Thread limit"))
38+macprocs.description = translate("0 to match the number of CPUs (default), >0 to explicitly specify concurrency.")
39+macprocs.default = "0"
40+macprocs.placeholder = "0"
41+macprocs.datatype="range(0,32)"
42+macprocs.rmempty = false
43+
44+nice = s:option(Value, "nice", "Nice")
45+nice.description = translate("Explicitly specify nice. 0 is the highest and 19 is the lowest. (negative values are not allowed to be set temporarily)")
46+nice.default = "19"
47+nice.placeholder = "19"
48+nice.datatype="range(0,19)"
49+nice.rmempty = false
1750
1851
1952 return m
--- a/applications/luci-app-syncthing/luasrc/view/syncthing/syncthing_status.htm
+++ b/applications/luci-app-syncthing/luasrc/view/syncthing/syncthing_status.htm
@@ -1,27 +1,22 @@
11 <script type="text/javascript">//<![CDATA[
2-XHR.poll(1, '<%=url([[admin]], [[nas]], [[syncthing]], [[status]])%>', null,
3- function(x, data) {
4- var tb = document.getElementById('syncthing_status');
5- if (data && tb) {
6- if (data.running) {
7- var links = '<font color=green>Syncthing <%:RUNNING%></font><input class="cbi-button mar-10" type="button" value="<%:Open Web Interface%>" onclick="openClient();" />';
8- tb.innerHTML = links;
9- } else {
10- tb.innerHTML = '<font color=red>Syncthing <%:NOT RUNNING%></font>';
2+ XHR.poll(1, '<%=url([[admin]], [[nas]], [[syncthing]], [[status]])%>', null,
3+ function (x, data) {
4+ var tb = document.getElementById('syncthing_status');
5+ if (data && tb) {
6+ if (data.running) {
7+ var links = '<em><b><font color="green">Syncthing <%:RUNNING%></font></b></em><input class="btn cbi-button mar-10" type="button" value="<%:Open Syncthing page%>" onclick="openwebui();" />';
8+ tb.innerHTML = links;
9+ } else {
10+ tb.innerHTML = '<em><b><font color="red">Syncthing <%:NOT RUNNING%></font></b></em>';
11+ }
1112 }
1213 }
13- }
14-);
14+ );
1515
16-function openClient() {
17- var curWwwPath = window.document.location.href;
18- var pathName = window.document.location.pathname;
19- var pos = curWwwPath.indexOf(pathName);
20- var localhostPath = curWwwPath.substring(0, pos);
21- var clientPort = window.document.getElementById("cbid.syncthing.config.port").value
22- var url = localhostPath + ":" + clientPort;
23- window.open(url)
24-};
16+function openwebui(){
17+ var url = window.location.host+":<%=luci.sys.exec("uci -q get syncthing.syncthing.gui_address"):match(":[0-9]+"):gsub(":", "")%>";
18+ window.open('http://'+url,'target','');
19+}
2520 //]]>
2621 </script>
2722 <style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
--- a/applications/luci-app-syncthing/po/zh-cn/syncthing.po
+++ b/applications/luci-app-syncthing/po/zh-cn/syncthing.po
@@ -1,8 +1,35 @@
11 msgid "Syncthing"
2-msgstr "储存同步"
2+msgstr "Syncthing"
33
4-msgid "SyncThing Synchronization Tool"
5-msgstr "syncthing同步工具"
4+msgid "Syncthing Synchronization Tool"
5+msgstr "Syncthing 存储同步工具"
66
7-msgid "Open Web Interface"
8-msgstr "打开管理页面"
7+msgid "Open Syncthing page"
8+msgstr "打开储存同步页面"
9+
10+msgid "GUI access address"
11+msgstr "GUI访问地址"
12+
13+msgid "Use 0.0.0.0:8384 to monitor all access."
14+msgstr "使用0.0.0.0:8384监听所有访问。"
15+
16+msgid "Configuration file directory"
17+msgstr "配置文件存储目录"
18+
19+msgid "Only the configuration saved in /etc/syncthing will be automatically backed up!"
20+msgstr "只有保存在 /etc/syncthing 的配置会被自动备份!"
21+
22+msgid "User"
23+msgstr "用户"
24+
25+msgid "The default is syncthing, but it may cause permission denied. Syncthing officially does not recommend running as root."
26+msgstr "默认为syncthing,但可能引起权限不足问题。Syncthing官方不建议以root身份运行。"
27+
28+msgid "Thread limit"
29+msgstr "线程限制"
30+
31+msgid "0 to match the number of CPUs (default), >0 to explicitly specify concurrency."
32+msgstr "使用0来匹配CPU核心数,或输入大于0的数来显式指定并发数。"
33+
34+msgid "Explicitly specify nice. 0 is the highest and 19 is the lowest. (negative values are not allowed to be set temporarily)"
35+msgstr "显式指定进程Nice值。其中0最高,19最低。(暂不允许设置负值)"
--- a/applications/luci-app-syncthing/root/etc/config/syncthing
+++ /dev/null
@@ -1,4 +0,0 @@
1-
2-config setting 'config'
3- option enabled '0'
4- option port '8384'
--- a/applications/luci-app-syncthing/root/etc/init.d/syncthing
+++ /dev/null
@@ -1,43 +0,0 @@
1-#!/bin/sh /etc/rc.common
2-START=50
3-
4-run_syncthing()
5-{
6- local enabled
7- config_get_bool enabled $1 enabled
8- if [ $enabled = 1 ]; then
9- local port
10- config_get port $1 port
11- state=`pgrep syncthing | wc -l`
12- if [ $state = 0 ] ; then
13- export HOME="/root"
14- syncthing -gui-address="0.0.0.0:$port" -logfile="/var/log/syncthing.log" -no-browser >/dev/null &
15- echo "启动中..."
16- start=`pgrep syncthing | wc -l`
17- if [ $start = 0 ] ; then
18- echo "启动失败"
19- else
20- echo "启动成功"
21- fi
22- else
23- echo "已在运行"
24- fi
25- fi
26-}
27-
28-start()
29-{
30- config_load syncthing
31- config_foreach run_syncthing setting
32-}
33-
34-stop()
35-{
36- kill -9 `pgrep syncthing`
37- stop=`pgrep syncthing | wc -l`
38- if [ $stop = 0 ] ; then
39- echo "已停止运行"
40- else
41- echo "未停止运行"
42- fi
43-}
Afficher sur ancien navigateur de dépôt.