* 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
| ... | ... |
@@ -80,6 +80,27 @@ function die_if_not_set() {
|
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 | 82 |
|
| 83 |
+# HTTP and HTTPS proxy servers are supported via the usual environment variables [1] |
|
| 84 |
+# ``http_proxy``, ``https_proxy`` and ``no_proxy``. They can be set in |
|
| 85 |
+# ``localrc`` or on the command line if necessary:: |
|
| 86 |
+# |
|
| 87 |
+# [1] http://www.w3.org/Daemon/User/Proxies/ProxyClients.html |
|
| 88 |
+# |
|
| 89 |
+# http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh |
|
| 90 |
+ |
|
| 91 |
+function export_proxy_variables() {
|
|
| 92 |
+ if [[ -n "$http_proxy" ]]; then |
|
| 93 |
+ export http_proxy=$http_proxy |
|
| 94 |
+ fi |
|
| 95 |
+ if [[ -n "$https_proxy" ]]; then |
|
| 96 |
+ export https_proxy=$https_proxy |
|
| 97 |
+ fi |
|
| 98 |
+ if [[ -n "$no_proxy" ]]; then |
|
| 99 |
+ export no_proxy=$no_proxy |
|
| 100 |
+ fi |
|
| 101 |
+} |
|
| 102 |
+ |
|
| 103 |
+ |
|
| 83 | 104 |
# Grab a numbered field from python prettytable output |
| 84 | 105 |
# Fields are numbered starting with 1 |
| 85 | 106 |
# Reverse syntax is supported: -1 is the last field, -2 is second to last, etc. |
| ... | ... |
@@ -30,9 +30,8 @@ source $TOP_DIR/functions |
| 30 | 30 |
GetDistro |
| 31 | 31 |
|
| 32 | 32 |
|
| 33 |
- |
|
| 34 |
-# Settings |
|
| 35 |
-# ======== |
|
| 33 |
+# Global Settings |
|
| 34 |
+# =============== |
|
| 36 | 35 |
|
| 37 | 36 |
# ``stack.sh`` is customizable through setting environment variables. If you |
| 38 | 37 |
# want to override a setting you can set and export it:: |
| ... | ... |
@@ -62,33 +61,18 @@ fi |
| 62 | 62 |
source $TOP_DIR/stackrc |
| 63 | 63 |
|
| 64 | 64 |
|
| 65 |
-# Proxy Settings |
|
| 65 |
+# Local Settings |
|
| 66 | 66 |
# -------------- |
| 67 | 67 |
|
| 68 |
-# HTTP and HTTPS proxy servers are supported via the usual environment variables [1] |
|
| 69 |
-# ``http_proxy``, ``https_proxy`` and ``no_proxy``. They can be set in |
|
| 70 |
-# ``localrc`` if necessary or on the command line:: |
|
| 71 |
-# |
|
| 72 |
-# [1] http://www.w3.org/Daemon/User/Proxies/ProxyClients.html |
|
| 73 |
-# |
|
| 74 |
-# http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh |
|
| 75 |
- |
|
| 76 |
-if [[ -n "$http_proxy" ]]; then |
|
| 77 |
- export http_proxy=$http_proxy |
|
| 78 |
-fi |
|
| 79 |
-if [[ -n "$https_proxy" ]]; then |
|
| 80 |
- export https_proxy=$https_proxy |
|
| 81 |
-fi |
|
| 82 |
-if [[ -n "$no_proxy" ]]; then |
|
| 83 |
- export no_proxy=$no_proxy |
|
| 84 |
-fi |
|
| 68 |
+# Make sure the proxy config is visible to sub-processes |
|
| 69 |
+export_proxy_variables |
|
| 85 | 70 |
|
| 86 | 71 |
# Destination path for installation ``DEST`` |
| 87 | 72 |
DEST=${DEST:-/opt/stack}
|
| 88 | 73 |
|
| 89 | 74 |
|
| 90 | 75 |
# Sanity Check |
| 91 |
-# ============ |
|
| 76 |
+# ------------ |
|
| 92 | 77 |
|
| 93 | 78 |
# Clean up last environment var cache |
| 94 | 79 |
if [[ -r $TOP_DIR/.stackenv ]]; then |
| ... | ... |
@@ -631,26 +615,9 @@ set -o xtrace |
| 631 | 631 |
# OpenStack uses a fair number of other projects. |
| 632 | 632 |
|
| 633 | 633 |
# Install package requirements |
| 634 |
+# Source it so the entire environment is available |
|
| 634 | 635 |
echo_summary "Installing package prerequisites" |
| 635 |
-if is_ubuntu; then |
|
| 636 |
- install_package $(get_packages $FILES/apts) |
|
| 637 |
-elif is_fedora; then |
|
| 638 |
- install_package $(get_packages $FILES/rpms) |
|
| 639 |
-elif is_suse; then |
|
| 640 |
- install_package $(get_packages $FILES/rpms-suse) |
|
| 641 |
-else |
|
| 642 |
- exit_distro_not_supported "list of packages" |
|
| 643 |
-fi |
|
| 644 |
- |
|
| 645 |
-if [[ $SYSLOG != "False" ]]; then |
|
| 646 |
- if is_ubuntu || is_fedora; then |
|
| 647 |
- install_package rsyslog-relp |
|
| 648 |
- elif is_suse; then |
|
| 649 |
- install_package rsyslog-module-relp |
|
| 650 |
- else |
|
| 651 |
- exit_distro_not_supported "rsyslog-relp installation" |
|
| 652 |
- fi |
|
| 653 |
-fi |
|
| 636 |
+source $TOP_DIR/tools/install_prereqs.sh |
|
| 654 | 637 |
|
| 655 | 638 |
install_rpc_backend |
| 656 | 639 |
|
| 657 | 640 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,82 @@ |
| 0 |
+#!/usr/bin/env bash |
|
| 1 |
+ |
|
| 2 |
+# **install_prereqs.sh** |
|
| 3 |
+ |
|
| 4 |
+# Install system package prerequisites |
|
| 5 |
+# |
|
| 6 |
+# install_prereqs.sh [-f] |
|
| 7 |
+# |
|
| 8 |
+# -f Force an install run now |
|
| 9 |
+ |
|
| 10 |
+if [[ -n "$1" && "$1" = "-f" ]]; then |
|
| 11 |
+ FORCE_PREREQ=1 |
|
| 12 |
+fi |
|
| 13 |
+ |
|
| 14 |
+# If TOP_DIR is set we're being sourced rather than running stand-alone |
|
| 15 |
+# or in a sub-shell |
|
| 16 |
+if [[ -z "$TOP_DIR" ]]; then |
|
| 17 |
+ # Keep track of the devstack directory |
|
| 18 |
+ TOP_DIR=$(cd $(dirname "$0")/.. && pwd) |
|
| 19 |
+ |
|
| 20 |
+ # Import common functions |
|
| 21 |
+ source $TOP_DIR/functions |
|
| 22 |
+ |
|
| 23 |
+ # Determine what system we are running on. This provides ``os_VENDOR``, |
|
| 24 |
+ # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` |
|
| 25 |
+ # and ``DISTRO`` |
|
| 26 |
+ GetDistro |
|
| 27 |
+ |
|
| 28 |
+ # Needed to get ``ENABLED_SERVICES`` |
|
| 29 |
+ source $TOP_DIR/stackrc |
|
| 30 |
+ |
|
| 31 |
+ # Prereq dirs are here |
|
| 32 |
+ FILES=$TOP_DIR/files |
|
| 33 |
+fi |
|
| 34 |
+ |
|
| 35 |
+# Minimum wait time |
|
| 36 |
+PREREQ_RERUN_MARKER=${PREREQ_RERUN_MARKER:-$TOP_DIR/.prereqs}
|
|
| 37 |
+PREREQ_RERUN_HOURS=${PREREQ_RERUN_HOURS:-2}
|
|
| 38 |
+PREREQ_RERUN_SECONDS=$((60*60*$PREREQ_RERUN_HOURS)) |
|
| 39 |
+ |
|
| 40 |
+NOW=$(date "+%s") |
|
| 41 |
+LAST_RUN=$(head -1 $PREREQ_RERUN_MARKER 2>/dev/null || echo "0") |
|
| 42 |
+DELTA=$(($NOW - $LAST_RUN)) |
|
| 43 |
+if [[ $DELTA -lt $PREREQ_RERUN_SECONDS && -z "$FORCE_PREREQ" ]]; then |
|
| 44 |
+ echo "Re-run time has not expired ($(($PREREQ_RERUN_SECONDS - $DELTA)) seconds remaining); exiting..." |
|
| 45 |
+ return 0 |
|
| 46 |
+fi |
|
| 47 |
+ |
|
| 48 |
+# Make sure the proxy config is visible to sub-processes |
|
| 49 |
+export_proxy_variables |
|
| 50 |
+ |
|
| 51 |
+ |
|
| 52 |
+# Install Packages |
|
| 53 |
+# ================ |
|
| 54 |
+ |
|
| 55 |
+# Install package requirements |
|
| 56 |
+if is_ubuntu; then |
|
| 57 |
+ install_package $(get_packages $FILES/apts) |
|
| 58 |
+elif is_fedora; then |
|
| 59 |
+ install_package $(get_packages $FILES/rpms) |
|
| 60 |
+elif is_suse; then |
|
| 61 |
+ install_package $(get_packages $FILES/rpms-suse) |
|
| 62 |
+else |
|
| 63 |
+ exit_distro_not_supported "list of packages" |
|
| 64 |
+fi |
|
| 65 |
+ |
|
| 66 |
+if [[ -n "$SYSLOG" && "$SYSLOG" != "False" ]]; then |
|
| 67 |
+ if is_ubuntu || is_fedora; then |
|
| 68 |
+ install_package rsyslog-relp |
|
| 69 |
+ elif is_suse; then |
|
| 70 |
+ install_package rsyslog-module-relp |
|
| 71 |
+ else |
|
| 72 |
+ exit_distro_not_supported "rsyslog-relp installation" |
|
| 73 |
+ fi |
|
| 74 |
+fi |
|
| 75 |
+ |
|
| 76 |
+ |
|
| 77 |
+# Mark end of run |
|
| 78 |
+# --------------- |
|
| 79 |
+ |
|
| 80 |
+date "+%s" >$PREREQ_RERUN_MARKER |
|
| 81 |
+date >>$PREREQ_RERUN_MARKER |