"Fossies" - the Fresh Open Source Software Archive

Member "etherpad-lite-1.7.5/bin/installDeps.sh" (25 Jan 2019, 3238 Bytes) of package /linux/misc/etherpad-lite-1.7.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "installDeps.sh": 1.7.0_vs_1.7.5.

    1 #!/bin/sh
    2 
    3 # minimum required node version
    4 REQUIRED_NODE_MAJOR=6
    5 REQUIRED_NODE_MINOR=9
    6 
    7 # minimum required npm version
    8 REQUIRED_NPM_MAJOR=3
    9 REQUIRED_NPM_MINOR=10
   10 
   11 require_minimal_version() {
   12   PROGRAM_LABEL="$1"
   13   VERSION_STRING="$2"
   14   REQUIRED_MAJOR="$3"
   15   REQUIRED_MINOR="$4"
   16 
   17   # Flag -s (--only-delimited on GNU cut) ensures no string is returned
   18   # when there is no match
   19   DETECTED_MAJOR=$(echo $VERSION_STRING | cut -s -d "." -f 1)
   20   DETECTED_MINOR=$(echo $VERSION_STRING | cut -s -d "." -f 2)
   21 
   22   if [ -z "$DETECTED_MAJOR" ]; then
   23     printf 'Cannot extract %s major version from version string "%s"\n' "$PROGRAM_LABEL" "$VERSION_STRING" >&2
   24     exit 1
   25   fi
   26 
   27   if [ -z "$DETECTED_MINOR" ]; then
   28     printf 'Cannot extract %s minor version from version string "%s"\n' "$PROGRAM_LABEL" "$VERSION_STRING" >&2
   29     exit 1
   30   fi
   31 
   32   case "$DETECTED_MAJOR" in
   33       ''|*[!0-9]*)
   34         printf '%s major version from "%s" is not a number. Detected: "%s"\n' "$PROGRAM_LABEL" "$VERSION_STRING" "$DETECTED_MAJOR" >&2
   35         exit 1
   36         ;;
   37   esac
   38 
   39   case "$DETECTED_MINOR" in
   40       ''|*[!0-9]*)
   41         printf '%s minor version from "%s" is not a number. Detected: "%s"\n' "$PROGRAM_LABEL" "$VERSION_STRING" "$DETECTED_MINOR" >&2
   42         exit 1
   43   esac
   44 
   45   if [ "$DETECTED_MAJOR" -lt "$REQUIRED_MAJOR" ] || ([ "$DETECTED_MAJOR" -eq "$REQUIRED_MAJOR" ] && [ "$DETECTED_MINOR" -lt "$REQUIRED_MINOR" ]); then
   46     printf 'Your %s version "%s" is too old. %s %d.%d.x or higher is required.\n' "$PROGRAM_LABEL" "$VERSION_STRING" "$PROGRAM_LABEL" "$REQUIRED_MAJOR" "$REQUIRED_MINOR" >&2
   47     exit 1
   48   fi
   49 }
   50 
   51 #Move to the folder where ep-lite is installed
   52 cd `dirname $0`
   53 
   54 #Was this script started in the bin folder? if yes move out
   55 if [ -d "../bin" ]; then
   56   cd "../"
   57 fi
   58 
   59 #Is node installed?
   60 #Not checking io.js, default installation creates a symbolic link to node
   61 hash node > /dev/null 2>&1 || {
   62   echo "Please install node.js ( https://nodejs.org )" >&2
   63   exit 1
   64 }
   65 
   66 #Is npm installed?
   67 hash npm > /dev/null 2>&1 || {
   68   echo "Please install npm ( https://npmjs.org )" >&2
   69   exit 1
   70 }
   71 
   72 #Check npm version
   73 NPM_VERSION_STRING=$(npm --version)
   74 
   75 require_minimal_version "npm" "$NPM_VERSION_STRING" "$REQUIRED_NPM_MAJOR" "$REQUIRED_NPM_MINOR"
   76 
   77 #Check node version
   78 NODE_VERSION_STRING=$(node --version)
   79 NODE_VERSION_STRING=${NODE_VERSION_STRING#"v"}
   80 
   81 require_minimal_version "nodejs" "$NODE_VERSION_STRING" "$REQUIRED_NODE_MAJOR" "$REQUIRED_NODE_MINOR"
   82 
   83 #Get the name of the settings file
   84 settings="settings.json"
   85 a='';
   86 for arg in $*; do
   87   if [ "$a" = "--settings" ] || [ "$a" = "-s" ]; then settings=$arg; fi
   88   a=$arg
   89 done
   90 
   91 #Does a $settings exist? if not copy the template
   92 if [ ! -f $settings ]; then
   93   echo "Copy the settings template to $settings..."
   94   cp settings.json.template $settings || exit 1
   95 fi
   96 
   97 echo "Ensure that all dependencies are up to date...  If this is the first time you have run Etherpad please be patient."
   98 (
   99   mkdir -p node_modules
  100   cd node_modules
  101   [ -e ep_etherpad-lite ] || ln -s ../src ep_etherpad-lite
  102   cd ep_etherpad-lite
  103   npm install --no-save --loglevel warn
  104 ) || {
  105   rm -rf src/node_modules
  106   exit 1
  107 }
  108 
  109 #Remove all minified data to force node creating it new
  110 echo "Clearing minified cache..."
  111 rm -f var/minified*
  112 
  113 exit 0