blob: 9651083cb3467645186b9abf09c51194d980a366 [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
11if [[ -n "$1" && "$1" = "-f" ]]; then
12 FORCE_PREREQ=1
13fi
14
15# If TOP_DIR is set we're being sourced rather than running stand-alone
16# or in a sub-shell
17if [[ -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
34fi
35
36# Minimum wait time
37PREREQ_RERUN_MARKER=${PREREQ_RERUN_MARKER:-$TOP_DIR/.prereqs}
38PREREQ_RERUN_HOURS=${PREREQ_RERUN_HOURS:-2}
39PREREQ_RERUN_SECONDS=$((60*60*$PREREQ_RERUN_HOURS))
40
41NOW=$(date "+%s")
42LAST_RUN=$(head -1 $PREREQ_RERUN_MARKER 2>/dev/null || echo "0")
43DELTA=$(($NOW - $LAST_RUN))
44if [[ $DELTA -lt $PREREQ_RERUN_SECONDS && -z "$FORCE_PREREQ" ]]; then
Ian Wienand7919d852013-04-26 11:28:29 +100045 echo "Re-run time has not expired ($(($PREREQ_RERUN_SECONDS - $DELTA)) seconds remaining) "
46 echo "and FORCE_PREREQ not set; exiting..."
Dean Troyer48352ee2012-12-12 12:50:38 -060047 return 0
48fi
49
50# Make sure the proxy config is visible to sub-processes
51export_proxy_variables
52
53
54# Install Packages
55# ================
56
57# Install package requirements
Alexander Gordeev06fb29c2014-01-31 18:02:07 +040058PACKAGES=$(get_packages general $ENABLED_SERVICES)
59if is_ubuntu && echo $PACKAGES | grep -q dkms ; then
60 # ensure headers for the running kernel are installed for any DKMS builds
61 PACKAGES="$PACKAGES linux-headers-$(uname -r)"
62fi
63
64install_package $PACKAGES
Dean Troyer48352ee2012-12-12 12:50:38 -060065
66if [[ -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
74fi
75
76
77# Mark end of run
78# ---------------
79
80date "+%s" >$PREREQ_RERUN_MARKER
81date >>$PREREQ_RERUN_MARKER