Add is_fedora and exit_distro_not_supported functions
Between is_fedora, is_ubuntu and is_suse, we can make the code a bit simpler to read. We also use exit_distro_not_supported to identify places where we need implementation details for new distros. As "/sbin/service --skip-redirect" is Fedora-specific, guard this with a is_fedora test too. Change-Id: Ic77c0697ed9be0dbb5df8e73da93463e76025f0c
This commit is contained in:
parent
e5f8d1228a
commit
00011c0847
55
functions
55
functions
@ -354,6 +354,18 @@ function is_ubuntu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Determine if current distribution is a Fedora-based distribution
|
||||||
|
# (Fedora, RHEL, CentOS).
|
||||||
|
# is_fedora
|
||||||
|
function is_fedora {
|
||||||
|
if [[ -z "$os_VENDOR" ]]; then
|
||||||
|
GetOSVersion
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$os_VENDOR" = "Fedora" ] || [ "$os_VENDOR" = "Red Hat" ] || [ "$os_VENDOR" = "CentOS" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Determine if current distribution is a SUSE-based distribution
|
# Determine if current distribution is a SUSE-based distribution
|
||||||
# (openSUSE, SLE).
|
# (openSUSE, SLE).
|
||||||
# is_suse
|
# is_suse
|
||||||
@ -366,6 +378,23 @@ function is_suse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Exit after outputting a message about the distribution not being supported.
|
||||||
|
# exit_distro_not_supported [optional-string-telling-what-is-missing]
|
||||||
|
function exit_distro_not_supported {
|
||||||
|
if [[ -z "$DISTRO" ]]; then
|
||||||
|
GetDistro
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
echo "Support for $DISTRO is incomplete: no support for $@"
|
||||||
|
else
|
||||||
|
echo "Support for $DISTRO is incomplete."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# git clone only if directory doesn't exist already. Since ``DEST`` might not
|
# git clone only if directory doesn't exist already. Since ``DEST`` might not
|
||||||
# be owned by the installation user, we create the directory and change the
|
# be owned by the installation user, we create the directory and change the
|
||||||
# ownership to the proper user.
|
# ownership to the proper user.
|
||||||
@ -598,12 +627,12 @@ function install_package() {
|
|||||||
NO_UPDATE_REPOS=True
|
NO_UPDATE_REPOS=True
|
||||||
|
|
||||||
apt_get install "$@"
|
apt_get install "$@"
|
||||||
|
elif is_fedora; then
|
||||||
|
yum_install "$@"
|
||||||
|
elif is_suse; then
|
||||||
|
zypper_install "$@"
|
||||||
else
|
else
|
||||||
if is_suse; then
|
exit_distro_not_supported "installing packages"
|
||||||
zypper_install "$@"
|
|
||||||
else
|
|
||||||
yum_install "$@"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,9 +651,11 @@ function is_package_installed() {
|
|||||||
if [[ "$os_PACKAGE" = "deb" ]]; then
|
if [[ "$os_PACKAGE" = "deb" ]]; then
|
||||||
dpkg -l "$@" > /dev/null
|
dpkg -l "$@" > /dev/null
|
||||||
return $?
|
return $?
|
||||||
else
|
elif [[ "$os_PACKAGE" = "rpm" ]]; then
|
||||||
rpm --quiet -q "$@"
|
rpm --quiet -q "$@"
|
||||||
return $?
|
return $?
|
||||||
|
else
|
||||||
|
exit_distro_not_supported "finding if a package is installed"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1032,20 +1063,20 @@ function add_user_to_group() {
|
|||||||
function get_rootwrap_location() {
|
function get_rootwrap_location() {
|
||||||
local module=$1
|
local module=$1
|
||||||
|
|
||||||
if is_ubuntu || is_suse; then
|
if is_fedora; then
|
||||||
echo "/usr/local/bin/$module-rootwrap"
|
|
||||||
else
|
|
||||||
echo "/usr/bin/$module-rootwrap"
|
echo "/usr/bin/$module-rootwrap"
|
||||||
|
else
|
||||||
|
echo "/usr/local/bin/$module-rootwrap"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the path to the pip command.
|
# Get the path to the pip command.
|
||||||
# get_pip_command
|
# get_pip_command
|
||||||
function get_pip_command() {
|
function get_pip_command() {
|
||||||
if is_ubuntu || is_suse; then
|
if is_fedora; then
|
||||||
echo "/usr/bin/pip"
|
|
||||||
else
|
|
||||||
echo "/usr/bin/pip-python"
|
echo "/usr/bin/pip-python"
|
||||||
|
else
|
||||||
|
echo "/usr/bin/pip"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
lib/cinder
12
lib/cinder
@ -195,8 +195,8 @@ function init_cinder() {
|
|||||||
mkdir -p $CINDER_STATE_PATH/volumes
|
mkdir -p $CINDER_STATE_PATH/volumes
|
||||||
|
|
||||||
if sudo vgs $VOLUME_GROUP; then
|
if sudo vgs $VOLUME_GROUP; then
|
||||||
if [[ "$os_PACKAGE" = "rpm" ]]; then
|
if is_fedora || is_suse; then
|
||||||
# RPM doesn't start the service
|
# service is not started by default
|
||||||
start_service tgtd
|
start_service tgtd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -245,9 +245,15 @@ function start_cinder() {
|
|||||||
# do it in two steps
|
# do it in two steps
|
||||||
sudo stop tgt || true
|
sudo stop tgt || true
|
||||||
sudo start tgt
|
sudo start tgt
|
||||||
else
|
elif is_fedora; then
|
||||||
# bypass redirection to systemctl during restart
|
# bypass redirection to systemctl during restart
|
||||||
sudo /sbin/service --skip-redirect tgtd restart
|
sudo /sbin/service --skip-redirect tgtd restart
|
||||||
|
elif is_suse; then
|
||||||
|
restart_service tgtd
|
||||||
|
else
|
||||||
|
# note for other distros: unstack.sh also uses the tgt/tgtd service
|
||||||
|
# name, and would need to be adjusted too
|
||||||
|
exit_distro_not_supported "restarting tgt"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -23,22 +23,28 @@ function configure_database_mysql {
|
|||||||
if is_ubuntu; then
|
if is_ubuntu; then
|
||||||
MY_CONF=/etc/mysql/my.cnf
|
MY_CONF=/etc/mysql/my.cnf
|
||||||
MYSQL=mysql
|
MYSQL=mysql
|
||||||
else
|
elif is_fedora; then
|
||||||
MY_CONF=/etc/my.cnf
|
MY_CONF=/etc/my.cnf
|
||||||
if is_suse; then
|
MYSQL=mysqld
|
||||||
MYSQL=mysql
|
elif is_suse; then
|
||||||
else
|
MY_CONF=/etc/my.cnf
|
||||||
MYSQL=mysqld
|
MYSQL=mysql
|
||||||
fi
|
else
|
||||||
|
exit_distro_not_supported "mysql configuration"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start mysql-server
|
# Start mysql-server
|
||||||
if [[ "$os_PACKAGE" = "rpm" ]]; then
|
if is_fedora || is_suse; then
|
||||||
# RPM doesn't start the service
|
# service is not started by default
|
||||||
start_service $MYSQL
|
start_service $MYSQL
|
||||||
# Set the root password - only works the first time
|
fi
|
||||||
|
|
||||||
|
# Set the root password - only works the first time. For Ubuntu, we already
|
||||||
|
# did that with debconf before installing the package.
|
||||||
|
if ! is_ubuntu; then
|
||||||
sudo mysqladmin -u root password $DATABASE_PASSWORD || true
|
sudo mysqladmin -u root password $DATABASE_PASSWORD || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update the DB to give user ‘$DATABASE_USER’@’%’ full control of the all databases:
|
# Update the DB to give user ‘$DATABASE_USER’@’%’ full control of the all databases:
|
||||||
sudo mysql -uroot -p$DATABASE_PASSWORD -h127.0.0.1 -e "GRANT ALL PRIVILEGES ON *.* TO '$DATABASE_USER'@'%' identified by '$DATABASE_PASSWORD';"
|
sudo mysql -uroot -p$DATABASE_PASSWORD -h127.0.0.1 -e "GRANT ALL PRIVILEGES ON *.* TO '$DATABASE_USER'@'%' identified by '$DATABASE_PASSWORD';"
|
||||||
|
|
||||||
@ -84,10 +90,12 @@ EOF
|
|||||||
chmod 0600 $HOME/.my.cnf
|
chmod 0600 $HOME/.my.cnf
|
||||||
fi
|
fi
|
||||||
# Install mysql-server
|
# Install mysql-server
|
||||||
if is_suse; then
|
if is_ubuntu || is_fedora; then
|
||||||
|
install_package mysql-server
|
||||||
|
elif is_suse; then
|
||||||
install_package mysql-community-server
|
install_package mysql-community-server
|
||||||
else
|
else
|
||||||
install_package mysql-server
|
exit_distro_not_supported "mysql installation"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ function recreate_database_postgresql {
|
|||||||
|
|
||||||
function configure_database_postgresql {
|
function configure_database_postgresql {
|
||||||
echo_summary "Configuring and starting PostgreSQL"
|
echo_summary "Configuring and starting PostgreSQL"
|
||||||
if [[ "$os_PACKAGE" = "rpm" ]]; then
|
if is_fedora || is_suse; then
|
||||||
PG_HBA=/var/lib/pgsql/data/pg_hba.conf
|
PG_HBA=/var/lib/pgsql/data/pg_hba.conf
|
||||||
PG_CONF=/var/lib/pgsql/data/postgresql.conf
|
PG_CONF=/var/lib/pgsql/data/postgresql.conf
|
||||||
sudo [ -e $PG_HBA ] || sudo postgresql-setup initdb
|
sudo [ -e $PG_HBA ] || sudo postgresql-setup initdb
|
||||||
@ -53,10 +53,12 @@ EOF
|
|||||||
else
|
else
|
||||||
sed -i "s/:root:\w\+/:root:$DATABASE_PASSWORD/" $PGPASS
|
sed -i "s/:root:\w\+/:root:$DATABASE_PASSWORD/" $PGPASS
|
||||||
fi
|
fi
|
||||||
if [[ "$os_PACKAGE" = "rpm" ]]; then
|
if is_ubuntu; then
|
||||||
|
install_package postgresql
|
||||||
|
elif is_fedora || is_suse; then
|
||||||
install_package postgresql-server
|
install_package postgresql-server
|
||||||
else
|
else
|
||||||
install_package postgresql
|
exit_distro_not_supported "postgresql installation"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
lib/horizon
29
lib/horizon
@ -81,19 +81,18 @@ function init_horizon() {
|
|||||||
sudo a2ensite horizon
|
sudo a2ensite horizon
|
||||||
# WSGI doesn't enable by default, enable it
|
# WSGI doesn't enable by default, enable it
|
||||||
sudo a2enmod wsgi
|
sudo a2enmod wsgi
|
||||||
|
elif is_fedora; then
|
||||||
|
APACHE_NAME=httpd
|
||||||
|
APACHE_CONF=conf.d/horizon.conf
|
||||||
|
sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
|
||||||
|
elif is_suse; then
|
||||||
|
APACHE_NAME=apache2
|
||||||
|
APACHE_CONF=vhosts.d/horizon.conf
|
||||||
|
# Append wsgi to the list of modules to load
|
||||||
|
grep -q "^APACHE_MODULES=.*wsgi" /etc/sysconfig/apache2 ||
|
||||||
|
sudo sed '/^APACHE_MODULES=/s/^\(.*\)"$/\1 wsgi"/' -i /etc/sysconfig/apache2
|
||||||
else
|
else
|
||||||
# Install httpd, which is NOPRIME'd
|
exit_distro_not_supported "apache configuration"
|
||||||
if is_suse; then
|
|
||||||
APACHE_NAME=apache2
|
|
||||||
APACHE_CONF=vhosts.d/horizon.conf
|
|
||||||
# Append wsgi to the list of modules to load
|
|
||||||
grep -q "^APACHE_MODULES=.*wsgi" /etc/sysconfig/apache2 ||
|
|
||||||
sudo sed '/^APACHE_MODULES=/s/^\(.*\)"$/\1 wsgi"/' -i /etc/sysconfig/apache2
|
|
||||||
else
|
|
||||||
APACHE_NAME=httpd
|
|
||||||
APACHE_CONF=conf.d/horizon.conf
|
|
||||||
sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Configure apache to run horizon
|
# Configure apache to run horizon
|
||||||
@ -113,11 +112,13 @@ function install_horizon() {
|
|||||||
if is_ubuntu; then
|
if is_ubuntu; then
|
||||||
# Install apache2, which is NOPRIME'd
|
# Install apache2, which is NOPRIME'd
|
||||||
install_package apache2 libapache2-mod-wsgi
|
install_package apache2 libapache2-mod-wsgi
|
||||||
|
elif is_fedora; then
|
||||||
|
sudo rm -f /etc/httpd/conf.d/000-*
|
||||||
|
install_package httpd mod_wsgi
|
||||||
elif is_suse; then
|
elif is_suse; then
|
||||||
install_package apache2 apache2-mod_wsgi
|
install_package apache2 apache2-mod_wsgi
|
||||||
else
|
else
|
||||||
sudo rm -f /etc/httpd/conf.d/000-*
|
exit_distro_not_supported "apache installation"
|
||||||
install_package httpd mod_wsgi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# NOTE(sdague) quantal changed the name of the node binary
|
# NOTE(sdague) quantal changed the name of the node binary
|
||||||
|
8
lib/nova
8
lib/nova
@ -394,11 +394,13 @@ function install_novaclient() {
|
|||||||
function install_nova() {
|
function install_nova() {
|
||||||
if is_service_enabled n-cpu; then
|
if is_service_enabled n-cpu; then
|
||||||
if is_ubuntu; then
|
if is_ubuntu; then
|
||||||
LIBVIRT_PKG_NAME=libvirt-bin
|
install_package libvirt-bin
|
||||||
|
elif is_fedora || is_suse; then
|
||||||
|
install_package libvirt
|
||||||
else
|
else
|
||||||
LIBVIRT_PKG_NAME=libvirt
|
exit_distro_not_supported "libvirt installation"
|
||||||
fi
|
fi
|
||||||
install_package $LIBVIRT_PKG_NAME
|
|
||||||
# Install and configure **LXC** if specified. LXC is another approach to
|
# Install and configure **LXC** if specified. LXC is another approach to
|
||||||
# splitting a system into many smaller parts. LXC uses cgroups and chroot
|
# splitting a system into many smaller parts. LXC uses cgroups and chroot
|
||||||
# to simulate multiple systems.
|
# to simulate multiple systems.
|
||||||
|
34
stack.sh
34
stack.sh
@ -678,17 +678,21 @@ set -o xtrace
|
|||||||
echo_summary "Installing package prerequisites"
|
echo_summary "Installing package prerequisites"
|
||||||
if is_ubuntu; then
|
if is_ubuntu; then
|
||||||
install_package $(get_packages $FILES/apts)
|
install_package $(get_packages $FILES/apts)
|
||||||
|
elif is_fedora; then
|
||||||
|
install_package $(get_packages $FILES/rpms)
|
||||||
elif is_suse; then
|
elif is_suse; then
|
||||||
install_package $(get_packages $FILES/rpms-suse)
|
install_package $(get_packages $FILES/rpms-suse)
|
||||||
else
|
else
|
||||||
install_package $(get_packages $FILES/rpms)
|
exit_distro_not_supported "list of packages"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $SYSLOG != "False" ]]; then
|
if [[ $SYSLOG != "False" ]]; then
|
||||||
if is_suse; then
|
if is_ubuntu || is_fedora; then
|
||||||
|
install_package rsyslog-relp
|
||||||
|
elif is_suse; then
|
||||||
install_package rsyslog-module-relp
|
install_package rsyslog-module-relp
|
||||||
else
|
else
|
||||||
install_package rsyslog-relp
|
exit_distro_not_supported "rsyslog-relp installation"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -700,20 +704,22 @@ if is_service_enabled rabbit; then
|
|||||||
cat "$tfile"
|
cat "$tfile"
|
||||||
rm -f "$tfile"
|
rm -f "$tfile"
|
||||||
elif is_service_enabled qpid; then
|
elif is_service_enabled qpid; then
|
||||||
if [[ "$os_PACKAGE" = "rpm" ]]; then
|
if is_fedora; then
|
||||||
install_package qpid-cpp-server-daemon
|
install_package qpid-cpp-server-daemon
|
||||||
else
|
elif is_ubuntu; then
|
||||||
install_package qpidd
|
install_package qpidd
|
||||||
|
else
|
||||||
|
exit_distro_not_supported "qpid installation"
|
||||||
fi
|
fi
|
||||||
elif is_service_enabled zeromq; then
|
elif is_service_enabled zeromq; then
|
||||||
if [[ "$os_PACKAGE" = "rpm" ]]; then
|
if is_fedora; then
|
||||||
if is_suse; then
|
install_package zeromq python-zmq
|
||||||
install_package libzmq1 python-pyzmq
|
elif is_ubuntu; then
|
||||||
else
|
|
||||||
install_package zeromq python-zmq
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
install_package libzmq1 python-zmq
|
install_package libzmq1 python-zmq
|
||||||
|
elif is_suse; then
|
||||||
|
install_package libzmq1 python-pyzmq
|
||||||
|
else
|
||||||
|
exit_distro_not_supported "zeromq installation"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -909,8 +915,8 @@ fi
|
|||||||
if is_service_enabled rabbit; then
|
if is_service_enabled rabbit; then
|
||||||
# Start rabbitmq-server
|
# Start rabbitmq-server
|
||||||
echo_summary "Starting RabbitMQ"
|
echo_summary "Starting RabbitMQ"
|
||||||
if [[ "$os_PACKAGE" = "rpm" ]]; then
|
if is_fedora || is_suse; then
|
||||||
# RPM doesn't start the service
|
# service is not started by default
|
||||||
restart_service rabbitmq-server
|
restart_service rabbitmq-server
|
||||||
fi
|
fi
|
||||||
# change the rabbit password since the default is "guest"
|
# change the rabbit password since the default is "guest"
|
||||||
|
@ -260,9 +260,11 @@ fi
|
|||||||
if [[ "$os_PACKAGE" = "deb" ]]; then
|
if [[ "$os_PACKAGE" = "deb" ]]; then
|
||||||
is_package_installed dpkg
|
is_package_installed dpkg
|
||||||
VAL=$?
|
VAL=$?
|
||||||
else
|
elif [[ "$os_PACKAGE" = "rpm" ]]; then
|
||||||
is_package_installed rpm
|
is_package_installed rpm
|
||||||
VAL=$?
|
VAL=$?
|
||||||
|
else
|
||||||
|
VAL=1
|
||||||
fi
|
fi
|
||||||
if [[ "$VAL" -eq 0 ]]; then
|
if [[ "$VAL" -eq 0 ]]; then
|
||||||
echo "OK"
|
echo "OK"
|
||||||
@ -273,9 +275,11 @@ fi
|
|||||||
if [[ "$os_PACKAGE" = "deb" ]]; then
|
if [[ "$os_PACKAGE" = "deb" ]]; then
|
||||||
is_package_installed dpkg bash
|
is_package_installed dpkg bash
|
||||||
VAL=$?
|
VAL=$?
|
||||||
else
|
elif [[ "$os_PACKAGE" = "rpm" ]]; then
|
||||||
is_package_installed rpm bash
|
is_package_installed rpm bash
|
||||||
VAL=$?
|
VAL=$?
|
||||||
|
else
|
||||||
|
VAL=1
|
||||||
fi
|
fi
|
||||||
if [[ "$VAL" -eq 0 ]]; then
|
if [[ "$VAL" -eq 0 ]]; then
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
@ -90,15 +90,19 @@ done
|
|||||||
|
|
||||||
if is_ubuntu; then
|
if is_ubuntu; then
|
||||||
PKG_DIR=$FILES/apts
|
PKG_DIR=$FILES/apts
|
||||||
else
|
elif is_fedora; then
|
||||||
PKG_DIR=$FILES/rpms
|
PKG_DIR=$FILES/rpms
|
||||||
|
else
|
||||||
|
exit_distro_not_supported "list of packages"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for p in $(get_packages $PKG_DIR); do
|
for p in $(get_packages $PKG_DIR); do
|
||||||
if [[ "$os_PACKAGE" = "deb" ]]; then
|
if [[ "$os_PACKAGE" = "deb" ]]; then
|
||||||
ver=$(dpkg -s $p 2>/dev/null | grep '^Version: ' | cut -d' ' -f2)
|
ver=$(dpkg -s $p 2>/dev/null | grep '^Version: ' | cut -d' ' -f2)
|
||||||
else
|
elif [[ "$os_PACKAGE" = "rpm" ]]; then
|
||||||
ver=$(rpm -q --queryformat "%{VERSION}-%{RELEASE}\n" $p)
|
ver=$(rpm -q --queryformat "%{VERSION}-%{RELEASE}\n" $p)
|
||||||
|
else
|
||||||
|
exit_distro_not_supported "finding version of a package"
|
||||||
fi
|
fi
|
||||||
echo "pkg|${p}|${ver}"
|
echo "pkg|${p}|${ver}"
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user