[DRE-commits] [vagrant-libvirt] 17/104: Tool for RedHat image preparation.

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:55:40 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag 0.0.11
in repository vagrant-libvirt.

commit 9f67b6b1b887db724c8faa3d56566632810fc450
Author: pradels <les.pradels at gmail.com>
Date:   Tue Apr 9 15:31:56 2013 +0200

    Tool for RedHat image preparation.
---
 tools/prepare_redhat_for_box.sh | 106 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 106 insertions(+)

diff --git a/tools/prepare_redhat_for_box.sh b/tools/prepare_redhat_for_box.sh
new file mode 100755
index 0000000..eb14331
--- /dev/null
+++ b/tools/prepare_redhat_for_box.sh
@@ -0,0 +1,106 @@
+#!/bin/bash +x
+
+# This script should help to prepare RedHat and RedHat like OS (CentOS,
+# Scientific Linux, ...) for Vagrant box usage.
+
+# To create new box image, just install minimal base system in VM on top of not
+# fully allocated qcow2 image. Then upload this script to the VM and run it.
+# After script has finished, nothing else than halting machine should be done.
+
+# For more info about creating custom box refer to
+# https://github.com/pradels/vagrant-libvirt/tree/master/example_box
+
+# We need a hostname.
+if [ $# -ne 1 ]; then
+	echo "Usage: $0 <hostname>"
+	echo "Hostname should be in format vagrant-[os-name], e.g. vagrant-redhat63."
+	exit 1
+fi
+
+
+# On which version of RedHet are we running?
+RHEL_MAJOR_VERSION=$(sed 's/.*release \([0-9]\)\..*/\1/' /etc/redhat-release)
+if [ $? -ne 0 ]; then
+	echo "Is this a RedHat distro?"
+	exit 1
+fi
+echo "* Found RedHat ${RHEL_MAJOR_VERSION} version."
+
+
+# Setup hostname vagrant-something.
+FQDN="$1.vagrantup.com"
+if grep '^HOSTNAME=' /etc/sysconfig/network > /dev/null; then
+	sed -i 's/HOSTNAME=\(.*\)/HOSTNAME='${FQDN}'/' /etc/sysconfig/network
+else
+	echo "HOSTNAME=${FQDN}" >> /etc/sysconfig/network
+fi
+
+
+# Enable EPEL repository.
+yum -y install wget
+cd ~root
+if [ $RHEL_MAJOR_VERSION -eq 5 ]; then
+	wget http://ftp.astral.ro/mirrors/fedora/pub/epel/5/i386/epel-release-5-4.noarch.rpm
+	EPEL_PKG="epel-release-5-4.noarch.rpm"
+else
+	wget http://ftp.astral.ro/mirrors/fedora/pub/epel/6/i386/epel-release-6-8.noarch.rpm
+	EPEL_PKG="epel-release-6-8.noarch.rpm"
+fi
+rpm -i ~root/${EPEL_PKG}
+rm -f ~root/${EPEL_PKG}
+
+
+# Install some required software.
+yum -y install openssh-server openssh-clients sudo \
+ruby ruby-devel make gcc rubygems rsync
+chkconfig sshd on
+gem install puppet
+gem install chef
+
+
+# Users, groups, passwords and sudoers.
+echo 'vagrant' | passwd --stdin root
+grep 'vagrant' /etc/passwd > /dev/null
+if [ $? -ne 0 ]; then
+	echo '* Creating user vagrant.'
+	useradd vagrant
+	echo 'vagrant' | passwd --stdin vagrant
+fi
+grep '^admin:' /etc/group > /dev/null || groupadd admin
+usermod -G admin vagrant
+
+echo 'Defaults    env_keep += "SSH_AUTH_SOCK"' >> /etc/sudoers
+echo '%admin ALL=NOPASSWD: ALL' >> /etc/sudoers
+sed -i 's/Defaults requiretty/Defaults !requiretty/' /etc/sudoers
+
+
+# SSH keys
+# Add Vagrant ssh key for root accout.
+[ -d ~root/.ssh ] || mkdir ~root/.ssh
+chmod 700 ~root/.ssh
+cat > ~root/.ssh/authorized_keys << EOF
+ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
+EOF
+chmod 600 ~root/.ssh/authorized_keys
+
+
+# Networking setup..
+# Don't fix ethX names to hw address.
+rm -f /etc/udev/rules.d/*persistent-net.rules
+rm -f /etc/udev/rules.d/*-net.rules
+rm -fr /var/lib/dhclient/*
+
+# Interface eth0 should get IP address via dhcp.
+cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
+DEVICE="eth0"
+BOOTPROTO="dhcp"
+ONBOOT="yes"
+NM_CONTROLLED="no"
+EOF
+
+
+# Do some cleanup..
+rm -f ~root/.bash_history
+rm -r "$(gem env gemdir)"/doc/*
+yum clean all
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git



More information about the Pkg-ruby-extras-commits mailing list