blob: a77eae6fe737463a95d758b0308273ab815aaab5 [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
Dirk Muellere61e19e2017-05-27 23:43:05 +020063if [[ "${DISTRO}" == "opensuse-42.2" ]]; then
64 # temporary workaround until https://bugzilla.suse.com/show_bug.cgi?id=1041161 is fixed
65 sudo zypper ar -f http://download.opensuse.org/update/leap/42.2-test/ leap42.2-test-updates
66 sudo zypper --non-interactive --gpg-auto-import-keys --no-gpg-checks ref
67 sudo zypper --non-interactive install liberasurecode-devel
68 sudo zypper rr leap42.2-test-updates
69fi
70
Dean Troyer48352ee2012-12-12 12:50:38 -060071# Install package requirements
Ian Wienandb8509f02015-11-09 11:55:56 +110072PACKAGES=$(get_packages general,$ENABLED_SERVICES)
Adam Gandelman7ca90cd2015-03-04 17:25:07 -080073PACKAGES="$PACKAGES $(get_plugin_packages)"
74
Alexander Gordeev06fb29c2014-01-31 18:02:07 +040075if is_ubuntu && echo $PACKAGES | grep -q dkms ; then
Dean Troyerdc97cb72015-03-28 08:20:50 -050076 # Ensure headers for the running kernel are installed for any DKMS builds
Alexander Gordeev06fb29c2014-01-31 18:02:07 +040077 PACKAGES="$PACKAGES linux-headers-$(uname -r)"
78fi
79
80install_package $PACKAGES
Dean Troyer48352ee2012-12-12 12:50:38 -060081
82if [[ -n "$SYSLOG" && "$SYSLOG" != "False" ]]; then
83 if is_ubuntu || is_fedora; then
84 install_package rsyslog-relp
85 elif is_suse; then
86 install_package rsyslog-module-relp
87 else
88 exit_distro_not_supported "rsyslog-relp installation"
89 fi
90fi
91
Doug Hellmannddc38392015-05-07 21:06:24 +000092if python3_enabled; then
93 install_python3
Davanum Srinivas51ecf0a2017-01-05 16:11:17 -050094 export PYTHON=$(which python${PYTHON3_VERSION} 2>/dev/null || which python3 2>/dev/null)
95else
96 export PYTHON=$(which python 2>/dev/null)
Doug Hellmannddc38392015-05-07 21:06:24 +000097fi
Dean Troyer48352ee2012-12-12 12:50:38 -060098
99# Mark end of run
100# ---------------
101
102date "+%s" >$PREREQ_RERUN_MARKER
103date >>$PREREQ_RERUN_MARKER