This replaces all of the [[ "$os_PACKAGE" = "deb" ]] tests, except when
those tests are before straight calls to dpkg.
Change-Id: I8a3ebf1b1bc5a55d736f9258d5ba1d24dabf04ea
| ... | ... |
@@ -341,6 +341,19 @@ function GetDistro() {
|
| 341 | 341 |
} |
| 342 | 342 |
|
| 343 | 343 |
|
| 344 |
+# Determine if current distribution is an Ubuntu-based distribution. |
|
| 345 |
+# It will also detect non-Ubuntu but Debian-based distros; this is not an issue |
|
| 346 |
+# since Debian and Ubuntu should be compatible. |
|
| 347 |
+# is_ubuntu |
|
| 348 |
+function is_ubuntu {
|
|
| 349 |
+ if [[ -z "$os_PACKAGE" ]]; then |
|
| 350 |
+ GetOSVersion |
|
| 351 |
+ fi |
|
| 352 |
+ |
|
| 353 |
+ [ "$os_PACKAGE" = "deb" ] |
|
| 354 |
+} |
|
| 355 |
+ |
|
| 356 |
+ |
|
| 344 | 357 |
# Determine if current distribution is a SUSE-based distribution |
| 345 | 358 |
# (openSUSE, SLE). |
| 346 | 359 |
# is_suse |
| ... | ... |
@@ -580,11 +593,7 @@ function disable_negated_services() {
|
| 580 | 580 |
# Distro-agnostic package installer |
| 581 | 581 |
# install_package package [package ...] |
| 582 | 582 |
function install_package() {
|
| 583 |
- if [[ -z "$os_PACKAGE" ]]; then |
|
| 584 |
- GetOSVersion |
|
| 585 |
- fi |
|
| 586 |
- |
|
| 587 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 583 |
+ if is_ubuntu; then |
|
| 588 | 584 |
[[ "$NO_UPDATE_REPOS" = "True" ]] || apt_get update |
| 589 | 585 |
NO_UPDATE_REPOS=True |
| 590 | 586 |
|
| ... | ... |
@@ -609,6 +618,7 @@ function is_package_installed() {
|
| 609 | 609 |
if [[ -z "$os_PACKAGE" ]]; then |
| 610 | 610 |
GetOSVersion |
| 611 | 611 |
fi |
| 612 |
+ |
|
| 612 | 613 |
if [[ "$os_PACKAGE" = "deb" ]]; then |
| 613 | 614 |
dpkg -l "$@" > /dev/null |
| 614 | 615 |
return $? |
| ... | ... |
@@ -661,10 +671,7 @@ function pip_install {
|
| 661 | 661 |
# Service wrapper to restart services |
| 662 | 662 |
# restart_service service-name |
| 663 | 663 |
function restart_service() {
|
| 664 |
- if [[ -z "$os_PACKAGE" ]]; then |
|
| 665 |
- GetOSVersion |
|
| 666 |
- fi |
|
| 667 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 664 |
+ if is_ubuntu; then |
|
| 668 | 665 |
sudo /usr/sbin/service $1 restart |
| 669 | 666 |
else |
| 670 | 667 |
sudo /sbin/service $1 restart |
| ... | ... |
@@ -746,10 +753,7 @@ function setup_develop() {
|
| 746 | 746 |
# Service wrapper to start services |
| 747 | 747 |
# start_service service-name |
| 748 | 748 |
function start_service() {
|
| 749 |
- if [[ -z "$os_PACKAGE" ]]; then |
|
| 750 |
- GetOSVersion |
|
| 751 |
- fi |
|
| 752 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 749 |
+ if is_ubuntu; then |
|
| 753 | 750 |
sudo /usr/sbin/service $1 start |
| 754 | 751 |
else |
| 755 | 752 |
sudo /sbin/service $1 start |
| ... | ... |
@@ -760,10 +764,7 @@ function start_service() {
|
| 760 | 760 |
# Service wrapper to stop services |
| 761 | 761 |
# stop_service service-name |
| 762 | 762 |
function stop_service() {
|
| 763 |
- if [[ -z "$os_PACKAGE" ]]; then |
|
| 764 |
- GetOSVersion |
|
| 765 |
- fi |
|
| 766 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 763 |
+ if is_ubuntu; then |
|
| 767 | 764 |
sudo /usr/sbin/service $1 stop |
| 768 | 765 |
else |
| 769 | 766 |
sudo /sbin/service $1 stop |
| ... | ... |
@@ -1031,11 +1032,7 @@ function add_user_to_group() {
|
| 1031 | 1031 |
function get_rootwrap_location() {
|
| 1032 | 1032 |
local module=$1 |
| 1033 | 1033 |
|
| 1034 |
- if [[ -z "$os_PACKAGE" ]]; then |
|
| 1035 |
- GetOSVersion |
|
| 1036 |
- fi |
|
| 1037 |
- |
|
| 1038 |
- if [[ "$os_PACKAGE" = "deb" ]] || is_suse; then |
|
| 1034 |
+ if is_ubuntu || is_suse; then |
|
| 1039 | 1035 |
echo "/usr/local/bin/$module-rootwrap" |
| 1040 | 1036 |
else |
| 1041 | 1037 |
echo "/usr/bin/$module-rootwrap" |
| ... | ... |
@@ -1045,11 +1042,7 @@ function get_rootwrap_location() {
|
| 1045 | 1045 |
# Get the path to the pip command. |
| 1046 | 1046 |
# get_pip_command |
| 1047 | 1047 |
function get_pip_command() {
|
| 1048 |
- if [[ -z "$os_PACKAGE" ]]; then |
|
| 1049 |
- GetOSVersion |
|
| 1050 |
- fi |
|
| 1051 |
- |
|
| 1052 |
- if [[ "$os_PACKAGE" = "deb" ]] || is_suse; then |
|
| 1048 |
+ if is_ubuntu || is_suse; then |
|
| 1053 | 1049 |
echo "/usr/bin/pip" |
| 1054 | 1050 |
else |
| 1055 | 1051 |
echo "/usr/bin/pip-python" |
| ... | ... |
@@ -237,7 +237,7 @@ function _configure_tgt_for_config_d() {
|
| 237 | 237 |
# start_cinder() - Start running processes, including screen |
| 238 | 238 |
function start_cinder() {
|
| 239 | 239 |
if is_service_enabled c-vol; then |
| 240 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 240 |
+ if is_ubuntu; then |
|
| 241 | 241 |
_configure_tgt_for_config_d |
| 242 | 242 |
if [[ ! -f /etc/tgt/conf.d/cinder.conf ]]; then |
| 243 | 243 |
echo "include $CINDER_STATE_PATH/volumes/*" | sudo tee /etc/tgt/conf.d/cinder.conf |
| ... | ... |
@@ -20,7 +20,7 @@ function recreate_database_mysql {
|
| 20 | 20 |
function configure_database_mysql {
|
| 21 | 21 |
echo_summary "Configuring and starting MySQL" |
| 22 | 22 |
|
| 23 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 23 |
+ if is_ubuntu; then |
|
| 24 | 24 |
MY_CONF=/etc/mysql/my.cnf |
| 25 | 25 |
MYSQL=mysql |
| 26 | 26 |
else |
| ... | ... |
@@ -61,7 +61,7 @@ default-storage-engine = InnoDB" $MY_CONF |
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 | 63 |
function install_database_mysql {
|
| 64 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 64 |
+ if is_ubuntu; then |
|
| 65 | 65 |
# Seed configuration with mysql password so that apt-get install doesn't |
| 66 | 66 |
# prompt us for a password upon install. |
| 67 | 67 |
cat <<MYSQL_PRESEED | sudo debconf-set-selections |
| ... | ... |
@@ -71,7 +71,7 @@ function init_horizon() {
|
| 71 | 71 |
sudo mkdir -p $HORIZON_DIR/.blackhole |
| 72 | 72 |
|
| 73 | 73 |
|
| 74 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 74 |
+ if is_ubuntu; then |
|
| 75 | 75 |
APACHE_NAME=apache2 |
| 76 | 76 |
APACHE_CONF=sites-available/horizon |
| 77 | 77 |
# Clean up the old config name |
| ... | ... |
@@ -110,7 +110,7 @@ function init_horizon() {
|
| 110 | 110 |
# install_horizon() - Collect source and prepare |
| 111 | 111 |
function install_horizon() {
|
| 112 | 112 |
# Apache installation, because we mark it NOPRIME |
| 113 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 113 |
+ if is_ubuntu; then |
|
| 114 | 114 |
# Install apache2, which is NOPRIME'd |
| 115 | 115 |
install_package apache2 libapache2-mod-wsgi |
| 116 | 116 |
elif is_suse; then |
| ... | ... |
@@ -121,7 +121,7 @@ function install_horizon() {
|
| 121 | 121 |
fi |
| 122 | 122 |
|
| 123 | 123 |
# NOTE(sdague) quantal changed the name of the node binary |
| 124 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 124 |
+ if is_ubuntu; then |
|
| 125 | 125 |
if [[ ! -e "/usr/bin/node" ]]; then |
| 126 | 126 |
install_package nodejs-legacy |
| 127 | 127 |
fi |
| ... | ... |
@@ -202,7 +202,7 @@ function configure_nova() {
|
| 202 | 202 |
# splitting a system into many smaller parts. LXC uses cgroups and chroot |
| 203 | 203 |
# to simulate multiple systems. |
| 204 | 204 |
if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then |
| 205 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 205 |
+ if is_ubuntu; then |
|
| 206 | 206 |
if [[ ! "$DISTRO" > natty ]]; then |
| 207 | 207 |
cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0" |
| 208 | 208 |
sudo mkdir -p /cgroup |
| ... | ... |
@@ -228,7 +228,7 @@ cgroup_device_acl = [ |
| 228 | 228 |
EOF |
| 229 | 229 |
fi |
| 230 | 230 |
|
| 231 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 231 |
+ if is_ubuntu; then |
|
| 232 | 232 |
LIBVIRT_DAEMON=libvirt-bin |
| 233 | 233 |
else |
| 234 | 234 |
# http://wiki.libvirt.org/page/SSHPolicyKitSetup |
| ... | ... |
@@ -393,7 +393,7 @@ function install_novaclient() {
|
| 393 | 393 |
# install_nova() - Collect source and prepare |
| 394 | 394 |
function install_nova() {
|
| 395 | 395 |
if is_service_enabled n-cpu; then |
| 396 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 396 |
+ if is_ubuntu; then |
|
| 397 | 397 |
LIBVIRT_PKG_NAME=libvirt-bin |
| 398 | 398 |
else |
| 399 | 399 |
LIBVIRT_PKG_NAME=libvirt |
| ... | ... |
@@ -403,7 +403,7 @@ function install_nova() {
|
| 403 | 403 |
# splitting a system into many smaller parts. LXC uses cgroups and chroot |
| 404 | 404 |
# to simulate multiple systems. |
| 405 | 405 |
if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then |
| 406 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 406 |
+ if is_ubuntu; then |
|
| 407 | 407 |
if [[ "$DISTRO" > natty ]]; then |
| 408 | 408 |
install_package cgroup-lite |
| 409 | 409 |
fi |
| ... | ... |
@@ -159,7 +159,7 @@ function configure_swift() {
|
| 159 | 159 |
s,%SWIFT_DATA_DIR%,$SWIFT_DATA_DIR,; |
| 160 | 160 |
" $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf |
| 161 | 161 |
# rsyncd.conf just prepared for 4 nodes |
| 162 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 162 |
+ if is_ubuntu; then |
|
| 163 | 163 |
sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync
|
| 164 | 164 |
else |
| 165 | 165 |
sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync
|
| ... | ... |
@@ -341,7 +341,7 @@ function start_swift() {
|
| 341 | 341 |
# (re)start rsyslog |
| 342 | 342 |
restart_service rsyslog |
| 343 | 343 |
# Start rsync |
| 344 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 344 |
+ if is_ubuntu; then |
|
| 345 | 345 |
sudo /etc/init.d/rsync restart || : |
| 346 | 346 |
else |
| 347 | 347 |
sudo systemctl start xinetd.service |
| ... | ... |
@@ -677,7 +677,7 @@ set -o xtrace |
| 677 | 677 |
|
| 678 | 678 |
# Install package requirements |
| 679 | 679 |
echo_summary "Installing package prerequisites" |
| 680 |
-if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 680 |
+if is_ubuntu; then |
|
| 681 | 681 |
install_package $(get_packages $FILES/apts) |
| 682 | 682 |
elif is_suse; then |
| 683 | 683 |
install_package $(get_packages $FILES/rpms-suse) |
| ... | ... |
@@ -726,7 +726,7 @@ if is_service_enabled q-agt; then |
| 726 | 726 |
if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then |
| 727 | 727 |
# Install deps |
| 728 | 728 |
# FIXME add to ``files/apts/quantum``, but don't install if not needed! |
| 729 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 729 |
+ if is_ubuntu; then |
|
| 730 | 730 |
kernel_version=`cat /proc/version | cut -d " " -f3` |
| 731 | 731 |
install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version |
| 732 | 732 |
else |
| ... | ... |
@@ -88,7 +88,7 @@ done |
| 88 | 88 |
# - We are going to check packages only for the services needed. |
| 89 | 89 |
# - We are parsing the packages files and detecting metadatas. |
| 90 | 90 |
|
| 91 |
-if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 91 |
+if is_ubuntu; then |
|
| 92 | 92 |
PKG_DIR=$FILES/apts |
| 93 | 93 |
else |
| 94 | 94 |
PKG_DIR=$FILES/rpms |
| ... | ... |
@@ -65,7 +65,7 @@ if is_service_enabled cinder; then |
| 65 | 65 |
# If tgt driver isn't running this won't work obviously |
| 66 | 66 |
# So check the response and restart if need be |
| 67 | 67 |
echo "tgtd seems to be in a bad state, restarting..." |
| 68 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 68 |
+ if is_ubuntu; then |
|
| 69 | 69 |
restart_service tgt |
| 70 | 70 |
else |
| 71 | 71 |
restart_service tgtd |
| ... | ... |
@@ -85,7 +85,7 @@ if is_service_enabled cinder; then |
| 85 | 85 |
sudo rm -rf $CINDER_STATE_PATH/volumes/* |
| 86 | 86 |
fi |
| 87 | 87 |
|
| 88 |
- if [[ "$os_PACKAGE" = "deb" ]]; then |
|
| 88 |
+ if is_ubuntu; then |
|
| 89 | 89 |
stop_service tgt |
| 90 | 90 |
else |
| 91 | 91 |
stop_service tgtd |