project-config/nodepool/elements/nodepool-base/post-install.d/20-iptables

52 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
# dib-lint: disable=setu setpipefail
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -e
if [[ "$DISTRO_NAME" =~ (debian|ubuntu) ]] ; then
if [[ "$DIB_RELEASE" == 'trusty' ]] ; then
service_name=iptables-persistent
else
service_name=netfilter-persistent
fi
elif [[ "$DISTRO_NAME" =~ (centos|fedora) ]] ; then
service_name=iptables
else
echo "Unsupported operating system $DISTRO_NAME"
exit 1
fi
case "$DIB_INIT_SYSTEM" in
upstart)
# nothing to do
;;
systemd)
systemctl enable ${service_name}.service
if [[ "$DISTRO_NAME" =~ (centos|fedora) ]] ; then
systemctl enable ip6tables.service
fi
;;
*)
echo "Unsupported init system $DIB_INIT_SYSTEM"
exit 1
;;
esac