blob: 0bf217b3ae5d5938c3e962ecebd77401ecfc57f4 [file] [log] [blame]
Dean Troyer7be0b042012-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
11
12if [[ -n "$1" && "$1" = "-f" ]]; then
13 FORCE=1
14fi
15
16# Keep track of the devstack directory
17TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
18
19# Import common functions
20source $TOP_DIR/functions
21
22# Determine what system we are running on. This provides ``os_VENDOR``,
23# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
24# and ``DISTRO``
25GetDistro
26
27# Needed to get ``ENABLED_SERVICES``
28source $TOP_DIR/stackrc
29
30# Prereq dirs are here
31FILES=$TOP_DIR/files
32
33# Minimum wait time
34PREREQ_RERUN_MARKER=${PREREQ_RERUN_MARKER:-$TOP_DIR/.prereqs}
35PREREQ_RERUN_HOURS=${PREREQ_RERUN_HOURS:-2}
36PREREQ_RERUN_SECONDS=$((60*60*$PREREQ_RERUN_HOURS))
37
38NOW=$(date "+%s")
39LAST_RUN=$(head -1 $PREREQ_RERUN_MARKER 2>/dev/null || echo "0")
40DELTA=$(($NOW - $LAST_RUN))
41if [[ $DELTA -lt $PREREQ_RERUN_SECONDS && -z "$FORCE" ]]; then
42 echo "Re-run time has not expired ($(($PREREQ_RERUN_SECONDS - $DELTA)) seconds remaining); exiting..."
43 exit 0
44fi
45
46# Make sure the proxy config is visible to sub-processes
47re_export_proxy_variables
48
49# Install Packages
50# ================
51
52# Install package requirements
53if is_ubuntu; then
54 install_package $(get_packages $FILES/apts)
55elif is_fedora; then
56 install_package $(get_packages $FILES/rpms)
57elif is_suse; then
58 install_package $(get_packages $FILES/rpms-suse)
59else
60 exit_distro_not_supported "list of packages"
61fi
62
63if [[ -n "$SYSLOG" && "$SYSLOG" != "False" ]]; then
64 if is_ubuntu || is_fedora; then
65 install_package rsyslog-relp
66 elif is_suse; then
67 install_package rsyslog-module-relp
68 else
69 exit_distro_not_supported "rsyslog-relp installation"
70 fi
71fi
72
73
74# Mark end of run
75# ---------------
76
77date "+%s" >$PREREQ_RERUN_MARKER
78date >>$PREREQ_RERUN_MARKER