github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/scripts/konnector-node-run.sh (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  NODE_BIN="$(command -v nodejs || true)"
     5  if [ -z "${NODE_BIN}" ]; then
     6    NODE_BIN="$(command -v node || true)"
     7  fi
     8  
     9  if ! [ -x "${NODE_BIN}" ]; then
    10    >&2 echo "Unable to find nodejs binary, exiting..."
    11    exit 1
    12  fi
    13  
    14  NODE_VERSION="$(${NODE_BIN} --version)"
    15  if [ "${NODE_VERSION%%.*}" = "v12" ]; then
    16    NODE_OPTS="--max-http-header-size=16384 --tls-min-v1.0 --http-parser=legacy"
    17  else
    18    NODE_OPTS=""
    19  fi
    20  
    21  arg="${1}"
    22  
    23  if [ ! -f "${arg}" ] && [ ! -d "${arg}" ]; then
    24    >&2 echo "${arg} does not exist"
    25    exit 1
    26  fi
    27  
    28  ${NODE_BIN} ${NODE_OPTS} "${arg}"