|  | @@ -62,7 +62,7 @@ function get_npm_arch {
 | 
	
		
			
			| 62 | 62 |  
 | 
	
		
			
			| 63 | 63 |  function mesh_install_nodejs {
 | 
	
		
			
			| 64 | 64 |      mesh_install_nodejs_prefix=
 | 
	
		
			
			| 65 |  | -    if [ $rootdir ]; then
 | 
	
		
			
			|  | 65 | +    if [ "$rootdir" ]; then
 | 
	
		
			
			| 66 | 66 |          mesh_install_nodejs_prefix="chroot $rootdir"
 | 
	
		
			
			| 67 | 67 |      fi
 | 
	
		
			
			| 68 | 68 |  
 | 
	
	
		
			
			|  | @@ -70,46 +70,46 @@ function mesh_install_nodejs {
 | 
	
		
			
			| 70 | 70 |      $mesh_install_nodejs_prefix apt-get -yq install libxext-dev libxtst-dev libxkbfile-dev
 | 
	
		
			
			| 71 | 71 |      $mesh_install_nodejs_prefix apt-get -yq install apt-transport-https
 | 
	
		
			
			| 72 | 72 |      $mesh_install_nodejs_prefix wget https://deb.nodesource.com/gpgkey/nodesource.gpg.key -O /root/node.gpg.key
 | 
	
		
			
			| 73 |  | -    if [ ! -f $rootdir/root/node.gpg.key ]; then
 | 
	
		
			
			|  | 73 | +    if [ ! -f "$rootdir/root/node.gpg.key" ]; then
 | 
	
		
			
			| 74 | 74 |          echo $'Unable to obtain gpg key for nodejs repo'
 | 
	
		
			
			| 75 | 75 |          exit 6389252
 | 
	
		
			
			| 76 | 76 |      fi
 | 
	
		
			
			| 77 | 77 |      $mesh_install_nodejs_prefix apt-key add /root/node.gpg.key
 | 
	
		
			
			| 78 |  | -    echo "deb https://deb.nodesource.com/node_6.x stretch main" > $rootdir/etc/apt/sources.list.d/nodesource.list
 | 
	
		
			
			| 79 |  | -    echo "deb-src https://deb.nodesource.com/node_6.x stretch main" >> $rootdir/etc/apt/sources.list.d/nodesource.list
 | 
	
		
			
			|  | 78 | +    echo "deb https://deb.nodesource.com/node_6.x stretch main" > "$rootdir/etc/apt/sources.list.d/nodesource.list"
 | 
	
		
			
			|  | 79 | +    echo "deb-src https://deb.nodesource.com/node_6.x stretch main" >> "$rootdir/etc/apt/sources.list.d/nodesource.list"
 | 
	
		
			
			| 80 | 80 |  
 | 
	
		
			
			| 81 | 81 |      $mesh_install_nodejs_prefix apt-get update
 | 
	
		
			
			| 82 | 82 |      $mesh_install_nodejs_prefix apt-get -yq remove --purge nodejs
 | 
	
		
			
			| 83 | 83 |  
 | 
	
		
			
			| 84 |  | -    if [ -d $rootdir/usr/local/lib/node_modules ]; then
 | 
	
		
			
			| 85 |  | -        rm -rf $rootdir/usr/local/lib/node_modules
 | 
	
		
			
			|  | 84 | +    if [ -d "$rootdir/usr/local/lib/node_modules" ]; then
 | 
	
		
			
			|  | 85 | +        rm -rf "$rootdir/usr/local/lib/node_modules"
 | 
	
		
			
			| 86 | 86 |      fi
 | 
	
		
			
			| 87 |  | -    if [ -f $rootdir/usr/local/bin/node ]; then
 | 
	
		
			
			| 88 |  | -        rm $rootdir/usr/local/bin/node
 | 
	
		
			
			|  | 87 | +    if [ -f "$rootdir/usr/local/bin/node" ]; then
 | 
	
		
			
			|  | 88 | +        rm "$rootdir/usr/local/bin/node"
 | 
	
		
			
			| 89 | 89 |      fi
 | 
	
		
			
			| 90 |  | -    if [ -f $rootdir/usr/bin/node ]; then
 | 
	
		
			
			|  | 90 | +    if [ -f "$rootdir/usr/bin/node" ]; then
 | 
	
		
			
			| 91 | 91 |          rm /usr/bin/node
 | 
	
		
			
			| 92 | 92 |      fi
 | 
	
		
			
			| 93 |  | -    if [ -f $rootdir/usr/bin/nodejs ]; then
 | 
	
		
			
			| 94 |  | -        rm $rootdir/usr/bin/nodejs
 | 
	
		
			
			|  | 93 | +    if [ -f "$rootdir/usr/bin/nodejs" ]; then
 | 
	
		
			
			|  | 94 | +        rm "$rootdir/usr/bin/nodejs"
 | 
	
		
			
			| 95 | 95 |      fi
 | 
	
		
			
			| 96 | 96 |  
 | 
	
		
			
			| 97 | 97 |      $mesh_install_nodejs_prefix apt-get -yq install nodejs
 | 
	
		
			
			| 98 | 98 |  
 | 
	
		
			
			| 99 |  | -    if [ -f $rootdir/usr/bin/nodejs ]; then
 | 
	
		
			
			| 100 |  | -        cp $rootdir/usr/bin/nodejs $rootdir/usr/bin/node
 | 
	
		
			
			|  | 99 | +    if [ -f "$rootdir/usr/bin/nodejs" ]; then
 | 
	
		
			
			|  | 100 | +        cp "$rootdir/usr/bin/nodejs" "$rootdir/usr/bin/node"
 | 
	
		
			
			| 101 | 101 |      fi
 | 
	
		
			
			| 102 | 102 |  
 | 
	
		
			
			| 103 |  | -    if [ ! -f ${rootdir}/usr/bin/node ]; then
 | 
	
		
			
			| 104 |  | -        if [ ! -f ${rootdir}/usr/local/bin/node ]; then
 | 
	
		
			
			| 105 |  | -            if [ ! -f ${rootdir}/usr/bin/nodejs ]; then
 | 
	
		
			
			|  | 103 | +    if [ ! -f "${rootdir}/usr/bin/node" ]; then
 | 
	
		
			
			|  | 104 | +        if [ ! -f "${rootdir}/usr/local/bin/node" ]; then
 | 
	
		
			
			|  | 105 | +            if [ ! -f "${rootdir}/usr/bin/nodejs" ]; then
 | 
	
		
			
			| 106 | 106 |                  echo $'nodejs was not installed'
 | 
	
		
			
			| 107 | 107 |                  exit 63962
 | 
	
		
			
			| 108 | 108 |              fi
 | 
	
		
			
			| 109 | 109 |          fi
 | 
	
		
			
			| 110 | 110 |      fi
 | 
	
		
			
			| 111 | 111 |  
 | 
	
		
			
			| 112 |  | -    if [ ! -f $rootdir/usr/bin/node ]; then
 | 
	
		
			
			|  | 112 | +    if [ ! -f "$rootdir/usr/bin/node" ]; then
 | 
	
		
			
			| 113 | 113 |          echo $'/usr/bin/node not found'
 | 
	
		
			
			| 114 | 114 |          exit 7235728
 | 
	
		
			
			| 115 | 115 |      fi
 | 
	
	
		
			
			|  | @@ -118,25 +118,25 @@ function mesh_install_nodejs {
 | 
	
		
			
			| 118 | 118 |  
 | 
	
		
			
			| 119 | 119 |      $mesh_install_nodejs_prefix npm config set unsafe-perm true
 | 
	
		
			
			| 120 | 120 |      $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g npm@${NPM_VERSION} --save
 | 
	
		
			
			| 121 |  | -    if [ -f $rootdir/usr/local/bin/npm ]; then
 | 
	
		
			
			| 122 |  | -        cp $rootdir/usr/local/bin/npm /usr/bin/npm
 | 
	
		
			
			|  | 121 | +    if [ -f "$rootdir/usr/local/bin/npm" ]; then
 | 
	
		
			
			|  | 122 | +        cp "$rootdir/usr/local/bin/npm" /usr/bin/npm
 | 
	
		
			
			| 123 | 123 |      fi
 | 
	
		
			
			| 124 |  | -    cp $rootdir/usr/bin/npm $rootdir/root/npm
 | 
	
		
			
			|  | 124 | +    cp "$rootdir/usr/bin/npm" "$rootdir/root/npm"
 | 
	
		
			
			| 125 | 125 |  
 | 
	
		
			
			| 126 | 126 |      # update from the old debian nodejs version
 | 
	
		
			
			| 127 | 127 |      $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save
 | 
	
		
			
			| 128 | 128 |      $mesh_install_nodejs_prefix n --arch $N_ARCH ${NODEJS_VERSION}
 | 
	
		
			
			| 129 |  | -    cp $rootdir/root/npm $rootdir/usr/bin/npm
 | 
	
		
			
			|  | 129 | +    cp "$rootdir/root/npm" "$rootdir/usr/bin/npm"
 | 
	
		
			
			| 130 | 130 |  
 | 
	
		
			
			| 131 | 131 |      # deliberate second install of npm
 | 
	
		
			
			| 132 | 132 |      $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g npm@${NPM_VERSION} --save
 | 
	
		
			
			| 133 |  | -    if [ -f $rootdir/usr/local/bin/npm ]; then
 | 
	
		
			
			| 134 |  | -        cp $rootdir/usr/local/bin/npm /usr/bin/npm
 | 
	
		
			
			|  | 133 | +    if [ -f "$rootdir/usr/local/bin/npm" ]; then
 | 
	
		
			
			|  | 134 | +        cp "$rootdir/usr/local/bin/npm" /usr/bin/npm
 | 
	
		
			
			| 135 | 135 |      fi
 | 
	
		
			
			| 136 |  | -    cp $rootdir/usr/bin/npm $rootdir/root/npm
 | 
	
		
			
			|  | 136 | +    cp "$rootdir/usr/bin/npm" "$rootdir/root/npm"
 | 
	
		
			
			| 137 | 137 |  
 | 
	
		
			
			| 138 | 138 |      # check the version numbers
 | 
	
		
			
			| 139 |  | -    cat <<EOF > $rootdir/usr/bin/test_nodejs_install
 | 
	
		
			
			|  | 139 | +    cat <<EOF > "$rootdir/usr/bin/test_nodejs_install"
 | 
	
		
			
			| 140 | 140 |  #!/bin/bash
 | 
	
		
			
			| 141 | 141 |  node_version=\$(node -v)
 | 
	
		
			
			| 142 | 142 |  if [[ "\$node_version" != "v${NODEJS_VERSION}" ]]; then
 | 
	
	
		
			
			|  | @@ -149,25 +149,24 @@ if [[ "\$npm_version" != "${NPM_VERSION}" ]]; then
 | 
	
		
			
			| 149 | 149 |      exit 2
 | 
	
		
			
			| 150 | 150 |  fi
 | 
	
		
			
			| 151 | 151 |  EOF
 | 
	
		
			
			| 152 |  | -    chmod +x $rootdir/usr/bin/test_nodejs_install
 | 
	
		
			
			| 153 |  | -    $mesh_install_nodejs_prefix /usr/bin/test_nodejs_install
 | 
	
		
			
			| 154 |  | -    if [ ! "$?" = "0" ]; then
 | 
	
		
			
			|  | 152 | +    chmod +x "$rootdir/usr/bin/test_nodejs_install"
 | 
	
		
			
			|  | 153 | +    if ! $mesh_install_nodejs_prefix /usr/bin/test_nodejs_install; then
 | 
	
		
			
			| 155 | 154 |          echo $"nodejs version numbers did not match. Architecture is $NPM_ARCH."
 | 
	
		
			
			| 156 | 155 |          exit 76835282
 | 
	
		
			
			| 157 | 156 |      fi
 | 
	
		
			
			| 158 |  | -    rm $rootdir/usr/bin/test_nodejs_install
 | 
	
		
			
			|  | 157 | +    rm "$rootdir/usr/bin/test_nodejs_install"
 | 
	
		
			
			| 159 | 158 |  }
 | 
	
		
			
			| 160 | 159 |  
 | 
	
		
			
			| 161 | 160 |  function remove_nodejs {
 | 
	
		
			
			| 162 |  | -    if [ ! $1 ]; then
 | 
	
		
			
			|  | 161 | +    if [ ! "$1" ]; then
 | 
	
		
			
			| 163 | 162 |          return
 | 
	
		
			
			| 164 | 163 |      fi
 | 
	
		
			
			| 165 |  | -    if [ ! -f $NODEJS_INSTALLED_APPS_FILE ]; then
 | 
	
		
			
			|  | 164 | +    if [ ! -f "$NODEJS_INSTALLED_APPS_FILE" ]; then
 | 
	
		
			
			| 166 | 165 |          #remove_app nodejs
 | 
	
		
			
			| 167 | 166 |          return
 | 
	
		
			
			| 168 | 167 |      fi
 | 
	
		
			
			| 169 |  | -    sed -i "/install_${1}/d" $NODEJS_INSTALLED_APPS_FILE
 | 
	
		
			
			| 170 |  | -    if ! grep -q "install_" $NODEJS_INSTALLED_APPS_FILE; then
 | 
	
		
			
			|  | 168 | +    sed -i "/install_${1}/d" "$NODEJS_INSTALLED_APPS_FILE"
 | 
	
		
			
			|  | 169 | +    if ! grep -q "install_" "$NODEJS_INSTALLED_APPS_FILE"; then
 | 
	
		
			
			| 171 | 170 |          apt-get -yq remove --purge nodejs
 | 
	
		
			
			| 172 | 171 |  
 | 
	
		
			
			| 173 | 172 |          if [ -f /usr/bin/nodejs ]; then
 | 
	
	
		
			
			|  | @@ -188,7 +187,7 @@ function remove_nodejs {
 | 
	
		
			
			| 188 | 187 |  
 | 
	
		
			
			| 189 | 188 |          remove_app nodejs
 | 
	
		
			
			| 190 | 189 |  
 | 
	
		
			
			| 191 |  | -        rm $NODEJS_INSTALLED_APPS_FILE
 | 
	
		
			
			|  | 190 | +        rm "$NODEJS_INSTALLED_APPS_FILE"
 | 
	
		
			
			| 192 | 191 |  
 | 
	
		
			
			| 193 | 192 |          apt-get -yq autoremove
 | 
	
		
			
			| 194 | 193 |      fi
 | 
	
	
		
			
			|  | @@ -218,7 +217,7 @@ function upgrade_nodejs {
 | 
	
		
			
			| 218 | 217 |  }
 | 
	
		
			
			| 219 | 218 |  
 | 
	
		
			
			| 220 | 219 |  function install_nodejs {
 | 
	
		
			
			| 221 |  | -    if [ $INSTALLING_MESH ]; then
 | 
	
		
			
			|  | 220 | +    if [ "$INSTALLING_MESH" ]; then
 | 
	
		
			
			| 222 | 221 |          mesh_install_nodejs
 | 
	
		
			
			| 223 | 222 |          return
 | 
	
		
			
			| 224 | 223 |      fi
 | 
	
	
		
			
			|  | @@ -227,7 +226,7 @@ function install_nodejs {
 | 
	
		
			
			| 227 | 226 |          return
 | 
	
		
			
			| 228 | 227 |      fi
 | 
	
		
			
			| 229 | 228 |  
 | 
	
		
			
			| 230 |  | -    if [ ! $ARCHITECTURE ]; then
 | 
	
		
			
			|  | 229 | +    if [ ! "$ARCHITECTURE" ]; then
 | 
	
		
			
			| 231 | 230 |          ARCHITECTURE=$(uname -m)
 | 
	
		
			
			| 232 | 231 |      fi
 | 
	
		
			
			| 233 | 232 |      rootdir=
 | 
	
	
		
			
			|  | @@ -250,9 +249,9 @@ function install_nodejs {
 | 
	
		
			
			| 250 | 249 |          exit 5274527
 | 
	
		
			
			| 251 | 250 |      fi
 | 
	
		
			
			| 252 | 251 |  
 | 
	
		
			
			| 253 |  | -    if [ $1 ]; then
 | 
	
		
			
			| 254 |  | -        if ! grep -q "install_${1}" $NODEJS_INSTALLED_APPS_FILE; then
 | 
	
		
			
			| 255 |  | -            echo "install_${1}" >> $NODEJS_INSTALLED_APPS_FILE
 | 
	
		
			
			|  | 252 | +    if [ "$1" ]; then
 | 
	
		
			
			|  | 253 | +        if ! grep -q "install_${1}" "$NODEJS_INSTALLED_APPS_FILE"; then
 | 
	
		
			
			|  | 254 | +            echo "install_${1}" >> "$NODEJS_INSTALLED_APPS_FILE"
 | 
	
		
			
			| 256 | 255 |          fi
 | 
	
		
			
			| 257 | 256 |      fi
 | 
	
		
			
			| 258 | 257 |  
 |