Merge remote-tracking branch 'origin/gh-78'

pull/100/head
Vlastimil Holer 7 years ago
commit 2dc909a469
No known key found for this signature in database
GPG Key ID: EB549BADEFD07C53

@ -1,4 +1,4 @@
TARGETS='el6 el6_ec2 el7 el7_ec2 suse deb deb_ec2 alpine'
TARGETS='el6 el7 el7_ec2 suse deb deb_ec2 alpine'
set -e
for TARGET in $TARGETS; do

@ -65,7 +65,10 @@ fi
set -e
BUILD_DIR=$(mktemp -d)
trap "rm -rf ${BUILD_DIR}" EXIT
_POSTIN=$(mktemp)
_PREUN=$(mktemp)
trap "rm -rf ${BUILD_DIR} ${_POSTIN} ${_PREUN}" EXIT
while IFS= read -r -d $'\0' SRC; do
F_TAGS=${SRC##*##}
@ -111,22 +114,31 @@ else
! -path 'etc/init*' \
-type f -printf '--config-files %p ')
# concatenate pre/postinstall scripts
if [ -n "${POSTIN}" ]; then
cat ${POSTIN} >"${_POSTIN}"
fi
if [ -n "${PREUN}" ]; then
cat ${PREUN} >"${_PREUN}"
fi
fpm --name "${NAME}" --version "${VERSION}" --iteration "${RELEASE_FULL}" \
--architecture all --license "${LICENSE}" \
--vendor "${VENDOR}" --maintainer "${MAINTAINER}" \
--description "${DESCRIPTION}" --url "${URL}" \
--output-type "${TYPE}" --input-type dir --chdir "${BUILD_DIR}" \
${POSTIN:+ --after-install ${POSTIN}} \
${PREUN:+ --before-remove ${PREUN}} \
${POSTIN:+ --after-install ${_POSTIN}} \
${PREUN:+ --before-remove ${_PREUN}} \
--rpm-os linux \
--rpm-summary "${SUMMARY}" \
${DEPENDS:+ --depends ${DEPENDS// / --depends }} \
--replaces "${REPLACES}" \
--conflicts "${REPLACES}" \
${REPLACES:+ --replaces ${REPLACES// / --replaces }} \
${CONFLICTS:+ --conflicts ${CONFLICTS// / --conflicts }} \
${PROVIDES:+ --provides ${PROVIDES// / --provides }} \
--deb-no-default-config-files \
${CONFIG_FILES} \
--package "${OUT}"
# --provides "${REPLACES}" \
fi
echo $(basename ${OUT})

@ -16,7 +16,9 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
SERVICES='one-context-local one-context'
NETWORK=${NETWORK:-yes}
NETWORK_EC2=${NETWORK_EC2:-no}
SERVICES=${SERVICES:-one-context-local one-context}
rm -f /etc/udev/rules.d/70-persistent-cd.rules
rm -f /etc/udev/rules.d/70-persistent-net.rules
@ -62,16 +64,33 @@ else
echo 'WARNING: Contextualization service not enabled automatically' >&2
fi
# Cleanup network configuration
if [ "${NETWORK}" != 'yes' ]; then
exit
fi
# Debian based distros
if [ -d /etc/network ]; then
# Prepare network files
cp /etc/network/interfaces /etc/network/interfaces.$(date "+%s")
cat > /etc/network/interfaces <<EOT
rm -rf /etc/network/interfaces.d
if [ "${NETWORK_EC2}" = 'yes' ]; then
cat > /etc/network/interfaces <<EOT
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
EOT
rm -rf /etc/network/interfaces.d
else
cat > /etc/network/interfaces <<EOT
# The loopback network interface
auto lo
iface lo inet loopback
EOT
fi
# Do not reconfigure network interfaces on boot
# if [ -f /etc/default/networking ]; then
@ -79,31 +98,49 @@ EOT
# echo 'CONFIGURE_INTERFACES=no' >> /etc/default/networking
# fi
# fi
# Remove ttyS* from the grub
if [ -f /etc/default/grub ]; then
sed -i 's/console=ttyS[a-zA-Z0-9,]*//g' /etc/default/grub
fi
if [ -f /boot/grub/grub.cfg ]; then
sed -i 's/console=ttyS[a-zA-Z0-9,]*//g' /boot/grub/grub.cfg
fi
fi
# RedHat based distros
if [ -d /etc/sysconfig/network-scripts ]; then
# Prepare network files
rm -f /etc/sysconfig/network-scripts/ifcfg-eth*
find /etc/sysconfig/network-scripts -type f \
-name 'ifcfg-*' ! -name 'ifcfg-lo' \
-exec rm -f {} \;
if [ "${NETWORK_EC2}" = 'yes' ]; then
cat >/etc/sysconfig/network-scripts/ifcfg-eth0 <<EOT
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
USERCTL="yes"
PEERDNS="yes"
IPV6INIT="no"
NM_CONTROLLED="no"
PERSISTENT_DHCLIENT="1"
EOT
fi
fi
# openSUSE based distros
if [ -d /etc/sysconfig/network ]; then
# Prepare network files
rm -f /etc/sysconfig/network/ifcfg-eth*
rm -f /etc/sysconfig/network/ifroute-eth*
rm -f /etc/sysconfig/network/routes
rm -f /etc/sysconfig/network/ifsysctl
rm -f /etc/sysconfig/network/ifsysctl-eth*
sed -i '/^NETCONFIG_DNS_STATIC_SERVERS=/ s/=.*$/=""/' /etc/sysconfig/network/config
find /etc/sysconfig/network -type f \
\( -name 'ifcfg-*' -o -name 'ifroute-*' -o -name 'ifsysctl-*' \) \
! -name 'ifcfg-lo' ! -name 'ifroute-lo' ! -name 'ifsysctl-lo' \
-exec rm -f {} \;
rm -f /etc/sysconfig/network/routes /etc/sysconfig/network/ifsysctl
sed -i '/^NETCONFIG_DNS_STATIC_SERVERS=/ s/=.*$/="/' /etc/sysconfig/network/config
sed -i '/^NETCONFIG_DNS_STATIC_SEARCHLIST=/ s/=.*$/=""/' /etc/sysconfig/network/config
if [ "${NETWORK_EC2}" = 'yes' ]; then
cat >/etc/sysconfig/network/ifcfg-eth0 <<EOT
DEVICE=eth0
BOOTPROTO=dhcp4
STARTMODE=auto
USERCONTROL=yes
EOT
fi
fi

@ -16,19 +16,5 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
rm -f /etc/udev/rules.d/70-persistent-cd.rules
rm -f /etc/udev/rules.d/70-persistent-net.rules
# Debian based distros
if [ -d /etc/network ]; then
# Register Service
update-rc.d vmcontext defaults 99 99
fi
# RedHat based distros
if [ -d /etc/sysconfig/network-scripts ]; then
# Register Service
chkconfig --add vmcontext
fi
NETWORK_EC2=yes
SERVICES='one-context'

@ -16,7 +16,7 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
SERVICES='one-context one-context-local'
SERVICES=${SERVICES:-one-context one-context-local}
# Disable services
if which systemctl >/dev/null 2>&1 && [ -d /etc/systemd ]; then

@ -15,3 +15,5 @@
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SERVICES='one-context'

@ -1,38 +0,0 @@
#!/bin/bash
#
# chkconfig: 2345 11 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

@ -73,8 +73,20 @@ first_ip=$(get_first_ip)
if [ -n "$SET_HOSTNAME" ]; then
name=$(echo "$SET_HOSTNAME" | \
sed -e 's/[^-a-zA-Z0-9\.]/-/g' -e 's/^-*//g' -e 's/-*$//g')
elif [ -n "$DNS_HOSTNAME" ]; then
name=$(get_dns_name "${first_ip}")
elif [ "${EC2_HOSTNAME}" = 'YES' ]; then
# try to quickly get hostname from the EC2 metadata server or
# create hostname based on the first IPv4 (format: "ip-1-2-3-4")
name=$(curl -sf -m 5 'http://169.254.169.254/latest/meta-data/local-hostname' 2>/dev/null)
if [ -z "${name}" ]; then
name="$(echo "${first_ip}" | grep -x '[0-9\.]\+' | tr . -)"
if [ -n "${name}" ]; then
name="ip-${name}"
fi
fi
fi
if [ -n "${name}" ]; then

@ -0,0 +1,14 @@
[Unit]
Description=OpenNebula contextualization script
Requires=network.target
After=multi-user.target
ConditionPathExists=!/var/run/one-context/context.sh.local
ConditionPathExists=!/var/run/one-context/context.sh.network
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/one-contextd all
[Install]
WantedBy=multi-user.target

@ -164,9 +164,15 @@ function get_new_context {
vmtoolsd --cmd 'info-get guestinfo.opennebula.context' | \
openssl base64 -d > ${CONTEXT_NEW}
elif curl -s -m 30 -o ${CONTEXT_NEW} http://169.254.169.254/latest/user-data; then
elif curl -sf -m 30 -o ${CONTEXT_NEW} http://169.254.169.254/latest/user-data; then
log debug "Reading EC2 user-data"
echo -n ""
echo -n "" >>"${CONTEXT_NEW}"
# enable EC2 hostname configuration
export EC2_HOSTNAME=YES
else
log err 'Error: No contextualization found' 2
exit 1
fi
}

@ -4,10 +4,12 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-.el6}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-rpm sysv one}
DEPENDS=${DEPENDS:-util-linux-ng bind-utils cloud-utils-growpart dracut-modules-growroot ruby rubygem-json sudo shadow-utils open-vm-tools qemu-guest-agent}
DEPENDS=${DEPENDS:-util-linux-ng bash curl bind-utils cloud-utils-growpart dracut-modules-growroot ruby rubygem-json sudo shadow-utils open-vm-tools qemu-guest-agent}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
POSTIN=${POSTINST:-postinstall.one}
PREUN=${PREUN:-preuninstall.one}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
POSTIN=${POSTINST:-postinstall}
PREUN=${PREUN:-preuninstall}
;;
@ -16,10 +18,12 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-.el6}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-rpm sysv ec2}
DEPENDS=${DEPENDS:-util-linux-ng bind-utils cloud-utils-growpart dracut-modules-growroot ruby rubygem-json sudo shadow-utils}
DEPENDS=${DEPENDS:-util-linux-ng bash curl bind-utils cloud-utils-growpart dracut-modules-growroot ruby rubygem-json sudo shadow-utils}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
POSTIN=${POSTINST:-postinstall.ec2}
PREUN=${PREUN:-preuninstall.ec2}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context}
POSTIN=${POSTINST:-postinstall.ec2 postinstall}
PREUN=${PREUN:-preuninstall.ec2 preuninstall}
;;
'el7')
@ -27,21 +31,25 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-.el7}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-rpm systemd one}
DEPENDS=${DEPENDS:-util-linux bind-utils cloud-utils-growpart ruby rubygem-json sudo shadow-utils open-vm-tools qemu-guest-agent}
DEPENDS=${DEPENDS:-util-linux bash curl bind-utils cloud-utils-growpart ruby rubygem-json sudo shadow-utils open-vm-tools qemu-guest-agent}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
POSTIN=${POSTINST:-postinstall.one}
PREUN=${PREUN:-preuninstall.one}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
POSTIN=${POSTINST:-postinstall}
PREUN=${PREUN:-preuninstall}
;;
'el7_ec2')
NAME=${NAME:-one-context-ec2}
RELSUFFIX=${RELSUFFIX:-.el7}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-rpm sysv ec2}
DEPENDS=${DEPENDS:-util-linux bind-utils cloud-utils-growpart ruby rubygem-json sudo shadow-utils}
TAGS=${TAGS:-rpm systemd ec2}
DEPENDS=${DEPENDS:-util-linux bash curl bind-utils cloud-utils-growpart ruby rubygem-json sudo shadow-utils}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
POSTIN=${POSTINST:-postinstall.ec2}
PREUN=${PREUN:-preuninstall.ec2}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context}
POSTIN=${POSTINST:-postinstall.ec2 postinstall}
PREUN=${PREUN:-preuninstall.ec2 preuninstall}
;;
'suse')
@ -49,32 +57,52 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-.suse}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-rpm systemd one}
DEPENDS=${DEPENDS:-util-linux bind-utils growpart ruby sudo shadow open-vm-tools qemu-guest-agent} # rubygem-json}
DEPENDS=${DEPENDS:-util-linux bash curl bind-utils growpart ruby sudo shadow open-vm-tools qemu-guest-agent} # rubygem-json}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init cloud-init-config-suse}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
POSTIN=${POSTINST:-postinstall}
PREUN=${PREUN:-preuninstall}
;;
'suse_ec2')
NAME=${NAME:-one-context-ec2}
RELSUFFIX=${RELSUFFIX:-.suse}
TYPE=${TYPE:-rpm}
TAGS=${TAGS:-rpm systemd ec2}
DEPENDS=${DEPENDS:-util-linux bash curl bind-utils growpart ruby sudo shadow} # rubygem-json}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init cloud-init-config-suse}
POSTIN=${POSTINST:-postinstall.one}
PREUN=${PREUN:-preuninstall.one}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context}
POSTIN=${POSTINST:-postinstall.ec2 postinstall}
PREUN=${PREUN:-preuninstall.ec2 preuninstall}
;;
'deb')
NAME=${NAME:-one-context}
RELSUFFIX=${RELSUFFIX:-}
TYPE=${TYPE:-deb}
TAGS=${TAGS:-deb sysv systemd upstart one}
DEPENDS=${DEPENDS:-util-linux bind9-host cloud-utils ruby python ifupdown acpid sudo passwd open-vm-tools qemu-guest-agent}
DEPENDS=${DEPENDS:-util-linux bash curl bind9-host cloud-utils ruby python ifupdown acpid sudo passwd open-vm-tools qemu-guest-agent}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
POSTIN=${POSTINST:-postinstall.one}
PREUN=${PREUN:-preuninstall.one}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
POSTIN=${POSTINST:-postinstall}
PREUN=${PREUN:-preuninstall}
;;
'deb_ec2')
NAME=${NAME:-one-context-ec2}
RELSUFFIX=${RELSUFFIX:-}
TYPE=${TYPE:-deb}
TAGS=${TAGS:-deb ec2}
DEPENDS=${DEPENDS:-util-linux bind9-host cloud-utils ruby python ifupdown sudo passwd}
TAGS=${TAGS:-deb sysv systemd upstart ec2}
DEPENDS=${DEPENDS:-util-linux bash curl bind9-host cloud-utils ruby python ifupdown sudo passwd resolvconf}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
POSTIN=${POSTINST:-postinstall.ec2}
PREUN=${PREUN:-preuninstall.ec2}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context}
POSTIN=${POSTINST:-postinstall.ec2 postinstall}
PREUN=${PREUN:-preuninstall.ec2 preuninstall}
;;
'alpine')
@ -82,16 +110,34 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-}
TYPE=${TYPE:-apk}
TAGS=${TAGS:-apk one}
DEPENDS=${DEPENDS:-util-linux bash curl rsync udev iptables sfdisk e2fsprogs-extra open-vm-tools qemu-guest-agent keepalived quagga sudo shadow}
REPLACES=${REPLACES:-}
POSTIN=${POSTINST:-postinstall.one}
PREUN=${PREUN:-preuninstall.one}
DEPENDS=${DEPENDS:-util-linux bash curl rsync udev iptables sfdisk e2fsprogs-extra keepalived quagga sudo shadow open-vm-tools qemu-guest-agent}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-} #not respected
CONFLICTS=${CONFLICTS:-one-context-ec2}
POSTIN=${POSTINST:-postinstall}
PREUN=${PREUN:-preuninstall}
;;
'alpine_ec2')
NAME=${NAME:-one-context-ec2}
RELSUFFIX=${RELSUFFIX:-}
TYPE=${TYPE:-apk}
TAGS=${TAGS:-apk ec2}
DEPENDS=${DEPENDS:-util-linux bash curl rsync udev iptables sfdisk e2fsprogs-extra keepalived quagga sudo shadow}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-} #not respected
CONFLICTS=${CONFLICTS:-one-context}
POSTIN=${POSTINST:-postinstall.ec2 postinstall}
PREUN=${PREUN:-preuninstall.ec2 preuninstall}
;;
'arch')
NAME=${NAME:-one-context}
TYPE=${TYPE:-dir}
TAGS=${TAGS:-arch one}
echo 'ArchLinux target is currently not maintained'
exit 1
;;
*)

Loading…
Cancel
Save