From ca80972e4bd59afec7cf4bcc267d0fd4cc251944 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Mon, 25 Jul 2016 18:11:13 +0200 Subject: [PATCH] Systemd-based config for RPM --- base_rpm.one/etc/init.d/vmcontext | 38 ------------------- base_rpm.one/etc/one-context.d/10-network | 19 ++-------- .../lib/systemd/system/vmcontext.service | 13 +++++++ postinstall.ec2 | 2 +- postinstall.one | 2 +- 5 files changed, 18 insertions(+), 56 deletions(-) delete mode 100755 base_rpm.one/etc/init.d/vmcontext create mode 100644 base_rpm.one/lib/systemd/system/vmcontext.service diff --git a/base_rpm.one/etc/init.d/vmcontext b/base_rpm.one/etc/init.d/vmcontext deleted file mode 100755 index 5e847c4..0000000 --- a/base_rpm.one/etc/init.d/vmcontext +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# chkconfig: 2345 9 99 -# description: network reconfigure -# -# -------------------------------------------------------------------------- # -# Copyright 2010-2016, OpenNebula Systems # -# # -# 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. # -#--------------------------------------------------------------------------- # - -### BEGIN INIT INFO -# Provides: vmcontext -# Required-Start: $all -# Required-Stop: -# Should-Start: networking -# Should-Stop: networking -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: OpenNebula contextualization script -### END INIT INFO - -case "$1" in -"start") - /usr/sbin/one-contextd - -esac - diff --git a/base_rpm.one/etc/one-context.d/10-network b/base_rpm.one/etc/one-context.d/10-network index 6b25b9d..c0c621b 100755 --- a/base_rpm.one/etc/one-context.d/10-network +++ b/base_rpm.one/etc/one-context.d/10-network @@ -125,6 +125,7 @@ IPV6INIT=yes IPV6ADDR=$IPV6 IPV6_AUTOCONF=no EOT + echo 0 > /proc/sys/net/ipv6/conf/$DEV/autoconf if [ -n "$MTU" ]; then echo "MTU=$MTU" @@ -184,7 +185,7 @@ gen_network_configuration() ( cat < /etc/sysconfig/network-scripts/ifcfg-${DEV} - - ifup ${DEV} - done } -configure_network() -{ - gen_network_configuration - - service network restart - - sleep 2 -} - -[ -z "$(env | cut -d= -f1 | grep -E '^ETH[0-9]+_IPV*6*')" ] && exit 0 - -configure_network +gen_network_configuration diff --git a/base_rpm.one/lib/systemd/system/vmcontext.service b/base_rpm.one/lib/systemd/system/vmcontext.service new file mode 100644 index 0000000..c5881d5 --- /dev/null +++ b/base_rpm.one/lib/systemd/system/vmcontext.service @@ -0,0 +1,13 @@ +[Unit] +Description=OpenNebula contextualization script +Requires=dev-disk-by\x2dlabel-CONTEXT.device +After=dev-disk-by\x2dlabel-CONTEXT.device +Before=network.service + +[Service] +Type=oneshot +ExecStart=/usr/sbin/one-contextd + +[Install] +WantedBy=multi-user.target + diff --git a/postinstall.ec2 b/postinstall.ec2 index 9d7d35b..236c497 100755 --- a/postinstall.ec2 +++ b/postinstall.ec2 @@ -28,7 +28,7 @@ fi # RedHat based distros if [ -d /etc/sysconfig/network-scripts ]; then # Register Service - chkconfig --add vmcontext +# chkconfig --add vmcontext fi diff --git a/postinstall.one b/postinstall.one index 9c0107c..eb1178e 100755 --- a/postinstall.one +++ b/postinstall.one @@ -56,7 +56,7 @@ fi # RedHat based distros if [ -d /etc/sysconfig/network-scripts ]; then # Register Service - chkconfig --add vmcontext + systemctl enable vmcontext.service # Prepare network files rm -f /etc/sysconfig/network-scripts/ifcfg-eth*