Create tools/install_prereqs.sh
* Factor system package prereq installs out to tools/install_prereqs.sh * Set minimum time between runs with PREREQ_RERUN_HOURS default = 2 hours * Create export_proxy_variables * Force an update with install_prereqs.sh -f or by setting FORCE_PREREQ=true Fixed an issue with exit/return in tools/install_prereqs.sh Change-Id: I9a62090ad2f900b9b150cacb9cb02b326cb46972
This commit is contained in:
parent
f3da41a5ee
commit
48352ee7c0
21
functions
21
functions
@ -80,6 +80,27 @@ function die_if_not_set() {
|
||||
}
|
||||
|
||||
|
||||
# HTTP and HTTPS proxy servers are supported via the usual environment variables [1]
|
||||
# ``http_proxy``, ``https_proxy`` and ``no_proxy``. They can be set in
|
||||
# ``localrc`` or on the command line if necessary::
|
||||
#
|
||||
# [1] http://www.w3.org/Daemon/User/Proxies/ProxyClients.html
|
||||
#
|
||||
# http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh
|
||||
|
||||
function export_proxy_variables() {
|
||||
if [[ -n "$http_proxy" ]]; then
|
||||
export http_proxy=$http_proxy
|
||||
fi
|
||||
if [[ -n "$https_proxy" ]]; then
|
||||
export https_proxy=$https_proxy
|
||||
fi
|
||||
if [[ -n "$no_proxy" ]]; then
|
||||
export no_proxy=$no_proxy
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Grab a numbered field from python prettytable output
|
||||
# Fields are numbered starting with 1
|
||||
# Reverse syntax is supported: -1 is the last field, -2 is second to last, etc.
|
||||
|
49
stack.sh
49
stack.sh
@ -30,9 +30,8 @@ source $TOP_DIR/functions
|
||||
GetDistro
|
||||
|
||||
|
||||
|
||||
# Settings
|
||||
# ========
|
||||
# Global Settings
|
||||
# ===============
|
||||
|
||||
# ``stack.sh`` is customizable through setting environment variables. If you
|
||||
# want to override a setting you can set and export it::
|
||||
@ -62,33 +61,18 @@ fi
|
||||
source $TOP_DIR/stackrc
|
||||
|
||||
|
||||
# Proxy Settings
|
||||
# Local Settings
|
||||
# --------------
|
||||
|
||||
# HTTP and HTTPS proxy servers are supported via the usual environment variables [1]
|
||||
# ``http_proxy``, ``https_proxy`` and ``no_proxy``. They can be set in
|
||||
# ``localrc`` if necessary or on the command line::
|
||||
#
|
||||
# [1] http://www.w3.org/Daemon/User/Proxies/ProxyClients.html
|
||||
#
|
||||
# http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh
|
||||
|
||||
if [[ -n "$http_proxy" ]]; then
|
||||
export http_proxy=$http_proxy
|
||||
fi
|
||||
if [[ -n "$https_proxy" ]]; then
|
||||
export https_proxy=$https_proxy
|
||||
fi
|
||||
if [[ -n "$no_proxy" ]]; then
|
||||
export no_proxy=$no_proxy
|
||||
fi
|
||||
# Make sure the proxy config is visible to sub-processes
|
||||
export_proxy_variables
|
||||
|
||||
# Destination path for installation ``DEST``
|
||||
DEST=${DEST:-/opt/stack}
|
||||
|
||||
|
||||
# Sanity Check
|
||||
# ============
|
||||
# ------------
|
||||
|
||||
# Clean up last environment var cache
|
||||
if [[ -r $TOP_DIR/.stackenv ]]; then
|
||||
@ -631,26 +615,9 @@ set -o xtrace
|
||||
# OpenStack uses a fair number of other projects.
|
||||
|
||||
# Install package requirements
|
||||
# Source it so the entire environment is available
|
||||
echo_summary "Installing package prerequisites"
|
||||
if is_ubuntu; then
|
||||
install_package $(get_packages $FILES/apts)
|
||||
elif is_fedora; then
|
||||
install_package $(get_packages $FILES/rpms)
|
||||
elif is_suse; then
|
||||
install_package $(get_packages $FILES/rpms-suse)
|
||||
else
|
||||
exit_distro_not_supported "list of packages"
|
||||
fi
|
||||
|
||||
if [[ $SYSLOG != "False" ]]; then
|
||||
if is_ubuntu || is_fedora; then
|
||||
install_package rsyslog-relp
|
||||
elif is_suse; then
|
||||
install_package rsyslog-module-relp
|
||||
else
|
||||
exit_distro_not_supported "rsyslog-relp installation"
|
||||
fi
|
||||
fi
|
||||
source $TOP_DIR/tools/install_prereqs.sh
|
||||
|
||||
install_rpc_backend
|
||||
|
||||
|
82
tools/install_prereqs.sh
Executable file
82
tools/install_prereqs.sh
Executable file
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# **install_prereqs.sh**
|
||||
|
||||
# Install system package prerequisites
|
||||
#
|
||||
# install_prereqs.sh [-f]
|
||||
#
|
||||
# -f Force an install run now
|
||||
|
||||
if [[ -n "$1" && "$1" = "-f" ]]; then
|
||||
FORCE_PREREQ=1
|
||||
fi
|
||||
|
||||
# If TOP_DIR is set we're being sourced rather than running stand-alone
|
||||
# or in a sub-shell
|
||||
if [[ -z "$TOP_DIR" ]]; then
|
||||
# Keep track of the devstack directory
|
||||
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
|
||||
|
||||
# Import common functions
|
||||
source $TOP_DIR/functions
|
||||
|
||||
# Determine what system we are running on. This provides ``os_VENDOR``,
|
||||
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
|
||||
# and ``DISTRO``
|
||||
GetDistro
|
||||
|
||||
# Needed to get ``ENABLED_SERVICES``
|
||||
source $TOP_DIR/stackrc
|
||||
|
||||
# Prereq dirs are here
|
||||
FILES=$TOP_DIR/files
|
||||
fi
|
||||
|
||||
# Minimum wait time
|
||||
PREREQ_RERUN_MARKER=${PREREQ_RERUN_MARKER:-$TOP_DIR/.prereqs}
|
||||
PREREQ_RERUN_HOURS=${PREREQ_RERUN_HOURS:-2}
|
||||
PREREQ_RERUN_SECONDS=$((60*60*$PREREQ_RERUN_HOURS))
|
||||
|
||||
NOW=$(date "+%s")
|
||||
LAST_RUN=$(head -1 $PREREQ_RERUN_MARKER 2>/dev/null || echo "0")
|
||||
DELTA=$(($NOW - $LAST_RUN))
|
||||
if [[ $DELTA -lt $PREREQ_RERUN_SECONDS && -z "$FORCE_PREREQ" ]]; then
|
||||
echo "Re-run time has not expired ($(($PREREQ_RERUN_SECONDS - $DELTA)) seconds remaining); exiting..."
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Make sure the proxy config is visible to sub-processes
|
||||
export_proxy_variables
|
||||
|
||||
|
||||
# Install Packages
|
||||
# ================
|
||||
|
||||
# Install package requirements
|
||||
if is_ubuntu; then
|
||||
install_package $(get_packages $FILES/apts)
|
||||
elif is_fedora; then
|
||||
install_package $(get_packages $FILES/rpms)
|
||||
elif is_suse; then
|
||||
install_package $(get_packages $FILES/rpms-suse)
|
||||
else
|
||||
exit_distro_not_supported "list of packages"
|
||||
fi
|
||||
|
||||
if [[ -n "$SYSLOG" && "$SYSLOG" != "False" ]]; then
|
||||
if is_ubuntu || is_fedora; then
|
||||
install_package rsyslog-relp
|
||||
elif is_suse; then
|
||||
install_package rsyslog-module-relp
|
||||
else
|
||||
exit_distro_not_supported "rsyslog-relp installation"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Mark end of run
|
||||
# ---------------
|
||||
|
||||
date "+%s" >$PREREQ_RERUN_MARKER
|
||||
date >>$PREREQ_RERUN_MARKER
|
Loading…
Reference in New Issue
Block a user