project-config/nodepool/elements/nodepool-base/post-install.d/20-iptables
Neil Hanlon cc6b6de7a0
Add Rocky Linux to nodepool elements tooling
Change-Id: I2a94a34b1518c90ef5f0d91c9131482520c38c62
2022-02-15 17:31:34 -05:00

66 lines
1.9 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
service_name=netfilter-persistent
elif [[ "$DISTRO_NAME" =~ (centos|rhel7|fedora|openeuler|rocky) ]] ; then
service_name=iptables
elif [[ "$DISTRO_NAME" == 'opensuse' ]] ; then
# handle iptables through init.d instead of a service
exit 0
elif [[ "$DISTRO_NAME" == 'gentoo' ]] ; then
# for use in loops in both openrc and systemd
service_name='iptables ip6tables'
else
echo "Unsupported operating system $DISTRO_NAME"
exit 1
fi
case "$DIB_INIT_SYSTEM" in
upstart)
# nothing to do
;;
systemd)
if [[ "$DISTRO_NAME" == 'gentoo' ]] ; then
for service in ${service_name}; do
systemctl enable "${service}-restore.service"
systemctl enable "${service}-store.service"
done
else
systemctl enable ${service_name}.service
fi
if [[ "$DISTRO_NAME" =~ (centos|rhel7|fedora|openeuler|rocky) ]] ; then
systemctl enable ip6tables.service
fi
;;
openrc)
for service in ${service_name}; do
rc-update add "${service}" default
done
;;
*)
echo "Unsupported init system $DIB_INIT_SYSTEM"
exit 1
;;
esac