cache-domains: Fixed config files being outside of jail
This fix dnsmasq failing to startup once configured since the cache-domains config files are not included in the jail that dnsmasq runs inside. Signed-off-by: Gerard Ryan <G.M0N3Y.2503@gmail.com>
This commit is contained in:
parent
4af428ec71
commit
104bfa71a9
3 changed files with 76 additions and 13 deletions
|
@ -1,8 +1,8 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=cache-domains
|
PKG_NAME:=cache-domains
|
||||||
PKG_VERSION:=2.3.1
|
PKG_VERSION:=2.4.0
|
||||||
PKG_RELEASE:=2
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_MAINTAINER:=Gerard Ryan <G.M0N3Y.2503@gmail.com>
|
PKG_MAINTAINER:=Gerard Ryan <G.M0N3Y.2503@gmail.com>
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@ define Package/cache-domains/install/default
|
||||||
|
|
||||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface/
|
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface/
|
||||||
$(INSTALL_BIN) ./files/30-cache-domains $(1)/etc/hotplug.d/iface/
|
$(INSTALL_BIN) ./files/30-cache-domains $(1)/etc/hotplug.d/iface/
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/usr/share/cache-domains/
|
||||||
|
$(INSTALL_BIN) ./files/test.sh $(1)/usr/share/cache-domains/
|
||||||
endef
|
endef
|
||||||
|
|
||||||
Build/Compile=# Nothing to compile, just install the scripts
|
Build/Compile=# Nothing to compile, just install the scripts
|
||||||
|
|
|
@ -6,31 +6,42 @@ set -e
|
||||||
|
|
||||||
CACHE_DOMAINS_SRC="https://api.github.com/repos/uklans/cache-domains/tarball/master"
|
CACHE_DOMAINS_SRC="https://api.github.com/repos/uklans/cache-domains/tarball/master"
|
||||||
CACHE_DOMAINS_DIR="/var/cache-domains"
|
CACHE_DOMAINS_DIR="/var/cache-domains"
|
||||||
CACHE_DOMAINS_CONF_FILE="${CACHE_DOMAINS_DIR}/lancache.conf"
|
|
||||||
CONFIG_FILE="/etc/cache-domains.json"
|
CONFIG_FILE="/etc/cache-domains.json"
|
||||||
|
|
||||||
dnsmasq_conf() {
|
dnsmasq_conf() {
|
||||||
|
local ACTION="${1}"
|
||||||
|
local ADDN_CONF_DIR="${2}"
|
||||||
local I=0
|
local I=0
|
||||||
local DNSMASQ_CONF_DIR
|
local DNSMASQ_CONF_DIR
|
||||||
local DNSMASQ_CONF_FILE
|
local DNSMASQ_CONF_FILE
|
||||||
|
|
||||||
while uci_get "dhcp" "@dnsmasq[${I}]" > /dev/null; do
|
while uci_get "dhcp" "@dnsmasq[${I}]" > /dev/null; do
|
||||||
DNSMASQ_CONF_DIR="$(uci_get "dhcp" "@dnsmasq[${I}]" "confdir" "/tmp/dnsmasq.d" || :)"
|
DNSMASQ_CONF_DIR="$(uci_get "dhcp" "@dnsmasq[${I}]" "confdir" "/tmp/dnsmasq.d" || :)"
|
||||||
DNSMASQ_CONF_FILE="${DNSMASQ_CONF_DIR}/$(basename "${CACHE_DOMAINS_CONF_FILE}")"
|
uci_remove_list "dhcp" "@dnsmasq[${I}]" "addnmount" "${ADDN_CONF_DIR}"
|
||||||
|
|
||||||
case ${1} in
|
mkdir -p "${DNSMASQ_CONF_DIR}"
|
||||||
|
case "${ACTION}" in
|
||||||
add)
|
add)
|
||||||
ln -sf "${CACHE_DOMAINS_CONF_FILE}" "${DNSMASQ_CONF_FILE}"
|
ln -s "${ADDN_CONF_DIR}/"* "${DNSMASQ_CONF_DIR}" 2> /dev/null || :
|
||||||
|
uci_add_list "dhcp" "@dnsmasq[${I}]" "addnmount" "${ADDN_CONF_DIR}"
|
||||||
;;
|
;;
|
||||||
remove)
|
remove)
|
||||||
rm -f "${DNSMASQ_CONF_FILE}"
|
for DNSMASQ_CONF_FILE in "${DNSMASQ_CONF_DIR}/"*; do
|
||||||
|
case "$(readlink "${DNSMASQ_CONF_FILE}" || echo "${DNSMASQ_CONF_FILE}")" in
|
||||||
|
"${ADDN_CONF_DIR}"*)
|
||||||
|
rm -f "${DNSMASQ_CONF_FILE}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "ERROR: Invalid action '${1}' for dnsmasq_conf()"
|
echo "ERROR: Invalid action '${ACTION}' for dnsmasq_conf()"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
uci_commit "dhcp"
|
||||||
|
|
||||||
I=$((${I} + 1))
|
I=$((${I} + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -59,18 +70,16 @@ configure() {
|
||||||
cd "${SOURCE_DIR}/scripts/"
|
cd "${SOURCE_DIR}/scripts/"
|
||||||
cp "${CONFIG_FILE}" "config.json"
|
cp "${CONFIG_FILE}" "config.json"
|
||||||
./create-dnsmasq.sh > /dev/null
|
./create-dnsmasq.sh > /dev/null
|
||||||
cat "./output/dnsmasq/"*".conf" > "${CACHE_DOMAINS_CONF_FILE}"
|
|
||||||
cd "${INITIAL_DIR}"
|
cd "${INITIAL_DIR}"
|
||||||
rm -fr "${SOURCE_DIR}"
|
|
||||||
|
|
||||||
dnsmasq_conf add
|
dnsmasq_conf add "${SOURCE_DIR}/scripts/output/dnsmasq"
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
dnsmasq_conf remove
|
dnsmasq_conf remove "${CACHE_DOMAINS_DIR}/$(ls "${CACHE_DOMAINS_DIR}")/scripts/output/dnsmasq"
|
||||||
}
|
}
|
||||||
|
|
||||||
case ${1} in
|
case "${1}" in
|
||||||
config*)
|
config*)
|
||||||
configure
|
configure
|
||||||
;;
|
;;
|
||||||
|
|
51
utils/cache-domains/files/test.sh
Normal file
51
utils/cache-domains/files/test.sh
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
|
test_url() {
|
||||||
|
echo "INFO: Testing '${2}' has ${1} addresses" >&2
|
||||||
|
|
||||||
|
case "${1}" in
|
||||||
|
IPv4)
|
||||||
|
nslookup -type=a "${2}"
|
||||||
|
;;
|
||||||
|
IPv6)
|
||||||
|
nslookup -type=aaaa "${2}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Unknown IP version: ${1}" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_domains() {
|
||||||
|
echo "INFO: cache-domains ${1}" >&2
|
||||||
|
cache-domains "${1}"
|
||||||
|
sleep 5
|
||||||
|
}
|
||||||
|
|
||||||
|
cache_domains cleanup
|
||||||
|
|
||||||
|
test_url IPv4 lancache.steamcontent.com | grep -q 'canonical name ='
|
||||||
|
test_url IPv6 lancache.steamcontent.com | grep -q 'canonical name ='
|
||||||
|
|
||||||
|
test_url IPv4 dist.blizzard.com | grep -q 'canonical name ='
|
||||||
|
test_url IPv6 dist.blizzard.com | grep -q 'canonical name ='
|
||||||
|
|
||||||
|
cache_domains configure
|
||||||
|
|
||||||
|
test_url IPv4 lancache.steamcontent.com | grep -q '10.10.3.10'
|
||||||
|
test_url IPv4 lancache.steamcontent.com | grep -q '10.10.3.11'
|
||||||
|
test_url IPv6 lancache.steamcontent.com > /dev/null # None configured
|
||||||
|
|
||||||
|
test_url IPv4 dist.blizzard.com | grep -q '10.10.3.13'
|
||||||
|
test_url IPv6 dist.blizzard.com > /dev/null # None configured
|
||||||
|
|
||||||
|
cache_domains cleanup
|
||||||
|
|
||||||
|
test_url IPv4 lancache.steamcontent.com | grep -q 'canonical name ='
|
||||||
|
test_url IPv6 lancache.steamcontent.com | grep -q 'canonical name ='
|
||||||
|
|
||||||
|
test_url IPv4 dist.blizzard.com | grep -q 'canonical name ='
|
||||||
|
test_url IPv6 dist.blizzard.com | grep -q 'canonical name ='
|
Loading…
Reference in a new issue