Merge "Add is_ubuntu function"

This commit is contained in:
Jenkins 2012-12-05 19:47:03 +00:00 committed by Gerrit Code Review
commit fe89e72659
9 changed files with 37 additions and 44 deletions

View File

@ -341,6 +341,19 @@ function GetDistro() {
}
# Determine if current distribution is an Ubuntu-based distribution.
# It will also detect non-Ubuntu but Debian-based distros; this is not an issue
# since Debian and Ubuntu should be compatible.
# is_ubuntu
function is_ubuntu {
if [[ -z "$os_PACKAGE" ]]; then
GetOSVersion
fi
[ "$os_PACKAGE" = "deb" ]
}
# Determine if current distribution is a SUSE-based distribution
# (openSUSE, SLE).
# is_suse
@ -580,11 +593,7 @@ function disable_negated_services() {
# Distro-agnostic package installer
# install_package package [package ...]
function install_package() {
if [[ -z "$os_PACKAGE" ]]; then
GetOSVersion
fi
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
[[ "$NO_UPDATE_REPOS" = "True" ]] || apt_get update
NO_UPDATE_REPOS=True
@ -609,6 +618,7 @@ function is_package_installed() {
if [[ -z "$os_PACKAGE" ]]; then
GetOSVersion
fi
if [[ "$os_PACKAGE" = "deb" ]]; then
dpkg -l "$@" > /dev/null
return $?
@ -661,10 +671,7 @@ function pip_install {
# Service wrapper to restart services
# restart_service service-name
function restart_service() {
if [[ -z "$os_PACKAGE" ]]; then
GetOSVersion
fi
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
sudo /usr/sbin/service $1 restart
else
sudo /sbin/service $1 restart
@ -746,10 +753,7 @@ function setup_develop() {
# Service wrapper to start services
# start_service service-name
function start_service() {
if [[ -z "$os_PACKAGE" ]]; then
GetOSVersion
fi
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
sudo /usr/sbin/service $1 start
else
sudo /sbin/service $1 start
@ -760,10 +764,7 @@ function start_service() {
# Service wrapper to stop services
# stop_service service-name
function stop_service() {
if [[ -z "$os_PACKAGE" ]]; then
GetOSVersion
fi
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
sudo /usr/sbin/service $1 stop
else
sudo /sbin/service $1 stop
@ -1031,11 +1032,7 @@ function add_user_to_group() {
function get_rootwrap_location() {
local module=$1
if [[ -z "$os_PACKAGE" ]]; then
GetOSVersion
fi
if [[ "$os_PACKAGE" = "deb" ]] || is_suse; then
if is_ubuntu || is_suse; then
echo "/usr/local/bin/$module-rootwrap"
else
echo "/usr/bin/$module-rootwrap"
@ -1045,11 +1042,7 @@ function get_rootwrap_location() {
# Get the path to the pip command.
# get_pip_command
function get_pip_command() {
if [[ -z "$os_PACKAGE" ]]; then
GetOSVersion
fi
if [[ "$os_PACKAGE" = "deb" ]] || is_suse; then
if is_ubuntu || is_suse; then
echo "/usr/bin/pip"
else
echo "/usr/bin/pip-python"

View File

@ -237,7 +237,7 @@ function _configure_tgt_for_config_d() {
# start_cinder() - Start running processes, including screen
function start_cinder() {
if is_service_enabled c-vol; then
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
_configure_tgt_for_config_d
if [[ ! -f /etc/tgt/conf.d/cinder.conf ]]; then
echo "include $CINDER_STATE_PATH/volumes/*" | sudo tee /etc/tgt/conf.d/cinder.conf

View File

@ -20,7 +20,7 @@ function recreate_database_mysql {
function configure_database_mysql {
echo_summary "Configuring and starting MySQL"
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
MY_CONF=/etc/mysql/my.cnf
MYSQL=mysql
else
@ -61,7 +61,7 @@ default-storage-engine = InnoDB" $MY_CONF
}
function install_database_mysql {
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
# Seed configuration with mysql password so that apt-get install doesn't
# prompt us for a password upon install.
cat <<MYSQL_PRESEED | sudo debconf-set-selections

View File

@ -71,7 +71,7 @@ function init_horizon() {
sudo mkdir -p $HORIZON_DIR/.blackhole
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
APACHE_NAME=apache2
APACHE_CONF=sites-available/horizon
# Clean up the old config name
@ -110,7 +110,7 @@ function init_horizon() {
# install_horizon() - Collect source and prepare
function install_horizon() {
# Apache installation, because we mark it NOPRIME
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
# Install apache2, which is NOPRIME'd
install_package apache2 libapache2-mod-wsgi
elif is_suse; then
@ -121,7 +121,7 @@ function install_horizon() {
fi
# NOTE(sdague) quantal changed the name of the node binary
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
if [[ ! -e "/usr/bin/node" ]]; then
install_package nodejs-legacy
fi

View File

@ -202,7 +202,7 @@ function configure_nova() {
# splitting a system into many smaller parts. LXC uses cgroups and chroot
# to simulate multiple systems.
if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
if [[ ! "$DISTRO" > natty ]]; then
cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0"
sudo mkdir -p /cgroup
@ -228,7 +228,7 @@ cgroup_device_acl = [
EOF
fi
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
LIBVIRT_DAEMON=libvirt-bin
else
# http://wiki.libvirt.org/page/SSHPolicyKitSetup
@ -393,7 +393,7 @@ function install_novaclient() {
# install_nova() - Collect source and prepare
function install_nova() {
if is_service_enabled n-cpu; then
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
LIBVIRT_PKG_NAME=libvirt-bin
else
LIBVIRT_PKG_NAME=libvirt
@ -403,7 +403,7 @@ function install_nova() {
# splitting a system into many smaller parts. LXC uses cgroups and chroot
# to simulate multiple systems.
if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
if [[ "$DISTRO" > natty ]]; then
install_package cgroup-lite
fi

View File

@ -159,7 +159,7 @@ function configure_swift() {
s,%SWIFT_DATA_DIR%,$SWIFT_DATA_DIR,;
" $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf
# rsyncd.conf just prepared for 4 nodes
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync
else
sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync
@ -341,7 +341,7 @@ function start_swift() {
# (re)start rsyslog
restart_service rsyslog
# Start rsync
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
sudo /etc/init.d/rsync restart || :
else
sudo systemctl start xinetd.service

View File

@ -677,7 +677,7 @@ set -o xtrace
# Install package requirements
echo_summary "Installing package prerequisites"
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
install_package $(get_packages $FILES/apts)
elif is_suse; then
install_package $(get_packages $FILES/rpms-suse)
@ -726,7 +726,7 @@ if is_service_enabled q-agt; then
if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then
# Install deps
# FIXME add to ``files/apts/quantum``, but don't install if not needed!
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
kernel_version=`cat /proc/version | cut -d " " -f3`
install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
else

View File

@ -88,7 +88,7 @@ done
# - We are going to check packages only for the services needed.
# - We are parsing the packages files and detecting metadatas.
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
PKG_DIR=$FILES/apts
else
PKG_DIR=$FILES/rpms

View File

@ -65,7 +65,7 @@ if is_service_enabled cinder; then
# If tgt driver isn't running this won't work obviously
# So check the response and restart if need be
echo "tgtd seems to be in a bad state, restarting..."
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
restart_service tgt
else
restart_service tgtd
@ -85,7 +85,7 @@ if is_service_enabled cinder; then
sudo rm -rf $CINDER_STATE_PATH/volumes/*
fi
if [[ "$os_PACKAGE" = "deb" ]]; then
if is_ubuntu; then
stop_service tgt
else
stop_service tgtd