mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 17:36:14 -04:00
Revert "scripts: Various shell script cleanups (#4008)"
This reverts commit fba4fd5314
.
The series of commits I made for PR #4008 were squashed into a single
commit and rebased. Somewhere along the way a mistake was made in a
merge conflict resolution, resulting in some bad code in
`bin/buildForWindows.sh`. This commit reverts the bad squashed commit.
This commit is contained in:
parent
02af7d0c2d
commit
9ffb2ccfb0
5 changed files with 132 additions and 129 deletions
|
@ -8,12 +8,6 @@ REQUIRED_NODE_MINOR=13
|
|||
REQUIRED_NPM_MAJOR=5
|
||||
REQUIRED_NPM_MINOR=5
|
||||
|
||||
pecho() { printf %s\\n "$*"; }
|
||||
log() { pecho "$@"; }
|
||||
error() { log "ERROR: $@" >&2; }
|
||||
fatal() { error "$@"; exit 1; }
|
||||
is_cmd() { command -v "$@" >/dev/null 2>&1; }
|
||||
|
||||
require_minimal_version() {
|
||||
PROGRAM_LABEL="$1"
|
||||
VERSION_STRING="$2"
|
||||
|
@ -22,50 +16,71 @@ require_minimal_version() {
|
|||
|
||||
# Flag -s (--only-delimited on GNU cut) ensures no string is returned
|
||||
# when there is no match
|
||||
DETECTED_MAJOR=$(pecho "$VERSION_STRING" | cut -s -d "." -f 1)
|
||||
DETECTED_MINOR=$(pecho "$VERSION_STRING" | cut -s -d "." -f 2)
|
||||
DETECTED_MAJOR=$(echo $VERSION_STRING | cut -s -d "." -f 1)
|
||||
DETECTED_MINOR=$(echo $VERSION_STRING | cut -s -d "." -f 2)
|
||||
|
||||
[ -n "$DETECTED_MAJOR" ] || fatal "Cannot extract $PROGRAM_LABEL major version from version string \"$VERSION_STRING\""
|
||||
if [ -z "$DETECTED_MAJOR" ]; then
|
||||
printf 'Cannot extract %s major version from version string "%s"\n' "$PROGRAM_LABEL" "$VERSION_STRING" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -n "$DETECTED_MINOR" ] || fatal "Cannot extract $PROGRAM_LABEL minor version from version string \"$VERSION_STRING\""
|
||||
if [ -z "$DETECTED_MINOR" ]; then
|
||||
printf 'Cannot extract %s minor version from version string "%s"\n' "$PROGRAM_LABEL" "$VERSION_STRING" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$DETECTED_MAJOR" in
|
||||
''|*[!0-9]*)
|
||||
fatal "$PROGRAM_LABEL major version from \"$VERSION_STRING\" is not a number. Detected: \"$DETECTED_MAJOR\""
|
||||
printf '%s major version from "%s" is not a number. Detected: "%s"\n' "$PROGRAM_LABEL" "$VERSION_STRING" "$DETECTED_MAJOR" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$DETECTED_MINOR" in
|
||||
''|*[!0-9]*)
|
||||
fatal "$PROGRAM_LABEL minor version from \"$VERSION_STRING\" is not a number. Detected: \"$DETECTED_MINOR\""
|
||||
printf '%s minor version from "%s" is not a number. Detected: "%s"\n' "$PROGRAM_LABEL" "$VERSION_STRING" "$DETECTED_MINOR" >&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
[ "$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."
|
||||
if [ "$DETECTED_MAJOR" -lt "$REQUIRED_MAJOR" ] || ([ "$DETECTED_MAJOR" -eq "$REQUIRED_MAJOR" ] && [ "$DETECTED_MINOR" -lt "$REQUIRED_MINOR" ]); then
|
||||
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
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Move to the folder where ep-lite is installed
|
||||
cd "$(dirname "$0")"/..
|
||||
#Move to the folder where ep-lite is installed
|
||||
cd $(dirname $0)
|
||||
|
||||
# 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 )"
|
||||
#Was this script started in the bin folder? if yes move out
|
||||
if [ -d "../bin" ]; then
|
||||
cd "../"
|
||||
fi
|
||||
|
||||
# Is npm installed?
|
||||
is_cmd npm || fatal "Please install npm ( https://npmjs.org )"
|
||||
#Is node installed?
|
||||
#Not checking io.js, default installation creates a symbolic link to node
|
||||
hash node > /dev/null 2>&1 || {
|
||||
echo "Please install node.js ( https://nodejs.org )" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check npm version
|
||||
#Is npm installed?
|
||||
hash npm > /dev/null 2>&1 || {
|
||||
echo "Please install npm ( https://npmjs.org )" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
#Check npm version
|
||||
NPM_VERSION_STRING=$(npm --version)
|
||||
|
||||
require_minimal_version "npm" "$NPM_VERSION_STRING" "$REQUIRED_NPM_MAJOR" "$REQUIRED_NPM_MINOR"
|
||||
|
||||
# Check node version
|
||||
#Check node version
|
||||
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"
|
||||
|
||||
# Get the name of the settings file
|
||||
#Get the name of the settings file
|
||||
settings="settings.json"
|
||||
a='';
|
||||
for arg in "$@"; do
|
||||
|
@ -73,13 +88,13 @@ for arg in "$@"; do
|
|||
a=$arg
|
||||
done
|
||||
|
||||
# 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
|
||||
#Does a $settings exist? if not copy the template
|
||||
if [ ! -f $settings ]; then
|
||||
echo "Copy the settings template to $settings..."
|
||||
cp settings.json.template $settings || exit 1
|
||||
fi
|
||||
|
||||
log "Ensure that all dependencies are up to date... If this is the first time you have run Etherpad please be patient."
|
||||
echo "Ensure that all dependencies are up to date... If this is the first time you have run Etherpad please be patient."
|
||||
(
|
||||
mkdir -p node_modules
|
||||
cd node_modules
|
||||
|
@ -91,8 +106,8 @@ log "Ensure that all dependencies are up to date... If this is the first time y
|
|||
exit 1
|
||||
}
|
||||
|
||||
# Remove all minified data to force node creating it new
|
||||
log "Clearing minified cache..."
|
||||
#Remove all minified data to force node creating it new
|
||||
echo "Clearing minified cache..."
|
||||
rm -f var/minified*
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue