Browse code

Grab upstream nodejs for RHEL6

RHEL6 has no nodejs in main packages or in EPEL. The easiest way is
to just install the upstream binary version which works fine for the
very minimal usage by lesscss.

Change-Id: Ia35e7dbaf4c7add43797d6b7d0c846bab1cf0cb0

Ian Wienand authored on 2013/04/11 10:13:09
Showing 1 changed files
... ...
@@ -61,16 +61,47 @@ function _horizon_config_set() {
61 61
     fi
62 62
 }
63 63
 
64
+# Basic install of upstream nodejs for platforms that want it
65
+function install_nodejs() {
66
+    if [[ $(which node) ]]; then
67
+        echo "You already appear to have nodejs, skipping install"
68
+        return
69
+    fi
70
+
71
+    # There are several node deployment scripts; one may be more
72
+    # appropriate at some future point, but for now direct download is
73
+    # the simplest way.  The version barely matters for lesscss which
74
+    # doesn't use anything fancy.
75
+    local ver=0.10.1
76
+    local nodejs=node-v${ver}-linux-x64
77
+    local tar=$nodejs.tar.gz
78
+    local nodejs_url=http://nodejs.org/dist/v${ver}/${tar}
79
+
80
+    curl -Ss ${nodejs_url} | tar -C ${DEST} -xz
81
+    if [ $? -ne 0 ]; then
82
+        echo "*** Download of nodejs failed"
83
+        return 1
84
+    fi
85
+
86
+    # /usr/bin so it gets found in the PATH available to horizon
87
+    sudo ln -s $DEST/$nodejs/bin/node /usr/bin/node
88
+}
89
+
64 90
 # Entry Points
65 91
 # ------------
66 92
 
67 93
 # cleanup_horizon() - Remove residual data files, anything left over from previous
68 94
 # runs that a clean run would need to clean up
69 95
 function cleanup_horizon() {
70
-    # kill instances (nova)
71
-    # delete image files (glance)
72
-    # This function intentionally left blank
73
-    :
96
+
97
+    if [[ is_fedora && $DISTRO =~ (rhel6) ]]; then
98
+    # if the /usr/bin/node link looks like it's pointing into $DEST,
99
+    # then we installed it via install_nodejs
100
+        if [[ $(readlink -f /usr/bin/node) =~ ($DEST) ]]; then
101
+            sudo rm /usr/bin/node
102
+        fi
103
+    fi
104
+
74 105
 }
75 106
 
76 107
 # configure_horizon() - Set config files, create data dirs, etc
... ...
@@ -159,6 +190,14 @@ function install_horizon() {
159 159
         exit_distro_not_supported "apache installation"
160 160
     fi
161 161
 
162
+    if [[ is_fedora && $DISTRO =~ (rhel6) ]]; then
163
+        # RHEL6 currently has no native way to get nodejs, so we do a
164
+        # basic install here (see cleanup_horizon too).
165
+        # TODO: does nova have a better way that we can limit
166
+        # requirement of site-wide nodejs install?
167
+        install_nodejs
168
+    fi
169
+
162 170
     # NOTE(sdague) quantal changed the name of the node binary
163 171
     if is_ubuntu; then
164 172
         if [[ ! -e "/usr/bin/node" ]]; then