mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-10-13 06:04:58 +08:00
feat: Enhanced Dnsmasq logging (#1039)
This commit is contained in:
parent
09ca3bf118
commit
7acd1f6cdb
@ -107,6 +107,9 @@ configureDHCP() {
|
|||||||
|
|
||||||
configureDNS() {
|
configureDNS() {
|
||||||
|
|
||||||
|
local log="/var/log/dnsmasq.log"
|
||||||
|
rm -f "$log"
|
||||||
|
|
||||||
# Create lease file for faster resolve
|
# Create lease file for faster resolve
|
||||||
echo "0 $VM_NET_MAC $VM_NET_IP $VM_NET_HOST 01:$VM_NET_MAC" > /var/lib/misc/dnsmasq.leases
|
echo "0 $VM_NET_MAC $VM_NET_IP $VM_NET_HOST 01:$VM_NET_MAC" > /var/lib/misc/dnsmasq.leases
|
||||||
chmod 644 /var/lib/misc/dnsmasq.leases
|
chmod 644 /var/lib/misc/dnsmasq.leases
|
||||||
@ -125,18 +128,21 @@ configureDNS() {
|
|||||||
|
|
||||||
# Add DNS entry for container
|
# Add DNS entry for container
|
||||||
DNSMASQ_OPTS+=" --address=/host.lan/${VM_NET_IP%.*}.1"
|
DNSMASQ_OPTS+=" --address=/host.lan/${VM_NET_IP%.*}.1"
|
||||||
|
DNSMASQ_OPTS+=" --log-facility=$log"
|
||||||
|
|
||||||
DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
|
DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
|
||||||
|
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Starting Dnsmasq daemon..."
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Starting Dnsmasq daemon..."
|
||||||
|
|
||||||
if [[ "${DEBUG_DNS:-}" == [Yy1]* ]]; then
|
if ! $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}; then
|
||||||
DNSMASQ_OPTS+=" -d"
|
local msg="Failed to start Dnsmasq, reason: $?"
|
||||||
$DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS} &
|
[ -f "$log" ] && cat "$log"
|
||||||
return 0
|
error "$msg"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}; then
|
if [[ "${DEBUG_DNS:-}" == [Yy1]* ]]; then
|
||||||
error "Failed to start dnsmasq, reason: $?" && return 1
|
tail -fn +0 "$log" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -515,6 +521,9 @@ if [[ "$IP" == "172.17."* ]]; then
|
|||||||
warn "your container IP starts with 172.17.* which will cause conflicts when you install the Container Manager package inside DSM!"
|
warn "your container IP starts with 172.17.* which will cause conflicts when you install the Container Manager package inside DSM!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clean up old files
|
||||||
|
rm -f /var/run/dnsmasq.pid
|
||||||
|
|
||||||
if [[ -d "/sys/class/net/$VM_NET_TAP" ]]; then
|
if [[ -d "/sys/class/net/$VM_NET_TAP" ]]; then
|
||||||
info "Lingering interface will be removed..."
|
info "Lingering interface will be removed..."
|
||||||
ip link delete "$VM_NET_TAP" || true
|
ip link delete "$VM_NET_TAP" || true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user