James E. Blair 6736ee2251 Add image build jobs
Depends-On: https://review.opendev.org/940561

Change-Id: I691fafc25b377d812d002fae34aef2e0bc8e552a
2025-01-31 15:24:22 -08: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