Browse code

Merge "Create tools/install_prereqs.sh"

Jenkins authored on 2013/01/02 22:25:22
Showing 3 changed files
... ...
@@ -710,6 +710,27 @@ function restart_service() {
710 710
 }
711 711
 
712 712
 
713
+# HTTP and HTTPS proxy servers are supported via the usual environment variables [1]
714
+# ``http_proxy``, ``https_proxy`` and ``no_proxy``. They can be set in
715
+# ``localrc`` or on the command line if necessary::
716
+#
717
+# [1] http://www.w3.org/Daemon/User/Proxies/ProxyClients.html
718
+#
719
+#     http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh
720
+
721
+function re_export_proxy_variables() {
722
+    if [[ -n "$http_proxy" ]]; then
723
+        export http_proxy=$http_proxy
724
+    fi
725
+    if [[ -n "$https_proxy" ]]; then
726
+        export https_proxy=$https_proxy
727
+    fi
728
+    if [[ -n "$no_proxy" ]]; then
729
+        export no_proxy=$no_proxy
730
+    fi
731
+}
732
+
733
+
713 734
 # Helper to launch a service in a named screen
714 735
 # screen_it service "command-line"
715 736
 function screen_it {
... ...
@@ -648,25 +648,7 @@ set -o xtrace
648 648
 
649 649
 # Install package requirements
650 650
 echo_summary "Installing package prerequisites"
651
-if is_ubuntu; then
652
-    install_package $(get_packages $FILES/apts)
653
-elif is_fedora; then
654
-    install_package $(get_packages $FILES/rpms)
655
-elif is_suse; then
656
-    install_package $(get_packages $FILES/rpms-suse)
657
-else
658
-    exit_distro_not_supported "list of packages"
659
-fi
660
-
661
-if [[ $SYSLOG != "False" ]]; then
662
-    if is_ubuntu || is_fedora; then
663
-        install_package rsyslog-relp
664
-    elif is_suse; then
665
-        install_package rsyslog-module-relp
666
-    else
667
-        exit_distro_not_supported "rsyslog-relp installation"
668
-    fi
669
-fi
651
+$TOP_DIR/tools/install_prereqs.sh
670 652
 
671 653
 if is_service_enabled rabbit; then
672 654
     # Install rabbitmq-server
673 655
new file mode 100755
... ...
@@ -0,0 +1,78 @@
0
+#!/usr/bin/env bash
1
+
2
+# **install_prereqs.sh**
3
+
4
+# Install system package prerequisites
5
+#
6
+# install_prereqs.sh [-f]
7
+#
8
+# -f        Force an install run now
9
+
10
+
11
+if [[ -n "$1" &&  "$1" = "-f" ]]; then
12
+    FORCE=1
13
+fi
14
+
15
+# Keep track of the devstack directory
16
+TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
17
+
18
+# Import common functions
19
+source $TOP_DIR/functions
20
+
21
+# Determine what system we are running on.  This provides ``os_VENDOR``,
22
+# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
23
+# and ``DISTRO``
24
+GetDistro
25
+
26
+# Needed to get ``ENABLED_SERVICES``
27
+source $TOP_DIR/stackrc
28
+
29
+# Prereq dirs are here
30
+FILES=$TOP_DIR/files
31
+
32
+# Minimum wait time
33
+PREREQ_RERUN_MARKER=${PREREQ_RERUN_MARKER:-$TOP_DIR/.prereqs}
34
+PREREQ_RERUN_HOURS=${PREREQ_RERUN_HOURS:-2}
35
+PREREQ_RERUN_SECONDS=$((60*60*$PREREQ_RERUN_HOURS))
36
+
37
+NOW=$(date "+%s")
38
+LAST_RUN=$(head -1 $PREREQ_RERUN_MARKER 2>/dev/null || echo "0")
39
+DELTA=$(($NOW - $LAST_RUN))
40
+if [[ $DELTA -lt $PREREQ_RERUN_SECONDS && -z "$FORCE" ]]; then
41
+    echo "Re-run time has not expired ($(($PREREQ_RERUN_SECONDS - $DELTA)) seconds remaining); exiting..."
42
+    exit 0
43
+fi
44
+
45
+# Make sure the proxy config is visible to sub-processes
46
+re_export_proxy_variables
47
+
48
+# Install Packages
49
+# ================
50
+
51
+# Install package requirements
52
+if is_ubuntu; then
53
+    install_package $(get_packages $FILES/apts)
54
+elif is_fedora; then
55
+    install_package $(get_packages $FILES/rpms)
56
+elif is_suse; then
57
+    install_package $(get_packages $FILES/rpms-suse)
58
+else
59
+    exit_distro_not_supported "list of packages"
60
+fi
61
+
62
+if [[ -n "$SYSLOG" && "$SYSLOG" != "False" ]]; then
63
+    if is_ubuntu || is_fedora; then
64
+        install_package rsyslog-relp
65
+    elif is_suse; then
66
+        install_package rsyslog-module-relp
67
+    else
68
+        exit_distro_not_supported "rsyslog-relp installation"
69
+    fi
70
+fi
71
+
72
+
73
+# Mark end of run
74
+# ---------------
75
+
76
+date "+%s" >$PREREQ_RERUN_MARKER
77
+date >>$PREREQ_RERUN_MARKER