2023-12-05 12:41:04 Auto Sync
This commit is contained in:
parent
d7cc56837f
commit
47fada87dc
15
luci-app-nginx-manager/Makefile
Normal file
15
luci-app-nginx-manager/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for NginxManager From sundaqiang
|
||||
LUCI_DEPENDS:=+luci-ssl-nginx
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_MAINTAINER:=sundaqiang
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
18
luci-app-nginx-manager/README.md
Normal file
18
luci-app-nginx-manager/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
# luci-app-nginx-manager(Nginx管理器)
|
||||
|
||||
更方便的管理openwrt的nginx
|
||||
|
||||
### 注意事项
|
||||
1. 替代默认的uhttpd做为路由后台的web服务器
|
||||
2. 插件依赖+luci-nginx +luci-ssl-nginx +luci-ssl-openssl,并且会开启路由后台的https功能
|
||||
3. 插件会替代默认的uhttpd,但并不会删除uhttpd,如果你需要删除uhttpd,需在编译前在根目录执行以下操作:
|
||||
|
||||
```bash
|
||||
sed -i 's/+uhttpd +uhttpd-mod-ubus //g' feeds/luci/collections/luci/Makefile
|
||||
```
|
||||
|
||||
### 效果展示
|
||||
![nginx-manager][1]
|
||||
|
||||
[1]: https://raw.githubusercontent.com/sundaqiang/openwrt-packages/master/img/nginx-manager.png
|
39
luci-app-nginx-manager/luasrc/controller/nginx-manager.lua
Normal file
39
luci-app-nginx-manager/luasrc/controller/nginx-manager.lua
Normal file
@ -0,0 +1,39 @@
|
||||
module("luci.controller.nginx-manager", package.seeall)
|
||||
|
||||
function index()
|
||||
nixio.fs.rename ("/etc/nginx/uci.conf", "/etc/nginx/ucibak.conf")
|
||||
if not nixio.fs.access("/etc/nginx/nginx.conf") then
|
||||
nixio.fs.copyr("/var/lib/nginx/uci.conf", "/etc/nginx/nginx.conf")
|
||||
luci.sys.call("/etc/init.d/nginx restart")
|
||||
end
|
||||
file=nixio.fs.readfile("/etc/uwsgi/vassals/luci-webui.ini")
|
||||
if tonumber(file:match("limit%pas[%p%s]+(%d+)")) < 5000 then
|
||||
file=file:gsub("limit%pas[%p%s]+(%d+)","limit-as = 5000")
|
||||
nixio.fs.writefile("/etc/uwsgi/vassals/luci-webui.ini", file)
|
||||
luci.sys.call("/etc/init.d/uwsgi restart")
|
||||
end
|
||||
nixio.fs.writefile("/etc/config/nginx-manager", "")
|
||||
x = luci.model.uci.cursor()
|
||||
x:set("nginx-manager", "config", "nginx")
|
||||
x:set("nginx-manager", "config", "name", "config")
|
||||
x:set("nginx-manager", "config", "filepath", "/etc/config/nginx")
|
||||
for path in nixio.fs.dir("/etc/nginx/conf.d") do
|
||||
if path:find(".conf$") ~= nil then
|
||||
name = path:gsub(".conf", "")
|
||||
x:set("nginx-manager", name, "nginx")
|
||||
x:set("nginx-manager", name, "name", name)
|
||||
x:set("nginx-manager", name, "filepath", "/etc/nginx/conf.d/" .. path)
|
||||
end
|
||||
end
|
||||
x:commit("nginx-manager")
|
||||
entry({"admin", "services", "nginx-manager"}, cbi("nginx-manager"), _("Nginx Manager"), 95).dependent = true
|
||||
entry({"admin", "services", "nginx-manager", "setstatus"}, call("setstatus")).leaf = true
|
||||
end
|
||||
|
||||
function setstatus()
|
||||
local e = {}
|
||||
local mode = luci.http.formvalue('mode')
|
||||
e.code=luci.sys.call("/etc/init.d/nginx " .. mode)
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
43
luci-app-nginx-manager/luasrc/model/cbi/nginx-manager.lua
Normal file
43
luci-app-nginx-manager/luasrc/model/cbi/nginx-manager.lua
Normal file
@ -0,0 +1,43 @@
|
||||
local fs = require "nixio.fs"
|
||||
local m = Map("nginx-manager",translate("Nginx Manager"), translate("A simple Nginx manager") .. [[<br /><a href="https://github.com/sundaqiang/openwrt-packages" target="_blank">Powered by sundaqiang</a>]])
|
||||
s = m:section(TypedSection, "nginx", translate("Web site list"))
|
||||
s.template = "nginx-manager/index"
|
||||
s.addremove = true
|
||||
s.anonymous = false
|
||||
s:tab("general", translate("General Info"))
|
||||
s:tab("server", translate("Configuration File"))
|
||||
s:taboption("general", DummyValue, "name", translate("name"))
|
||||
s:taboption("general", DummyValue, "filepath", translate("File Path"))
|
||||
file=s:taboption("server", TextValue, "")
|
||||
file.template = "cbi/tvalue"
|
||||
file.rows = 25
|
||||
file.wrap = "off"
|
||||
file.rmempty = true
|
||||
|
||||
function s.create(self,section)
|
||||
path="/etc/nginx/conf.d/" .. section .. ".conf"
|
||||
fs.copyr("/etc/nginx/conf.d/templates", path)
|
||||
TypedSection.create(self,section)
|
||||
self.map:set(section, "name", section)
|
||||
self.map:set(section, "filepath", path)
|
||||
return true
|
||||
end
|
||||
function s.remove(self,section)
|
||||
path="/etc/nginx/conf.d/" .. section .. ".conf"
|
||||
fs.remove(path)
|
||||
TypedSection.remove(self,section)
|
||||
end
|
||||
function sync_value_to_file(value, file)
|
||||
value = value:gsub("\r\n?", "\n")
|
||||
local old_value = fs.readfile(file)
|
||||
if value ~= old_value then
|
||||
fs.writefile(file, value)
|
||||
end
|
||||
end
|
||||
function file.cfgvalue(self,section)
|
||||
return fs.readfile(self.map:get(section, "filepath")) or ""
|
||||
end
|
||||
function file.write(self, section, value)
|
||||
sync_value_to_file(value, self.map:get(section, "filepath"))
|
||||
end
|
||||
return m
|
62
luci-app-nginx-manager/luasrc/view/nginx-manager/index.htm
Normal file
62
luci-app-nginx-manager/luasrc/view/nginx-manager/index.htm
Normal file
@ -0,0 +1,62 @@
|
||||
<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
|
||||
<% if self.title and #self.title > 0 then -%>
|
||||
<legend><%=self.title%></legend>
|
||||
<%- end %>
|
||||
<% if self.description and #self.description > 0 then -%>
|
||||
<div class="cbi-section-descr"><%=self.description%></div>
|
||||
<%- end %>
|
||||
<div class="cbi-value" style="border-bottom: 1px solid #ddd;border-radius: 0px">
|
||||
<label class="cbi-value-title"><%= translate("Restart the nginx") %></label>
|
||||
<div class="cbi-value-field" style="padding:unset">
|
||||
<input class="btn cbi-button cbi-button-reload" id="restart" type="button" size="0" onclick="check_status('restart')" value="<%:Restart%>" />
|
||||
</div>
|
||||
<label class="cbi-value-title"><%= translate("Reload the nginx") %></label>
|
||||
<div class="cbi-value-field" style="padding:unset">
|
||||
<input class="btn cbi-button cbi-button-reload" id="reload" type="button" size="0" onclick="check_status('reload')" value="<%:Reload%>" />
|
||||
</div>
|
||||
</div>
|
||||
<% local isempty = true for i, k in ipairs(self:cfgsections()) do -%>
|
||||
<%- section = k; isempty = false -%>
|
||||
|
||||
<% if not self.anonymous then -%>
|
||||
<div class="cbi-section-remove" style="display: flex;flex-flow: row nowrap;justify-content: space-between">
|
||||
<span style="font-size:1.15rem;color:#32325d;font-weight:bold;letter-spacing:0.1rem;padding:1rem 1.5rem;"><%=section:upper()%></span>
|
||||
<input type="submit" name="cbi.rts.<%=self.config%>.<%=k%>" onclick="this.form.cbi_state='del-section'; return true" value="<%:Delete%>" class="cbi-button" />
|
||||
</div>
|
||||
<%- end %>
|
||||
<fieldset class="cbi-section-node<% if self.tabs then %> cbi-section-node-tabbed<% end %>" id="cbi-<%=self.config%>-<%=section%>" style="border-bottom: 1px solid #ddd;border-radius: 0px">
|
||||
<%+cbi/ucisection%>
|
||||
</fieldset>
|
||||
<%- end %>
|
||||
|
||||
<% if isempty then -%>
|
||||
<em><%:This section contains no values yet%><br /><br /></em>
|
||||
<%- end %>
|
||||
|
||||
<% if self.addremove then -%>
|
||||
<% if self.template_addremove then include(self.template_addremove) else -%>
|
||||
<div class="cbi-section-create">
|
||||
<% if self.anonymous then -%>
|
||||
<input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
|
||||
<%- else -%>
|
||||
<% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
|
||||
<input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" />
|
||||
<input type="submit" class="cbi-button cbi-button-add" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" />
|
||||
<% if self.invalid_cts then -%>
|
||||
<br /><%:Invalid%></div>
|
||||
<%- end %>
|
||||
<%- end %>
|
||||
</div>
|
||||
<%- end %>
|
||||
<%- end %>
|
||||
</fieldset>
|
||||
<style>.cbi-value-field {padding: 11.2px;}.cbi-tabmenu {border-bottom: unset !important;}</style>
|
||||
<script type="text/javascript">
|
||||
function check_status(mode) {
|
||||
const tb = document.getElementById(mode);
|
||||
tb.disabled = true;
|
||||
XHR.get('<%=url([[admin]], [[services]], [[nginx-manager]], [[setstatus]])%>', {mode: mode}, (x, r) => {
|
||||
tb.disabled = false;
|
||||
});
|
||||
}
|
||||
</script>
|
26
luci-app-nginx-manager/po/zh-cn/nginx-manager.po
Normal file
26
luci-app-nginx-manager/po/zh-cn/nginx-manager.po
Normal file
@ -0,0 +1,26 @@
|
||||
msgid "Nginx Manager"
|
||||
msgstr "Nginx管理器"
|
||||
|
||||
msgid "A simple Nginx manager"
|
||||
msgstr "一个简易的Nginx管理器"
|
||||
|
||||
msgid "Web site list"
|
||||
msgstr "网站列表"
|
||||
|
||||
msgid "Restart the nginx"
|
||||
msgstr "重新启动Nginx"
|
||||
|
||||
msgid "Reload the nginx"
|
||||
msgstr "重新加载Nginx"
|
||||
|
||||
msgid "Reload"
|
||||
msgstr "重新加载"
|
||||
|
||||
msgid "Configuration File"
|
||||
msgstr "配置文件"
|
||||
|
||||
msgid "General Info"
|
||||
msgstr "基础信息"
|
||||
|
||||
msgid "File Path"
|
||||
msgstr "文件路径"
|
1
luci-app-nginx-manager/po/zh_Hans
Symbolic link
1
luci-app-nginx-manager/po/zh_Hans
Symbolic link
@ -0,0 +1 @@
|
||||
zh-cn
|
17
luci-app-nginx-manager/root/etc/nginx/conf.d/templates
Normal file
17
luci-app-nginx-manager/root/etc/nginx/conf.d/templates
Normal file
@ -0,0 +1,17 @@
|
||||
server {
|
||||
listen 8080; #bind prot 绑定的端口
|
||||
root /www; #directory 网站路径
|
||||
ssl_session_timeout 5m;
|
||||
gzip on;
|
||||
gzip_types text/plain application/json application/javascript application/x-javascript text/css application/xml text/javascript;
|
||||
gzip_proxied any;
|
||||
gzip_vary on;
|
||||
gzip_comp_level 6;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_http_version 1.0;
|
||||
|
||||
location / {
|
||||
index index.html index.htm; #默认文件
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@nginx-manager[-1]
|
||||
add ucitrack nginx-manager
|
||||
set ucitrack.@nginx-manage[-1].init=nginx
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-nginx-manager": {
|
||||
"description": "Grant UCI access for luci-app-nginx-manager",
|
||||
"read": {
|
||||
"uci": [ "nginx-manager" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "nginx-manager" ]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user