File docker-container-ifdel of Package docker-container-starter
#!/bin/bash
if [[ -z "${IFCONFIG_FILE}" ]] || [[ ! -f "${IFCONFIG_FILE}" ]]; then
if [[ -z "${IFCONFIG_FILE}" ]]; then
logger -p warning "Path of interface configuration file is not set, try default path..."
elif [[ ! -e "${IFCONFIG_FILE}" ]]; then
logger -p warning "Path of interface configuration file does not point to a file, try default path..."
elif [[ ! -f "${IFCONFIG_FILE}" ]]; then
logger -p warning "Path of interface configuration file does not point to a readable file, try default path..."
fi
if [[ -z "${RUNTIME_DIRECTORY}" ]]; then
logger -p error "Runtime directory is not set either, is this script run from the systemd docker-container@.service? Quit now."
exit 255
elif [[ -f "${RUNTIME_DIRECTORY}/ifconfig" ]]; then
IFCONFIG_FILE="${RUNTIME_DIRECTORY}/ifconfig"
logger -p info "using file "${IFCONFIG_FILE}" as network interface configuration file."
else
logger -p error "Can not file default network interface configuration file. quit now."
exit 255
fi
fi
if [[ -z "${NAME}" ]]; then
logger -p error "The environment variable NAME is empty, this must be a valid docker container name."
exit 255
fi
source "${IFCONFIG_FILE}"
if [[ ${I_IF} -eq 0 ]]; then
logger -p warning "No interfaces are defined for docker container \"${NAME}\"."
exit 0
fi
ret=0
for i in $(seq 0 ${I_IF}); do
if [ $i -ge ${I_IF} ]; then
break
fi
logger -p info "Stopping network interface ${i} ..."
if [[ -z "${IF_BRIDGE[${i}]}" ]]; then
logger -p error "No bridge defined, can not create interface."
let "ret++"
break
fi
/usr/bin/ovs-docker del-ports "${IF_BRIDGE[${i}]}" "${NAME}"
if [[ $? -ne 0 ]]; then
logger -p error "ovs-docker returned code: $?."
let "ret++"
fi
done
exit $ret