fix: Verify PID is not empty

This commit is contained in:
Kroese 2024-04-16 14:56:55 +02:00 committed by GitHub
parent 88fd998555
commit 6f6e3e6625
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -223,7 +223,7 @@ closeNetwork() {
else else
local pid="/var/run/dnsmasq.pid" local pid="/var/run/dnsmasq.pid"
[ -f "$pid" ] && pKill "$(<"$pid")" [ -s "$pid" ] && pKill "$(<"$pid")"
ip link set "$VM_NET_TAP" down promisc off || true ip link set "$VM_NET_TAP" down promisc off || true
ip link delete "$VM_NET_TAP" || true ip link delete "$VM_NET_TAP" || true
@ -251,7 +251,7 @@ getInfo() {
if [ -z "$MAC" ]; then if [ -z "$MAC" ]; then
local file="$STORAGE/$PROCESS.mac" local file="$STORAGE/$PROCESS.mac"
[ -f "$file" ] && MAC=$(<"$file") [ -s "$file" ] && MAC=$(<"$file")
if [ -z "$MAC" ]; then if [ -z "$MAC" ]; then
# Generate MAC address based on Docker container ID in hostname # Generate MAC address based on Docker container ID in hostname
MAC=$(echo "$HOST" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/') MAC=$(echo "$HOST" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')