mirror of
https://github.com/kenzok8/small-package.git
synced 2026-02-07 23:27:13 +08:00
update 03-25 09:18
This commit is contained in:
73
gowebdav/Makefile
Normal file
73
gowebdav/Makefile
Normal file
@@ -0,0 +1,73 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#
|
||||
# Copyright (C) 2021 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=gowebdav
|
||||
PKG_VERSION:=0.0.3
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/1715173329/gowebdav/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=skip
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
CONFIG_GOWEBDAV_COMPRESS_GOPROXY \
|
||||
CONFIG_GOWEBDAV_COMPRESS_UPX
|
||||
|
||||
PKG_BUILD_DEPENDS:=golang/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
GO_PKG:=github.com/1715173329/gowebdav
|
||||
GO_PKG_LDFLAGS:=-s -w
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/gowebdav
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=File Transfer
|
||||
TITLE:=A simple WebDav server written in Go
|
||||
URL:=https://github.com/1715173329/gowebdav
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS)
|
||||
endef
|
||||
|
||||
define Package/gowebdav/config
|
||||
config GOWEBDAV_COMPRESS_GOPROXY
|
||||
bool "Compiling with GOPROXY proxy"
|
||||
default n
|
||||
|
||||
config GOWEBDAV_COMPRESS_UPX
|
||||
bool "Compress executable files with UPX"
|
||||
depends on !mips64
|
||||
default n
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_GOWEBDAV_COMPRESS_GOPROXY),y)
|
||||
export GO111MODULE=on
|
||||
export GOPROXY=https://goproxy.bj.bcebos.com
|
||||
endif
|
||||
|
||||
define Build/Compile
|
||||
$(call GoPackage/Build/Compile)
|
||||
ifeq ($(CONFIG_GOWEBDAV_COMPRESS_UPX),y)
|
||||
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/gowebdav
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/gowebdav/install
|
||||
$(call GoPackage/Package/Install/Bin,$(1))
|
||||
|
||||
$(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,gowebdav))
|
||||
$(eval $(call BuildPackage,gowebdav))
|
||||
12
gowebdav/files/gowebdav.config
Normal file
12
gowebdav/files/gowebdav.config
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
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'
|
||||
option cert_cer ''
|
||||
option cert_key ''
|
||||
56
gowebdav/files/gowebdav.init
Executable file
56
gowebdav/files/gowebdav.init
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2021 ImmortalWrt
|
||||
|
||||
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_cer" "config" "cert_cer"
|
||||
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_cer}" ] && [ -e "${cert_key}" ]; } && https_arg="-https-mode -https-cert-file ${cert_cer} -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"
|
||||
}
|
||||
Reference in New Issue
Block a user