tripleo-incubator/scripts/install-dependencies
2013-06-17 20:42:36 +12:00

77 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
set -eu
BASE=$(dirname $0)/..
# make the local id_rsa.pub be in .ssh/authorized_keys before that is copied
# into images via local-config
if ! grep "$(cat ~/.ssh/id_rsa.pub)" ~/.ssh/authorized_keys >/dev/null; then
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
fi
# packages
os=unsupported
if [ -f /etc/redhat-release ]; then
if `grep -Eqs 'Red Hat Enterprise Linux Server release 6|CentOS release 6' /etc/redhat-release`; then
if [ -f /etc/yum.repos.d/epel.repo ]; then
echo EPEL repository is required to install python-pip for RHEL/CentOS.
echo See http://fedoraproject.org/wiki/EPEL
exit 1
fi
fi
os=redhat
fi
if [ -f /etc/debian_version ]; then
os=debian
fi
if [ "$os" = "unsupported" ]; then
echo This script has not been tested outside of Fedora, RHEL, and Ubuntu variants.
echo Aborting.
fi
if [ "$os" = "debian" ]; then
# packages
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes python-lxml python-libvirt libvirt-bin qemu-utils qemu-system qemu-kvm git python-pip python-dev gcc python-virtualenv
sudo service libvirt-bin restart
fi
if [ "$os" = "redhat" ]; then
# For RHEL/CentOS, python-pip is in EPEL
sudo yum install -y python-lxml libvirt-python libvirt qemu-img qemu-kvm git python-pip openssl-devel python-devel gcc audit python-virtualenv
sudo service libvirtd restart
fi
$BASE/scripts/setup-clienttools
# libvirtd group
grep libvirtd /etc/group || sudo groupadd libvirtd
if ! id | grep libvirtd; then
echo "adding $USER to group libvirtd"
sudo usermod -a -G libvirtd $USER
if [ "$os" = "redhat" ]; then
libvirtd_file=/etc/libvirt/libvirtd.conf
if ! sudo grep "^unix_sock_group" $libvirtd_file > /dev/null; then
sudo sed -i 's/^#unix_sock_group.*/unix_sock_group = "libvirtd"/g' $libvirtd_file
sudo sed -i 's/^#auth_unix_rw.*/auth_unix_rw = "none"/g' $libvirtd_file
sudo sed -i 's/^#unix_sock_rw_perms.*/unix_sock_rw_perms = "0770"/g' $libvirtd_file
sudo service libvirtd restart
fi
fi
exec sudo su -l $USER $PWD/$0
fi
echo "Check to see that you are in the libvirtd group in your current shell before going on. You can check by running:"
echo
echo "id | grep libvirtd"
echo
echo "If you are not, it's because this script added you. You can pick up the group by logging out and back in, or run:"
echo
echo "sudo su -l $USER"