| 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 |  | 
 | 11 | if [[ -n "$1" &&  "$1" = "-f" ]]; then | 
 | 12 |     FORCE_PREREQ=1 | 
 | 13 | fi | 
 | 14 |  | 
 | 15 | # If TOP_DIR is set we're being sourced rather than running stand-alone | 
 | 16 | # or in a sub-shell | 
 | 17 | if [[ -z "$TOP_DIR" ]]; then | 
 | 18 |     # Keep track of the devstack directory | 
 | 19 |     TOP_DIR=$(cd $(dirname "$0")/.. && pwd) | 
 | 20 |  | 
 | 21 |     # Import common functions | 
 | 22 |     source $TOP_DIR/functions | 
 | 23 |  | 
 | 24 |     # Determine what system we are running on.  This provides ``os_VENDOR``, | 
 | 25 |     # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` | 
 | 26 |     # and ``DISTRO`` | 
 | 27 |     GetDistro | 
 | 28 |  | 
 | 29 |     # Needed to get ``ENABLED_SERVICES`` | 
 | 30 |     source $TOP_DIR/stackrc | 
 | 31 |  | 
 | 32 |     # Prereq dirs are here | 
 | 33 |     FILES=$TOP_DIR/files | 
 | 34 | fi | 
 | 35 |  | 
 | 36 | # Minimum wait time | 
 | 37 | PREREQ_RERUN_MARKER=${PREREQ_RERUN_MARKER:-$TOP_DIR/.prereqs} | 
 | 38 | PREREQ_RERUN_HOURS=${PREREQ_RERUN_HOURS:-2} | 
 | 39 | PREREQ_RERUN_SECONDS=$((60*60*$PREREQ_RERUN_HOURS)) | 
 | 40 |  | 
 | 41 | NOW=$(date "+%s") | 
 | 42 | LAST_RUN=$(head -1 $PREREQ_RERUN_MARKER 2>/dev/null || echo "0") | 
 | 43 | DELTA=$(($NOW - $LAST_RUN)) | 
 | 44 | if [[ $DELTA -lt $PREREQ_RERUN_SECONDS && -z "$FORCE_PREREQ" ]]; then | 
| Ian Wienand | 7919d85 | 2013-04-26 11:28:29 +1000 | [diff] [blame] | 45 |     echo "Re-run time has not expired ($(($PREREQ_RERUN_SECONDS - $DELTA)) seconds remaining) " | 
 | 46 |     echo "and FORCE_PREREQ not set; exiting..." | 
| Dean Troyer | 48352ee | 2012-12-12 12:50:38 -0600 | [diff] [blame] | 47 |     return 0 | 
 | 48 | fi | 
 | 49 |  | 
 | 50 | # Make sure the proxy config is visible to sub-processes | 
 | 51 | export_proxy_variables | 
 | 52 |  | 
 | 53 |  | 
 | 54 | # Install Packages | 
 | 55 | # ================ | 
 | 56 |  | 
 | 57 | # Install package requirements | 
| Isaku Yamahata | 8c43809 | 2013-02-12 22:30:56 +0900 | [diff] [blame] | 58 | install_package $(get_packages $ENABLED_SERVICES) | 
| Dean Troyer | 48352ee | 2012-12-12 12:50:38 -0600 | [diff] [blame] | 59 |  | 
 | 60 | if [[ -n "$SYSLOG" && "$SYSLOG" != "False" ]]; then | 
 | 61 |     if is_ubuntu || is_fedora; then | 
 | 62 |         install_package rsyslog-relp | 
 | 63 |     elif is_suse; then | 
 | 64 |         install_package rsyslog-module-relp | 
 | 65 |     else | 
 | 66 |         exit_distro_not_supported "rsyslog-relp installation" | 
 | 67 |     fi | 
 | 68 | fi | 
 | 69 |  | 
 | 70 |  | 
 | 71 | # Mark end of run | 
 | 72 | # --------------- | 
 | 73 |  | 
 | 74 | date "+%s" >$PREREQ_RERUN_MARKER | 
 | 75 | date >>$PREREQ_RERUN_MARKER |