blob: bb470b29279b9948a2a26b92594b93af5c87f916 [file] [log] [blame]
Dean Troyer48352ee2012-12-12 12:50:38 -06001#!/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 Dague53753292014-12-04 19:38:15 -050011FORCE_PREREQ=0
12
13while getopts ":f" opt; do
14 case $opt in
15 f)
16 FORCE_PREREQ=1
17 ;;
18 esac
19done
Dean Troyer48352ee2012-12-12 12:50:38 -060020
Dean Troyerdc97cb72015-03-28 08:20:50 -050021# If ``TOP_DIR`` is set we're being sourced rather than running stand-alone
Dean Troyer48352ee2012-12-12 12:50:38 -060022# or in a sub-shell
23if [[ -z "$TOP_DIR" ]]; then
Dean Troyerdc97cb72015-03-28 08:20:50 -050024 # Keep track of the DevStack directory
Dean Troyer48352ee2012-12-12 12:50:38 -060025 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``,
Ian Wienand7710e7f2014-08-27 16:15:32 +100031 # ``os_RELEASE``, ``os_PACKAGE``, ``os_CODENAME``
Dean Troyer48352ee2012-12-12 12:50:38 -060032 # 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
40fi
41
42# Minimum wait time
43PREREQ_RERUN_MARKER=${PREREQ_RERUN_MARKER:-$TOP_DIR/.prereqs}
44PREREQ_RERUN_HOURS=${PREREQ_RERUN_HOURS:-2}
45PREREQ_RERUN_SECONDS=$((60*60*$PREREQ_RERUN_HOURS))
46
47NOW=$(date "+%s")
48LAST_RUN=$(head -1 $PREREQ_RERUN_MARKER 2>/dev/null || echo "0")
49DELTA=$(($NOW - $LAST_RUN))
50if [[ $DELTA -lt $PREREQ_RERUN_SECONDS && -z "$FORCE_PREREQ" ]]; then
Ian Wienand7919d852013-04-26 11:28:29 +100051 echo "Re-run time has not expired ($(($PREREQ_RERUN_SECONDS - $DELTA)) seconds remaining) "
52 echo "and FORCE_PREREQ not set; exiting..."
Dean Troyer48352ee2012-12-12 12:50:38 -060053 return 0
54fi
55
56# Make sure the proxy config is visible to sub-processes
57export_proxy_variables
58
59
60# Install Packages
61# ================
62
63# Install package requirements
Ian Wienandb8509f02015-11-09 11:55:56 +110064PACKAGES=$(get_packages general,$ENABLED_SERVICES)
Adam Gandelman7ca90cd2015-03-04 17:25:07 -080065PACKAGES="$PACKAGES $(get_plugin_packages)"
66
Alexander Gordeev06fb29c2014-01-31 18:02:07 +040067if is_ubuntu && echo $PACKAGES | grep -q dkms ; then
Dean Troyerdc97cb72015-03-28 08:20:50 -050068 # Ensure headers for the running kernel are installed for any DKMS builds
Alexander Gordeev06fb29c2014-01-31 18:02:07 +040069 PACKAGES="$PACKAGES linux-headers-$(uname -r)"
70fi
71
72install_package $PACKAGES
Dean Troyer48352ee2012-12-12 12:50:38 -060073
74if [[ -n "$SYSLOG" && "$SYSLOG" != "False" ]]; then
75 if is_ubuntu || is_fedora; then
76 install_package rsyslog-relp
Dean Troyer48352ee2012-12-12 12:50:38 -060077 else
78 exit_distro_not_supported "rsyslog-relp installation"
79 fi
80fi
81
Clark Boylana40f9cb2018-04-04 14:02:30 -070082# TODO(clarkb) remove these once we are switched to global venv by default
83export PYTHON=$(which python${PYTHON3_VERSION} 2>/dev/null || which python3 2>/dev/null)
Dean Troyer48352ee2012-12-12 12:50:38 -060084
Dean Troyer48352ee2012-12-12 12:50:38 -060085# Mark end of run
86# ---------------
87
88date "+%s" >$PREREQ_RERUN_MARKER
89date >>$PREREQ_RERUN_MARKER