mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-10 11:09:57 +08:00
gowebdav: add package
This commit is contained in:
parent
de20bbdb22
commit
b05745006a
63
package/ctcgfw/gowebdav/Makefile
Normal file
63
package/ctcgfw/gowebdav/Makefile
Normal file
@ -0,0 +1,63 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=gowebdav
|
||||
PKG_VERSION:=0.0.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/1715173329/gowebdav.git
|
||||
PKG_SOURCE_VERSION:=8b30e5453e959fd9911a90f2d4f7421616285ffa
|
||||
PKG_MAINTAINER:=CN_SZTL <cnsztl@project-openwrt.eu.org>
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR)-$(PKG_VERSION).tar.gz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
||||
|
||||
PKG_BUILD_DEPENDS:=golang/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
GO_PKG:=gowebdav
|
||||
GO_PKG_LDFLAGS:=-s -w
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=File Transfer
|
||||
TITLE:=A simple WebDav server written in Golang.
|
||||
URL:=https://github.com/1715173329/gowebdav
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS)
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
A simple WebDav server written in Golang.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
tar -zxf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR) --strip-components 1
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(eval GO_PKG_BUILD_PKG:=$(GO_PKG))
|
||||
$(call GoPackage/Build/Configure)
|
||||
$(call GoPackage/Build/Compile)
|
||||
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/gowebdav
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/gowebdav $(1)/usr/bin/gowebdav
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(CURDIR)/files/gowebdav.config $(1)/etc/config/gowebdav
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(CURDIR)/files/gowebdav.init $(1)/etc/init.d/gowebdav
|
||||
endef
|
||||
|
||||
$(eval $(call GoBinPackage,$(PKG_NAME)))
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
10
package/ctcgfw/gowebdav/files/gowebdav.config
Normal file
10
package/ctcgfw/gowebdav/files/gowebdav.config
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
config gowebdav 'config'
|
||||
option enable '0'
|
||||
option listen_port '6086'
|
||||
option username 'user'
|
||||
option password 'pass'
|
||||
option root_dir '/mnt'
|
||||
option read_only '0'
|
||||
option allow_wan '0'
|
||||
option use_https '0'
|
56
package/ctcgfw/gowebdav/files/gowebdav.init
Executable file
56
package/ctcgfw/gowebdav/files/gowebdav.init
Executable file
@ -0,0 +1,56 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2020 [CTCGFW] Project OpenWRT
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
init_conf() {
|
||||
config_load "gowebdav"
|
||||
config_get "enable" "config" "enable" "0"
|
||||
config_get "listen_port" "config" "listen_port" "6086"
|
||||
config_get "username" "config" "username"
|
||||
config_get "password" "config" "password"
|
||||
config_get "root_dir" "config" "root_dir" "/mnt"
|
||||
config_get "read_only" "config" "read_only" "0"
|
||||
config_get "allow_wan" "config" "allow_wan" "0"
|
||||
config_get "use_https" "config" "use_https" "0"
|
||||
config_get "cert_crt" "config" "cert_crt"
|
||||
config_get "cert_key" "config" "cert_key"
|
||||
|
||||
config_load "network"
|
||||
config_get "lan_addr" "lan" "ipaddr" "192.168.1.1"
|
||||
}
|
||||
|
||||
set_firewall() {
|
||||
if [ "${set_type}" = "start" ]; then
|
||||
mkdir -p "/var/etc/"
|
||||
iptables -I INPUT -p tcp --dport "${listen_port}" -j ACCEPT
|
||||
echo "iptables -I INPUT -p tcp --dport "${listen_port}" -j ACCEPT" > "/var/etc/gowebdav.include"
|
||||
elif [ "${set_type}" = "stop" ]; then
|
||||
iptables -D INPUT -p tcp --dport "${listen_port}" -j ACCEPT
|
||||
echo "" > "/var/etc/gowebdav.include"
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
init_conf
|
||||
|
||||
stop
|
||||
|
||||
[ "${enable}" -ne "1" ] && exit 0
|
||||
|
||||
mkdir -p "${root_dir}"
|
||||
|
||||
[ "${allow_wan}" -ne "1" ] && listen_addr="${lan_addr}" || { listen_addr="0.0.0.0"; set_type="start" && set_firewall 2>"/dev/null"; }
|
||||
{ [ -n "${username}" ] && [ -n "${password}" ]; } && auth_arg="-user ${username} -password ${password}"
|
||||
[ "${read_only}" -eq "1" ] && readonly_arg="-read-only"
|
||||
{ [ "${use_https}" -eq "1" ] && [ -e "${cert_crt}" ] && [ -e "${cert_key}" ]; } && https_arg="-https-mode -https-cert-file ${cert_crt} -https-key-file ${cert_key}"
|
||||
/usr/bin/gowebdav -dir "${root_dir}" -http "${listen_addr}:${listen_port}" ${auth_arg} ${readonly_arg} ${https_arg} &
|
||||
}
|
||||
|
||||
stop() {
|
||||
init_conf
|
||||
|
||||
set_type="stop" && set_firewall 2>"/dev/null"
|
||||
killall "gowebdav" 2>"/dev/null"
|
||||
}
|
22
package/ctcgfw/luci-app-gowebdav/Makefile
Normal file
22
package/ctcgfw/luci-app-gowebdav/Makefile
Normal file
@ -0,0 +1,22 @@
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is a free software, use it under GNU General Public License v3.0.
|
||||
#
|
||||
# Created By [CTCGFW]Project-OpenWrt
|
||||
# https://github.com/project-openwrt
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-gowebdav
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LUCI_TITLE:=LuCI support for GoWebDav
|
||||
LUCI_DEPENDS:=+gowebdav
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_MAINTAINER:=CN_SZTL <cnsztl@project-openwrt.eu.org>
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
@ -0,0 +1,19 @@
|
||||
module("luci.controller.gowebdav", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/gowebdav") then
|
||||
return
|
||||
end
|
||||
entry({"admin", "nas"}, firstchild(), _("NAS") , 45).dependent = false
|
||||
local page
|
||||
page = entry({"admin", "nas", "gowebdav"}, cbi("gowebdav"), _("GoWebDav"), 100)
|
||||
page.dependent = true
|
||||
entry({"admin","nas","gowebdav","status"},call("act_status")).leaf=true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("pgrep gowebdav >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
@ -0,0 +1,59 @@
|
||||
-- Created By [CTCGFW]Project-OpenWrt
|
||||
-- https://github.com/project-openwrt
|
||||
|
||||
m = Map("gowebdav", translate("GoWebDav"), translate("GoWebDav is a tiny, simple, fast WevDav server."))
|
||||
|
||||
m:section(SimpleSection).template = "gowebdav/gowebdav_status"
|
||||
|
||||
s = m:section(TypedSection, "gowebdav")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
enable = s:option(Flag, "enable", translate("Enable"))
|
||||
enable.rmempty = false
|
||||
|
||||
listen_port = s:option(Value, "port", translate("Listen Port"))
|
||||
listen_port.placeholder = 6086
|
||||
listen_port.default = 6086
|
||||
listen_port.datatype = "port"
|
||||
listen_port.rmempty = false
|
||||
|
||||
username = s:option(Value, "username", translate("Username"))
|
||||
username.description = translate("Leave blank to disable auth.")
|
||||
username.placeholder = user
|
||||
username.default = user
|
||||
username.datatype = "string"
|
||||
|
||||
password = s:option(Value, "password", translate("Password"))
|
||||
password.description = translate("Leave blank to disable auth.")
|
||||
password.placeholder = pass
|
||||
password.default = pass
|
||||
password.datatype = "string"
|
||||
password.password = true
|
||||
|
||||
root_dir = s:option(Value, "root_dir", translate("Root Directory"))
|
||||
root_dir.placeholder = "/mnt"
|
||||
root_dir.default = "/mnt"
|
||||
root_dir.rmempty = false
|
||||
|
||||
read_only = s:option(Flag, "read_only", translate("Read-Only Mode"))
|
||||
read_only.rmempty = false
|
||||
|
||||
allow_wan = s:option(Flag, "allow_wan", translate("Allow Access From Internet"))
|
||||
allow_wan.rmempty = false
|
||||
|
||||
use_https = s:option(Flag, "use_https", translate("Use HTTPS instead of HTTP"))
|
||||
use_https.rmempty = false
|
||||
|
||||
cert_crt = s:option(Value, "cert_crt", translate("Path to Certificate"))
|
||||
cert_crt.datatype = "file"
|
||||
cert_crt:depends("use_https", 1)
|
||||
|
||||
cert_key = s:option(Value, "cert_key", translate("Path to Certificate Key"))
|
||||
cert_key.datatype = "file"
|
||||
cert_key:depends("use_https", 1)
|
||||
|
||||
download_reg = s:option(DummyValue,"opennewwindow",translate("<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Download Reg File\" onclick=\"window.open('https://raw.githubusercontent.com/1715173329/gowebdav/master/allow_http.reg')\" />"))
|
||||
download_reg.description = translate("Windows doesn't allow HTTP auth by default, you need to import this reg key to enable it (Reboot needed).")
|
||||
|
||||
return m
|
@ -0,0 +1,27 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(1, '<%=url([[admin]], [[nas]], [[gowebdav]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('gowebdav_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<font color=green>GoWebDav <%:RUNNING%></font><input class="cbi-button mar-10" type="button" value="<%:Open Web Interface%>" onclick="openwebui();" />';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<font color=red>GoWebDav <%:NOT RUNNING%></font>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function openwebui() {
|
||||
var url = window.location.host+":<%=luci.sys.exec("uci -q get gowebdav.config.listen_port"):gsub("^%s*(.-)%s*$", "%1")%>";
|
||||
window.open('http://'+url,'target','');
|
||||
};
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="gowebdav_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
47
package/ctcgfw/luci-app-gowebdav/po/zh_Hans/gowebdav.po
Normal file
47
package/ctcgfw/luci-app-gowebdav/po/zh_Hans/gowebdav.po
Normal file
@ -0,0 +1,47 @@
|
||||
msgid "GoWebDav"
|
||||
msgstr "GoWebDav"
|
||||
|
||||
msgid "GoWebDav is a tiny, simple, fast WevDav server."
|
||||
msgstr "GoWebDav 是一个轻巧、简单、快速的 WebDav 服务端程序。"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Listen Port"
|
||||
msgstr "监听端口"
|
||||
|
||||
msgid "Username"
|
||||
msgstr "用户名"
|
||||
|
||||
msgid "Password"
|
||||
msgstr "密码"
|
||||
|
||||
msgid "Leave blank to disable auth."
|
||||
msgstr "留空以禁用身份验证。"
|
||||
|
||||
msgid "Root Directory"
|
||||
msgstr "开放目录"
|
||||
|
||||
msgid "Read-Only Mode"
|
||||
msgstr "只读模式"
|
||||
|
||||
msgid "<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"Download Reg File\" onclick=\"window.open('https://raw.githubusercontent.com/1715173329/gowebdav/master/allow_http.reg')\" />"
|
||||
msgstr "<input type=\"button\" class=\"cbi-button cbi-button-apply\" value=\"下载注册表文件\" onclick=\"window.open('https://raw.githubusercontent.com/1715173329/gowebdav/master/allow_http.reg')\" />"
|
||||
|
||||
msgid "Windows doesn't allow HTTP auth by default, you need to import this reg key to enable it (Reboot needed)."
|
||||
msgstr "Windows 系统默认不允许 HTTP 鉴权,您需要手动导入注册表文件以开启此功能(需重启)。"
|
||||
|
||||
msgid "Allow Access From Internet"
|
||||
msgstr "允许从外网访问"
|
||||
|
||||
msgid "Use HTTPS instead of HTTP"
|
||||
msgstr "使用 HTTPS 模式"
|
||||
|
||||
msgid "Path to Certificate"
|
||||
msgstr "证书位置"
|
||||
|
||||
msgid "Path to Certificate Key"
|
||||
msgstr "密钥位置"
|
||||
|
||||
msgid "Open Web Interface"
|
||||
msgstr "打开 Web 界面"
|
17
package/ctcgfw/luci-app-gowebdav/root/etc/uci-defaults/gowebdav
Executable file
17
package/ctcgfw/luci-app-gowebdav/root/etc/uci-defaults/gowebdav
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@gowebdav[-1]
|
||||
add ucitrack gowebdav
|
||||
set ucitrack.@gowebdav[-1].init=gowebdav
|
||||
commit ucitrack
|
||||
delete firewall.gowebdav
|
||||
set firewall.gowebdav=include
|
||||
set firewall.gowebdav.type=script
|
||||
set firewall.gowebdav.path=/var/etc/gowebdav.include
|
||||
set firewall.gowebdav.reload=1
|
||||
commit firewall
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-gowebdav": {
|
||||
"description": "Grant UCI access for luci-app-gowebdav",
|
||||
"read": {
|
||||
"uci": [ "gowebdav" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "gowebdav" ]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user