Skip to content

Commit

Permalink
auto export user configuration on npm install
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoIannacone committed Mar 16, 2014
1 parent 08e8361 commit 272533f
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*/node_modules
debomatic-webui/public/external_libs
*/*/external_libs
*/user.config.js
19 changes: 15 additions & 4 deletions debomatic-webui/lib/config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
var config = {}
/*
* Please DO NOT edit this file.
*
* Edit auto-generated "user.config.js" file instead.
*
*/

config.version = '0.1-b1'
// #start config-auto-export
var config = {}

config.host = 'localhost'
config.port = 3000
config.user = 'www-data' // who will run server
config.user = 'www-data' // who will run server [not fully tested yet]

config.debomatic = {}
config.debomatic.path = '/srv/debomatic-amd64'
Expand Down Expand Up @@ -37,7 +43,12 @@ config.web.preferences.file_background = true
config.web.preferences.file_fontsize = 13 // valid values are [13..16]
config.web.preferences.debug = 0 // debug level - 0 means disabled

// DO NOT EDIT these ones
// #end config-auto-export


// DO NOT TOUCH these ones

config.version = '0.1-b1'

// A simple function to quickly have
// get and set strings for client events
Expand Down
2 changes: 2 additions & 0 deletions debomatic-webui/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ export SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

bash ${SCRIPTS_DIR}/install/remove_css_directory_listing.sh
bash ${SCRIPTS_DIR}/install/download_external_libs.sh

python ${SCRIPTS_DIR}/install/create-user-config.py
44 changes: 44 additions & 0 deletions debomatic-webui/scripts/install/create-user-config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/python

# create a user.config.js file starting from lib/config.js

import os

base_path = os.environ['SCRIPTS_DIR']

global_config_file = os.path.join(base_path, '../lib/config.js')
user_config_file = os.path.join(base_path, '../user.config.js')

if os.path.isfile(user_config_file):
print ("A config user file already exists. Skipping creation.")
print user_config_file
exit()

export_header = """
/*
* debomatic-webui user configuration
*/
"""

export_config = []

with open(global_config_file) as fd:
start = False
for line in fd:
if line.find('#start config-auto-export') >= 0:
start = True
continue
elif line.find('#end config-auto-export') >= 0:
break
if start:
export_config.append(line)

export_config.append('// DO NOT EDIT THIS LINE:\n')
export_config.append('module.exports = config')

print ("Creating user configuration ...")

with open(user_config_file, 'w') as fd:
fd.write(export_header)
fd.write(''.join(export_config))

0 comments on commit 272533f

Please sign in to comment.