xinetd: add support for UCI configuration
Signed-off-by: Helge Mader <ma@dev.tdt.de>
This commit is contained in:
parent
4a1618f91f
commit
be55bce946
4 changed files with 125 additions and 16 deletions
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=xinetd
|
PKG_NAME:=xinetd
|
||||||
PKG_VERSION:=2.3.15
|
PKG_VERSION:=2.3.15
|
||||||
PKG_RELEASE:=5
|
PKG_RELEASE:=6
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=https://github.com/xinetd-org/xinetd/archive
|
PKG_SOURCE_URL:=https://github.com/xinetd-org/xinetd/archive
|
||||||
|
@ -39,7 +39,7 @@ define Package/xinetd/description
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/xinetd/conffiles
|
define Package/xinetd/conffiles
|
||||||
/etc/xinetd.conf
|
/etc/config/xinetd
|
||||||
/etc/xinetd.d/
|
/etc/xinetd.d/
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ CONFIGURE_VARS += \
|
||||||
define Package/xinetd/install
|
define Package/xinetd/install
|
||||||
$(INSTALL_DIR) $(1)/usr/sbin
|
$(INSTALL_DIR) $(1)/usr/sbin
|
||||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xinetd $(1)/usr/sbin/
|
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xinetd $(1)/usr/sbin/
|
||||||
$(INSTALL_DIR) $(1)/etc
|
$(INSTALL_DIR) $(1)/etc/config/
|
||||||
$(INSTALL_DATA) ./files/xinetd.conf $(1)/etc/xinetd.conf
|
$(INSTALL_DATA) ./files/xinetd.uci.conf.sample $(1)/etc/config/xinetd
|
||||||
$(INSTALL_DIR) $(1)/etc/xinetd.d
|
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
$(INSTALL_BIN) ./files/xinetd.init $(1)/etc/init.d/xinetd
|
$(INSTALL_BIN) ./files/xinetd.init $(1)/etc/init.d/xinetd
|
||||||
|
$(INSTALL_DIR) $(1)/etc/xinetd.d
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildPackage,xinetd))
|
$(eval $(call BuildPackage,xinetd))
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
defaults
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
includedir /etc/xinetd.d
|
|
|
@ -2,14 +2,118 @@
|
||||||
# Copyright (C) 2006-2011 OpenWrt.org
|
# Copyright (C) 2006-2011 OpenWrt.org
|
||||||
|
|
||||||
START=50
|
START=50
|
||||||
|
STOP=10
|
||||||
|
|
||||||
SERVICE_USE_PID=1
|
USE_PROCD=1
|
||||||
|
|
||||||
start() {
|
PROG="/usr/sbin/xinetd"
|
||||||
service_start /usr/sbin/xinetd -pidfile /var/run/xinetd.pid
|
|
||||||
|
PIDFILE="/var/run/xinetd.pid"
|
||||||
|
|
||||||
|
CONF_FILE="/etc/config/xinetd"
|
||||||
|
GENERATED_CONF_FILE="/var/run/xinetd.conf"
|
||||||
|
|
||||||
|
ServiceEntry="false"
|
||||||
|
ListName=""
|
||||||
|
ListValue=""
|
||||||
|
|
||||||
|
|
||||||
|
# redefined callback for sections when calling config_load
|
||||||
|
config_cb() {
|
||||||
|
|
||||||
|
# write out last list option (from last section) if exist and clear
|
||||||
|
if [ "$ListName" != "" ]; then
|
||||||
|
echo -e "\t$ListName = $ListVals" >> $GENERATED_CONF_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
ListName=""
|
||||||
|
ListVals=""
|
||||||
|
|
||||||
|
# "close" last service entry (from last section) if exist
|
||||||
|
if [ "$ServiceEntry" = "true" ]; then # at least one service section "opened"
|
||||||
|
echo "}" >> $GENERATED_CONF_FILE # "close" open service section in config
|
||||||
|
ServiceEntry="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then # end of config reached
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local type="$1"
|
||||||
|
local name="$2"
|
||||||
|
|
||||||
|
if [ "$type" = "service" ]; then
|
||||||
|
|
||||||
|
if [ "$ServiceEntry" = "true" ]; then
|
||||||
|
echo "}" >> $GENERATED_CONF_FILE # "close" previous opened service section in config
|
||||||
|
fi
|
||||||
|
|
||||||
|
ServiceEntry="true"
|
||||||
|
|
||||||
|
echo "" >> $GENERATED_CONF_FILE
|
||||||
|
echo "service $name" >> $GENERATED_CONF_FILE
|
||||||
|
echo "{" >> $GENERATED_CONF_FILE
|
||||||
|
|
||||||
|
# redefined callback for options when calling config_load
|
||||||
|
option_cb() {
|
||||||
|
local option="$1"
|
||||||
|
local value="$2"
|
||||||
|
|
||||||
|
[ -n "$value" ] && echo -e "\t$option = $value" >> $GENERATED_CONF_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
# redefined callback for lists when calling config_load
|
||||||
service_stop /usr/sbin/xinetd
|
list_cb() {
|
||||||
|
local name="$1"
|
||||||
|
local value="$2"
|
||||||
|
|
||||||
|
# write out last list option if new list starts
|
||||||
|
if [ "$ListName" != "" -a "$ListName" != "$name" ]; then
|
||||||
|
|
||||||
|
echo -e "\t$ListName = $ListVals" >> $GENERATED_CONF_FILE
|
||||||
|
|
||||||
|
ListName=""
|
||||||
|
ListVals=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# new list option
|
||||||
|
if [ -z "$ListName" ]; then
|
||||||
|
|
||||||
|
ListName="$name"
|
||||||
|
ListVals="$value"
|
||||||
|
else
|
||||||
|
ListVals="$ListVals $value"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
else # ignore non 'service' sections
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generate_config() {
|
||||||
|
echo "# Auto-generated config file from $CONF_FILE" > $GENERATED_CONF_FILE
|
||||||
|
echo "# Do not edit, changes to this file will be lost on upgrades" >> $GENERATED_CONF_FILE
|
||||||
|
echo "" >> $GENERATED_CONF_FILE
|
||||||
|
|
||||||
|
echo "defaults" >> $GENERATED_CONF_FILE
|
||||||
|
echo "{" >> $GENERATED_CONF_FILE
|
||||||
|
echo "" >> $GENERATED_CONF_FILE
|
||||||
|
echo "}" >> $GENERATED_CONF_FILE
|
||||||
|
echo "" >> $GENERATED_CONF_FILE
|
||||||
|
echo "includedir /etc/xinetd.d" >> $GENERATED_CONF_FILE
|
||||||
|
|
||||||
|
config_load xinetd
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
generate_config
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param command $PROG -f $GENERATED_CONF_FILE -pidfile $PIDFILE
|
||||||
|
procd_set_param respawn
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "xinetd"
|
||||||
|
}
|
||||||
|
|
11
net/xinetd/files/xinetd.uci.conf.sample
Normal file
11
net/xinetd/files/xinetd.uci.conf.sample
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#config service 'checkmk_agent'
|
||||||
|
# option type 'UNLISTED'
|
||||||
|
# option port '6556'
|
||||||
|
# option socket_type 'stream'
|
||||||
|
# option protocol 'tcp'
|
||||||
|
# option wait 'no'
|
||||||
|
# option user 'root'
|
||||||
|
# option server '/usr/bin/check_mk_agent'
|
||||||
|
# option log_on_success ''
|
||||||
|
# option only_from '127.0.0.1'
|
||||||
|
# option disable 'no'
|
Loading…
Reference in a new issue