Merge fa4b3b36d3
into 8c2ec57462
This commit is contained in:
commit
fe31963585
|
@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
|||
|
||||
PKG_NAME:=gatling
|
||||
PKG_VERSION:=0.16
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=https://www.fefe.de/gatling/
|
||||
|
@ -32,9 +32,19 @@ define Package/gatling/description
|
|||
Gatling is particularly good in situations with very high load.
|
||||
endef
|
||||
|
||||
define Package/gatling/conffiles
|
||||
/etc/config/gatling
|
||||
endef
|
||||
|
||||
define Package/gatling/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/gatling $(1)/usr/bin/
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/gatling.conf $(1)/etc/config/gatling
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/gatling.init $(1)/etc/init.d/gatling
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,gatling))
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
config gatling 'v4'
|
||||
option listen_http '0.0.0.0:80'
|
||||
option virtual_hosting on
|
||||
option ftp_server off
|
||||
option ftp_port '21'
|
||||
option logging on
|
||||
option timeout 23
|
||||
option switch_to_uid 'nobody'
|
||||
option chroot_dir '/var/www/'
|
||||
option tarpit_clients off
|
||||
option tarpit_clients_at 50
|
||||
option localhost_access_only off
|
||||
option permit_access_ftp_uploads_immediately off
|
||||
|
||||
config gatling 'v6'
|
||||
option listen_http '[::]:80'
|
||||
option virtual_hosting on
|
||||
option ftp_server off
|
||||
option ftp_port '21'
|
||||
option logging on
|
||||
option timeout 23
|
||||
option switch_to_uid 'nobody'
|
||||
option chroot_dir '/var/www/'
|
||||
option tarpit_clients off
|
||||
option tarpit_clients_at 50
|
||||
option localhost_access_only off
|
||||
option permit_access_ftp_uploads_immediately off
|
|
@ -0,0 +1,114 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
# shellcheck shell=ash
|
||||
|
||||
# Just looks for changes in the config-file and applies them with a
|
||||
# one-time-run.
|
||||
|
||||
USE_PROCD=1
|
||||
# PROCD_DEBUG=1
|
||||
|
||||
# busybox doesn't include the rev-command. Thus implementing it by ourself.
|
||||
rev() {
|
||||
while read -r var; do
|
||||
# function taken from https://stackoverflow.com/a/34668251
|
||||
rev=""
|
||||
i=1
|
||||
|
||||
while [ "$i" -le "${#var}" ]; do
|
||||
rev="$(echo "$var" | awk -v i="$i" '{print(substr($0,i,1))}')$rev"
|
||||
: $((i += 1))
|
||||
done
|
||||
|
||||
echo "$rev"
|
||||
done
|
||||
}
|
||||
|
||||
# taken from /etc/init.d/uhttpd
|
||||
append_arg() {
|
||||
local cfg="$1"
|
||||
local var="$2"
|
||||
local opt="$3"
|
||||
local def="$4"
|
||||
local val
|
||||
|
||||
config_get val "$cfg" "$var"
|
||||
[ -n "$val" -o -n "$def" ] && procd_append_param command "$opt" "${val:-$def}"
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "gatling"
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
|
||||
local cfg="$1"
|
||||
local listen http ftp_server
|
||||
local enabled
|
||||
|
||||
config_get_bool enabled "$cfg" 'enabled' 1
|
||||
[ $enabled -gt 0 ] || return
|
||||
|
||||
procd_open_instance
|
||||
|
||||
procd_set_param command /usr/bin/gatling
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_set_param term_timeout 20
|
||||
|
||||
# get listen-address and slice it from back, to cut at port-delimiter
|
||||
config_get http gatling listen_http
|
||||
port=$(echo "$listen" | rev | cut -d':' -f 1 | rev )
|
||||
ip=$(echo "$listen" | rev | cut -d':' -f 2- | rev )
|
||||
|
||||
procd_append_param command -i "$ip"
|
||||
procd_append_param command -p "$port"
|
||||
|
||||
append_arg "$cfg" switch_to_uid "-u"
|
||||
append_arg "$cfg" chroot_dir "-c"
|
||||
append_arg "$cfg" timeout "-T"
|
||||
|
||||
config_get_bool virtual_hosting "$cfg" 'virtual_hosting' 0
|
||||
if [ "$virtual_hosting" -gt 0 ]; then
|
||||
# enable virtual hosting
|
||||
procd_append_param command -v
|
||||
else
|
||||
# disable
|
||||
procd_append_param command -V
|
||||
fi
|
||||
|
||||
config_get_bool ftp_server "$cfg" 'ftp_server' 0
|
||||
if [ "$ftp_server" -gt 0 ]; then
|
||||
procd_append_param command -f
|
||||
append_arg "$cfg" ftp_port "-p"
|
||||
else
|
||||
procd_append_param command -F
|
||||
fi
|
||||
|
||||
config_get_bool logging "$cfg" 'logging' 1
|
||||
if [ "$logging" = 0 ]; then
|
||||
procd_append_param command -n
|
||||
fi
|
||||
|
||||
config_get_bool tarpit_clients "$cfg" 'tarpit_clients' 0
|
||||
if [ "$tarpit_clients" -gt 0 ]; then
|
||||
append_arg "$cfg" tarpit_clients_at "-A"
|
||||
fi
|
||||
|
||||
config_get_bool localhost_access_only "$cfg" 'localhost_access_only' 0
|
||||
if [ "$localhost_access_only" = 1 ]; then
|
||||
procd_append_param command -L
|
||||
fi
|
||||
|
||||
config_get_bool permit_access_ftp_uploads_immediately "$cfg" 'permit_access_ftp_uploads_immediately' 0
|
||||
if [ "$permit_access_ftp_uploads_immediately" = 1 ]; then
|
||||
procd_append_param command -a
|
||||
fi
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load gatling
|
||||
config_foreach start_instance gatling
|
||||
}
|
Loading…
Reference in New Issue