2011-07-31 16:37:50 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-07-28 21:23:39 +00:00
|
|
|
# minimum required node version
|
2020-04-08 21:22:13 +00:00
|
|
|
REQUIRED_NODE_MAJOR=10
|
|
|
|
REQUIRED_NODE_MINOR=13
|
2018-07-28 21:23:39 +00:00
|
|
|
|
|
|
|
# minimum required npm version
|
2019-10-19 20:38:32 +00:00
|
|
|
REQUIRED_NPM_MAJOR=5
|
|
|
|
REQUIRED_NPM_MINOR=5
|
2018-07-28 21:23:39 +00:00
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
pecho() { printf %s\\n "$*"; }
|
|
|
|
log() { pecho "$@"; }
|
|
|
|
error() { log "ERROR: $@" >&2; }
|
|
|
|
fatal() { error "$@"; exit 1; }
|
|
|
|
is_cmd() { command -v "$@" >/dev/null 2>&1; }
|
|
|
|
|
2018-07-28 21:23:39 +00:00
|
|
|
require_minimal_version() {
|
|
|
|
PROGRAM_LABEL="$1"
|
|
|
|
VERSION_STRING="$2"
|
|
|
|
REQUIRED_MAJOR="$3"
|
|
|
|
REQUIRED_MINOR="$4"
|
|
|
|
|
2018-07-31 10:44:17 +00:00
|
|
|
# Flag -s (--only-delimited on GNU cut) ensures no string is returned
|
|
|
|
# when there is no match
|
2020-06-01 20:02:44 +00:00
|
|
|
DETECTED_MAJOR=$(pecho "$VERSION_STRING" | cut -s -d "." -f 1)
|
|
|
|
DETECTED_MINOR=$(pecho "$VERSION_STRING" | cut -s -d "." -f 2)
|
2018-07-28 21:23:39 +00:00
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
[ -n "$DETECTED_MAJOR" ] || fatal "Cannot extract $PROGRAM_LABEL major version from version string \"$VERSION_STRING\""
|
2018-07-28 21:23:39 +00:00
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
[ -n "$DETECTED_MINOR" ] || fatal "Cannot extract $PROGRAM_LABEL minor version from version string \"$VERSION_STRING\""
|
2018-07-28 21:23:39 +00:00
|
|
|
|
|
|
|
case "$DETECTED_MAJOR" in
|
|
|
|
''|*[!0-9]*)
|
2020-06-01 20:02:44 +00:00
|
|
|
fatal "$PROGRAM_LABEL major version from \"$VERSION_STRING\" is not a number. Detected: \"$DETECTED_MAJOR\""
|
2018-07-28 21:23:39 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$DETECTED_MINOR" in
|
|
|
|
''|*[!0-9]*)
|
2020-06-01 20:02:44 +00:00
|
|
|
fatal "$PROGRAM_LABEL minor version from \"$VERSION_STRING\" is not a number. Detected: \"$DETECTED_MINOR\""
|
2018-07-28 21:23:39 +00:00
|
|
|
esac
|
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
[ "$DETECTED_MAJOR" -gt "$REQUIRED_MAJOR" ] || ([ "$DETECTED_MAJOR" -eq "$REQUIRED_MAJOR" ] && [ "$DETECTED_MINOR" -ge "$REQUIRED_MINOR" ]) \
|
|
|
|
|| fatal "Your $PROGRAM_LABEL version \"$VERSION_STRING\" is too old. $PROGRAM_LABEL $REQUIRED_MAJOR.$REQUIRED_MINOR.x or higher is required."
|
2018-07-28 21:23:39 +00:00
|
|
|
}
|
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
# Move to the folder where ep-lite is installed
|
|
|
|
cd "$(dirname "$0")"/..
|
2011-07-27 13:37:12 +00:00
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
# Is node installed?
|
|
|
|
# Not checking io.js, default installation creates a symbolic link to node
|
|
|
|
is_cmd node || fatal "Please install node.js ( https://nodejs.org )"
|
2011-07-27 13:37:12 +00:00
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
# Is npm installed?
|
|
|
|
is_cmd npm || fatal "Please install npm ( https://npmjs.org )"
|
2011-07-27 13:37:12 +00:00
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
# Check npm version
|
2018-07-28 21:23:39 +00:00
|
|
|
NPM_VERSION_STRING=$(npm --version)
|
|
|
|
|
|
|
|
require_minimal_version "npm" "$NPM_VERSION_STRING" "$REQUIRED_NPM_MAJOR" "$REQUIRED_NPM_MINOR"
|
2011-08-11 14:09:05 +00:00
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
# Check node version
|
2018-07-28 21:23:39 +00:00
|
|
|
NODE_VERSION_STRING=$(node --version)
|
|
|
|
NODE_VERSION_STRING=${NODE_VERSION_STRING#"v"}
|
|
|
|
|
|
|
|
require_minimal_version "nodejs" "$NODE_VERSION_STRING" "$REQUIRED_NODE_MAJOR" "$REQUIRED_NODE_MINOR"
|
2012-01-26 11:55:54 +00:00
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
# Get the name of the settings file
|
2012-02-21 19:20:45 +00:00
|
|
|
settings="settings.json"
|
|
|
|
a='';
|
2019-12-01 00:52:32 +00:00
|
|
|
for arg in "$@"; do
|
2012-02-21 19:20:45 +00:00
|
|
|
if [ "$a" = "--settings" ] || [ "$a" = "-s" ]; then settings=$arg; fi
|
|
|
|
a=$arg
|
|
|
|
done
|
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
# Does a $settings exist? if not copy the template
|
|
|
|
if [ ! -f "$settings" ]; then
|
|
|
|
log "Copy the settings template to $settings..."
|
|
|
|
cp settings.json.template "$settings" || exit 1
|
2011-07-27 13:37:12 +00:00
|
|
|
fi
|
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
log "Ensure that all dependencies are up to date... If this is the first time you have run Etherpad please be patient."
|
2012-02-26 12:31:47 +00:00
|
|
|
(
|
|
|
|
mkdir -p node_modules
|
|
|
|
cd node_modules
|
2012-02-26 12:54:32 +00:00
|
|
|
[ -e ep_etherpad-lite ] || ln -s ../src ep_etherpad-lite
|
|
|
|
cd ep_etherpad-lite
|
2020-04-26 22:33:19 +00:00
|
|
|
npm ci
|
2015-01-21 12:18:38 +00:00
|
|
|
) || {
|
2018-08-29 19:45:33 +00:00
|
|
|
rm -rf src/node_modules
|
2015-01-21 12:18:38 +00:00
|
|
|
exit 1
|
2011-08-09 10:14:09 +00:00
|
|
|
}
|
2011-07-27 13:37:12 +00:00
|
|
|
|
2020-06-01 20:02:44 +00:00
|
|
|
# Remove all minified data to force node creating it new
|
|
|
|
log "Clearing minified cache..."
|
2011-07-27 13:37:12 +00:00
|
|
|
rm -f var/minified*
|
|
|
|
|
|
|
|
exit 0
|