Dean Troyer | 48352ee | 2012-12-12 12:50:38 -0600 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # **install_prereqs.sh** |
| 4 | |
| 5 | # Install system package prerequisites |
| 6 | # |
| 7 | # install_prereqs.sh [-f] |
| 8 | # |
| 9 | # -f Force an install run now |
| 10 | |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 11 | FORCE_PREREQ=0 |
| 12 | |
| 13 | while getopts ":f" opt; do |
| 14 | case $opt in |
| 15 | f) |
| 16 | FORCE_PREREQ=1 |
| 17 | ;; |
| 18 | esac |
| 19 | done |
Dean Troyer | 48352ee | 2012-12-12 12:50:38 -0600 | [diff] [blame] | 20 | |
| 21 | # If TOP_DIR is set we're being sourced rather than running stand-alone |
| 22 | # or in a sub-shell |
| 23 | if [[ -z "$TOP_DIR" ]]; then |
| 24 | # Keep track of the devstack directory |
| 25 | TOP_DIR=$(cd $(dirname "$0")/.. && pwd) |
| 26 | |
| 27 | # Import common functions |
| 28 | source $TOP_DIR/functions |
| 29 | |
| 30 | # Determine what system we are running on. This provides ``os_VENDOR``, |
| 31 | # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` |
| 32 | # and ``DISTRO`` |
| 33 | GetDistro |
| 34 | |
| 35 | # Needed to get ``ENABLED_SERVICES`` |
| 36 | source $TOP_DIR/stackrc |
| 37 | |
| 38 | # Prereq dirs are here |
| 39 | FILES=$TOP_DIR/files |
| 40 | fi |
| 41 | |
| 42 | # Minimum wait time |
| 43 | PREREQ_RERUN_MARKER=${PREREQ_RERUN_MARKER:-$TOP_DIR/.prereqs} |
| 44 | PREREQ_RERUN_HOURS=${PREREQ_RERUN_HOURS:-2} |
| 45 | PREREQ_RERUN_SECONDS=$((60*60*$PREREQ_RERUN_HOURS)) |
| 46 | |
| 47 | NOW=$(date "+%s") |
| 48 | LAST_RUN=$(head -1 $PREREQ_RERUN_MARKER 2>/dev/null || echo "0") |
| 49 | DELTA=$(($NOW - $LAST_RUN)) |
| 50 | if [[ $DELTA -lt $PREREQ_RERUN_SECONDS && -z "$FORCE_PREREQ" ]]; then |
Ian Wienand | 7919d85 | 2013-04-26 11:28:29 +1000 | [diff] [blame] | 51 | echo "Re-run time has not expired ($(($PREREQ_RERUN_SECONDS - $DELTA)) seconds remaining) " |
| 52 | echo "and FORCE_PREREQ not set; exiting..." |
Dean Troyer | 48352ee | 2012-12-12 12:50:38 -0600 | [diff] [blame] | 53 | return 0 |
| 54 | fi |
| 55 | |
| 56 | # Make sure the proxy config is visible to sub-processes |
| 57 | export_proxy_variables |
| 58 | |
| 59 | |
| 60 | # Install Packages |
| 61 | # ================ |
| 62 | |
| 63 | # Install package requirements |
Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame] | 64 | PACKAGES=$(get_packages general $ENABLED_SERVICES) |
Adam Gandelman | 7ca90cd | 2015-03-04 17:25:07 -0800 | [diff] [blame^] | 65 | PACKAGES="$PACKAGES $(get_plugin_packages)" |
| 66 | |
Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame] | 67 | if is_ubuntu && echo $PACKAGES | grep -q dkms ; then |
| 68 | # ensure headers for the running kernel are installed for any DKMS builds |
| 69 | PACKAGES="$PACKAGES linux-headers-$(uname -r)" |
| 70 | fi |
| 71 | |
| 72 | install_package $PACKAGES |
Dean Troyer | 48352ee | 2012-12-12 12:50:38 -0600 | [diff] [blame] | 73 | |
| 74 | if [[ -n "$SYSLOG" && "$SYSLOG" != "False" ]]; then |
| 75 | if is_ubuntu || is_fedora; then |
| 76 | install_package rsyslog-relp |
| 77 | elif is_suse; then |
| 78 | install_package rsyslog-module-relp |
| 79 | else |
| 80 | exit_distro_not_supported "rsyslog-relp installation" |
| 81 | fi |
| 82 | fi |
| 83 | |
| 84 | |
| 85 | # Mark end of run |
| 86 | # --------------- |
| 87 | |
| 88 | date "+%s" >$PREREQ_RERUN_MARKER |
| 89 | date >>$PREREQ_RERUN_MARKER |