blob: 68f11ce35ee59b50b8a60ed747751d885ca6a236 [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
Isaku Yamahata8c438092013-02-12 22:30:56 +090058install_package $(get_packages $ENABLED_SERVICES)
Dean Troyer48352ee2012-12-12 12:50:38 -060059
60if [[ -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
68fi
69
70
71# Mark end of run
72# ---------------
73
74date "+%s" >$PREREQ_RERUN_MARKER
75date >>$PREREQ_RERUN_MARKER