* luci/contrib/addons: add luci_hosts infrastructure
This commit is contained in:
parent
a849e84bfb
commit
be767cb726
3 changed files with 36 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-addons
|
PKG_NAME:=luci-addons
|
||||||
PKG_VERSION:=0.2
|
PKG_VERSION:=0.3
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||||
|
@ -32,8 +32,10 @@ define Package/luci-addons/install
|
||||||
$(INSTALL_BIN) ./dist/sbin/luci-flash $(1)/sbin
|
$(INSTALL_BIN) ./dist/sbin/luci-flash $(1)/sbin
|
||||||
$(INSTALL_BIN) ./dist/etc/init.d/luci_fixtime $(1)/etc/init.d
|
$(INSTALL_BIN) ./dist/etc/init.d/luci_fixtime $(1)/etc/init.d
|
||||||
$(INSTALL_BIN) ./dist/etc/init.d/luci_ethers $(1)/etc/init.d
|
$(INSTALL_BIN) ./dist/etc/init.d/luci_ethers $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) ./dist/etc/init.d/luci_hosts $(1)/etc/init.d
|
||||||
|
|
||||||
$(INSTALL_CONF) ./dist/etc/config/luci_ethers $(1)/etc/config
|
$(INSTALL_CONF) ./dist/etc/config/luci_ethers $(1)/etc/config
|
||||||
|
$(INSTALL_CONF) ./dist/etc/config/luci_hosts $(1)/etc/config
|
||||||
|
|
||||||
$(CP) ./dist/etc/crontabs/root $(1)/etc/crontabs/root
|
$(CP) ./dist/etc/crontabs/root $(1)/etc/crontabs/root
|
||||||
endef
|
endef
|
||||||
|
|
3
contrib/package/luci-addons/dist/etc/config/luci_hosts
vendored
Normal file
3
contrib/package/luci-addons/dist/etc/config/luci_hosts
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
config 'host'
|
||||||
|
option 'ipaddr' '10.11.12.13'
|
||||||
|
option 'hostname' 'sample-host'
|
30
contrib/package/luci-addons/dist/etc/init.d/luci_hosts
vendored
Normal file
30
contrib/package/luci-addons/dist/etc/init.d/luci_hosts
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
START=60
|
||||||
|
|
||||||
|
apply_host() {
|
||||||
|
local cfg="$1"
|
||||||
|
|
||||||
|
config_get hostname "$cfg" hostname
|
||||||
|
config_get ipaddr "$cfg" ipaddr
|
||||||
|
|
||||||
|
[ -n "$hostname" -a -n "$ipaddr" ] || return 0
|
||||||
|
|
||||||
|
echo "$ipaddr $hostname" >> /var/etc/hosts
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
if [ ! -L /etc/hosts ]; then
|
||||||
|
test -f /etc/hosts && mv /etc/hosts /etc/hosts.local
|
||||||
|
ln -s /var/etc/hosts /etc/hosts
|
||||||
|
fi
|
||||||
|
|
||||||
|
test -d /var/etc || mkdir -p /var/etc
|
||||||
|
test -f /etc/hosts.local && cat /etc/hosts.local >> /var/etc/hosts
|
||||||
|
|
||||||
|
config_load luci_hosts
|
||||||
|
config_foreach apply_host host
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
test -f /var/etc/hosts && rm -f /var/etc/hosts
|
||||||
|
}
|
Loading…
Reference in a new issue