mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
Merge f409914ff2
into 10cbb485fb
This commit is contained in:
commit
e561436b60
5 changed files with 82 additions and 9 deletions
|
@ -40,10 +40,17 @@ if [ ! $(echo $NODE_VERSION | cut -d "." -f 1-2) = "v0.6" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Does a settings.json exist? if no copy the template
|
#Get the name of the settings file
|
||||||
if [ ! -f "settings.json" ]; then
|
settings="settings.json"
|
||||||
echo "Copy the settings template to settings.json..."
|
a='';
|
||||||
cp -v settings.json.template settings.json || exit 1
|
for arg in $*; do
|
||||||
|
if [ "$a" = "--settings" ] || [ "$a" = "-s" ]; then settings=$arg; fi
|
||||||
|
a=$arg
|
||||||
|
done
|
||||||
|
#Does a $settings exist? if no copy the template
|
||||||
|
if [ ! -f $settings ]; then
|
||||||
|
echo "Copy the settings template to $settings..."
|
||||||
|
cp -v settings.json.template $settings || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Ensure that all dependencies are up to date..."
|
echo "Ensure that all dependencies are up to date..."
|
||||||
|
|
14
bin/run.sh
14
bin/run.sh
|
@ -20,10 +20,18 @@ if [ "$(id -u)" -eq 0 ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
prep=1
|
||||||
|
#If merely looking for help, don't prep the environment
|
||||||
|
for arg in $*; do
|
||||||
|
if [ "$arg" = "--help" ] || [ "$arg" = "-h" ]; then prep=0; fi
|
||||||
|
done
|
||||||
|
|
||||||
#prepare the enviroment
|
#prepare the enviroment
|
||||||
bin/installDeps.sh || exit 1
|
if [ $prep -eq 1 ]; then
|
||||||
|
bin/installDeps.sh $* || exit 1
|
||||||
|
echo "start..."
|
||||||
|
fi
|
||||||
|
|
||||||
#Move to the node folder and start
|
#Move to the node folder and start
|
||||||
echo "start..."
|
|
||||||
cd "node"
|
cd "node"
|
||||||
node server.js
|
node server.js $*
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var cli = require('./utils/Cli');
|
||||||
var ERR = require("async-stacktrace");
|
var ERR = require("async-stacktrace");
|
||||||
var log4js = require('log4js');
|
var log4js = require('log4js');
|
||||||
var os = require("os");
|
var os = require("os");
|
||||||
|
|
53
node/utils/Cli.js
Normal file
53
node/utils/Cli.js
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/**
|
||||||
|
* The CLI module handles command line parameters
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 2012 Jordan Hollinger
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an
|
||||||
|
"AS-IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// The help text
|
||||||
|
exports.helpText = '\
|
||||||
|
run.sh [OPTIONS] \n\
|
||||||
|
\n\
|
||||||
|
OPTIONS \n\
|
||||||
|
-s|--settings FILE Specifies the settings.json file\n\
|
||||||
|
-h|--help Print this message and exit \n\
|
||||||
|
';
|
||||||
|
|
||||||
|
// An object containing the parsed command-line options
|
||||||
|
exports.argv = {};
|
||||||
|
|
||||||
|
var argv = process.argv.slice(2);
|
||||||
|
var arg, prevArg;
|
||||||
|
|
||||||
|
// Loop through args
|
||||||
|
for ( var i = 0; i < argv.length; i++ ) {
|
||||||
|
arg = argv[i];
|
||||||
|
|
||||||
|
// Override location of settings.json file
|
||||||
|
if ( prevArg == '--settings' || prevArg == '-s' ) {
|
||||||
|
exports.argv.settings = arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print help and exit
|
||||||
|
else if ( arg == '--help' || arg == '-h' ) {
|
||||||
|
console.log(exports.helpText);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
prevArg = arg;
|
||||||
|
}
|
|
@ -22,6 +22,7 @@
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var os = require("os");
|
var os = require("os");
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var cli = require('./Cli');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The IP ep-lite should listen to
|
* The IP ep-lite should listen to
|
||||||
|
@ -88,9 +89,12 @@ exports.abiwordAvailable = function()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Discover where the settings file lives
|
||||||
|
var settingsFilename = cli.argv.settings || "settings.json";
|
||||||
|
var settingsPath = settingsFilename.charAt(0) == '/' ? '' : path.normalize(__dirname + "/../../");
|
||||||
|
|
||||||
//read the settings sync
|
//read the settings sync
|
||||||
var settingsPath = path.normalize(__dirname + "/../../");
|
var settingsStr = fs.readFileSync(settingsPath + settingsFilename).toString();
|
||||||
var settingsStr = fs.readFileSync(settingsPath + "settings.json").toString();
|
|
||||||
|
|
||||||
//remove all comments
|
//remove all comments
|
||||||
settingsStr = settingsStr.replace(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/gm,"").replace(/#.*/g,"").replace(/\/\/.*/g,"");
|
settingsStr = settingsStr.replace(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/gm,"").replace(/#.*/g,"").replace(/\/\/.*/g,"");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue