diff --git a/app/js/aether_native_app_v3.js b/app/js/aether_native_app_v3.js index 43384d5..12d4a3e 100644 --- a/app/js/aether_native_app_v3.js +++ b/app/js/aether_native_app_v3.js @@ -24,6 +24,9 @@ exports.load_config = function () { console.log(`CWD: ${cwd}`); try { + if (cwd == '/') { + cwd = '[home]'; + } console.log('Reading directory...'); let directory_list = fs_promises.readdir(cwd).then(function (read_dir_result) { console.log('Got contents:'); @@ -81,18 +84,24 @@ exports.load_config = function () { // config = JSON.parse(fs.readFileSync(config_path)); // console.log('Config file read.'); - } else if (fs.existsSync('config.json')) { + } else if (fs.existsSync(path.join(cwd, 'config.json'))) { //fs.copyFileSync(default_config_path, config_path); //console.log('Default config file copied: '+config_directory); - console.log(`Config file (config.json) not found under ${config_directory}. Using config in CWD. ${process.cwd()}`); - config_path = 'config.json'; + console.log(`Config file (config.json) not found under ${config_directory}. Using config in CWD. ${cwd}`); + config_path = path.join(cwd, 'config.json'); - // config = JSON.parse(fs.readFileSync('config.json')); - // console.log('Config file read.'); + console.log(`Config file (config.json) not found under ${config_directory}. Using config in CWD. ${cwd}`); + found_config_path = path.join(cwd, 'config.json'); - //console.log('Config file (config.json) not found under '+config_directory+'. Using config in CWD.'); - //config = JSON.parse(fs.readFileSync('config.json')); + fs.copyFileSync(found_config_path, config_path); + console.log(`Found config file copied: ${config_directory}`); + } else if (fs.existsSync(path.join(cwd, 'config.json.default'))) { + console.log(`Config file (config.json) not found under ${config_directory} or CWD. Using default config in CWD. ${cwd}`); + default_config_path = path.join(cwd, 'config.json.default'); + + fs.copyFileSync(default_config_path, config_path); + console.log(`Default config file copied: ${config_directory}`); } else { console.log('Can not find a config file.'); @@ -105,6 +114,10 @@ exports.load_config = function () { config.home_directory = home_directory; // From the OS platform config.tmp_directory = tmp_directory; // From the OS platform + config.app_root_path = config.app_root_path.replace('[home]', home_directory); + config.app_root_path = config.app_root_path.replace('[tmp]', tmp_directory); + console.log(config.app_root_path); + config.host_file_cache_path = config.host_file_cache_path.replace('[home]', home_directory); config.host_file_cache_path = config.host_file_cache_path.replace('[tmp]', tmp_directory); console.log(config.host_file_cache_path); diff --git a/config.json b/config.json index e4c33ae..c7671d6 100644 --- a/config.json +++ b/config.json @@ -5,6 +5,8 @@ "event_location_id": "7ReVVemiSM0", "event_session_id": null, + "app_root_path": "[home]/tmp/OSIT/native_app", + "api_secret_key": "dFP6J9DVj9hUgIMn-fNIqg", "api_remote_base_url": "https://dev-fastapi.oneskyit.com", "api_local_base_url": "http://dev-fastapi.oneskyit.local:5005", diff --git a/config.json.default b/config.json.default index cf6dfa6..a10b08d 100644 --- a/config.json.default +++ b/config.json.default @@ -9,6 +9,8 @@ "event_location_code": "", "event_session_id": "", + "app_root_path": "[home]/OSIT/native_app", + "api_secret_key": "ABCD1234XYZ", "api_server_base_url": "http://dev-api.oneskyit.local:5005",