Commit 304bdfbe authored by Leo Iannacone's avatar Leo Iannacone

do not require the coffee file, but try to evaluate it - allow users to...

do not require the coffee file, but try to evaluate it - allow users to specify config files with no .coffee extension
parent 290fce24
......@@ -40,7 +40,7 @@ sudo npm install -g coffee-script
Take a look at auto-generated **user.config.coffee**. Edit as you wish and then run service with:
```
coffee debomatic-webui -c user.config.coffee
coffee debomatic-webui -c user.config
```
That's all.
......@@ -2,8 +2,11 @@
Please DO NOT edit this file.
Edit auto-generated 'user.config.coffee' file instead.
###
fs = require('fs')
extend = require('extend')
crypto = require('crypto')
cseval = require('coffee-script').eval
Parser = require("./parser")
#start config-auto-export
###
......@@ -127,12 +130,13 @@ config.status.fail = false
# Merge the configuration
try
Parser = require("./parser")
parser = new Parser()
user_config = parser.getUserConfig()
if user_config
console.log "Reading user configutation ..."
config = extend(true, config, require(user_config))
data = fs.readFileSync(user_config, 'utf8')
user_config_content = cseval(data + "\nmodule.exports = config")
config = extend(true, config, user_config_content)
else
console.log "No user config specified. Using global settings."
......@@ -144,15 +148,17 @@ try
# get the debomatic pidfile
config.debomatic.pidfile = "/var/run/debomatic-" +
require("crypto")
.createHash("sha256")
crypto.createHash("sha256")
.update(config.debomatic.path)
.digest("hex")
module.exports = config
catch err
if err.code is "MODULE_NOT_FOUND"
console.log "File %s not found.", user_config
if err.code is 'ENOENT'
console.error 'File "%s" not found', user_config
else if err.code is 'EISDIR'
console.error 'File "%s" is a directory', user_config
else
console.error "Error reading user configutation", err
console.error "Error reading user configutation:"
console.error err
process.exit 2
......@@ -7,7 +7,7 @@ import os
base_path = os.environ['SCRIPTS_DIR']
global_config_file = os.path.join(base_path, '../lib/config.coffee')
user_config_file = os.path.join(base_path, '../user.config.coffee')
user_config_file = os.path.join(base_path, '../user.config')
if os.path.isfile(user_config_file):
print ("A config user file already exists. Skipping creation.")
......@@ -31,9 +31,6 @@ with open(global_config_file) as fd:
if start:
export_config.append(line)
export_config.append('# DO NOT EDIT THIS LINE:\n')
export_config.append('module.exports = config\n')
print ("Creating user configuration ...")
with open(user_config_file, 'w') as fd:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment