blob: 4d151db2cb9aff99e5611f3387a8916e5c5341eb [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
45 echo "Re-run time has not expired ($(($PREREQ_RERUN_SECONDS - $DELTA)) seconds remaining); exiting..."
46 return 0
47fi
48
49# Make sure the proxy config is visible to sub-processes
50export_proxy_variables
51
52
53# Install Packages
54# ================
55
56# Install package requirements
57if is_ubuntu; then
58 install_package $(get_packages $FILES/apts)
59elif is_fedora; then
60 install_package $(get_packages $FILES/rpms)
61elif is_suse; then
62 install_package $(get_packages $FILES/rpms-suse)
63else
64 exit_distro_not_supported "list of packages"
65fi
66
67if [[ -n "$SYSLOG" && "$SYSLOG" != "False" ]]; then
68 if is_ubuntu || is_fedora; then
69 install_package rsyslog-relp
70 elif is_suse; then
71 install_package rsyslog-module-relp
72 else
73 exit_distro_not_supported "rsyslog-relp installation"
74 fi
75fi
76
77
78# Mark end of run
79# ---------------
80
81date "+%s" >$PREREQ_RERUN_MARKER
82date >>$PREREQ_RERUN_MARKER