Commit e9ce2462 authored by Dobli's avatar Dobli
Browse files

added config info to readme and prepared copy function

parent 89e1463a
......@@ -64,6 +64,7 @@ docker
docker-compose
docker-machine
python
mosquitto (mosquitto_passwd utility)
```
**Python:**
......@@ -72,3 +73,24 @@ docker
PyInquirer
pyyaml
```
All python requirements are installable using `pip install -r requirements.txt` pointing to the requirements.txt file in this repo.
### Config file generation
The openhab-pb stack consists of multiple configuration files that need to be available and will be used by the docker containers. The Manager Script generates these for convinience. In addition they are documented here, sorted by application/folder, to understand their usecases.
**mosquitto**
- *mosquitto.conf*: basic configuration of mosquitto
- disables anonymous access
- enables usage of password file
- *mosquitto_passwords*: List of users/passwords that gain access to mosquitto
- generated with `mosquitto_passwd`
**nodered**
- *nodered_package.json*: packages to be installed when node red is setup
- contains entry for openhab package
- *nodered_settings*: basic node red config
- contains `httpNodeAuth` for users
\ No newline at end of file
......@@ -3,13 +3,16 @@ import docker
import logging
import os
from PyInquirer import prompt
from shutil import copy2
from subprocess import run
from PyInquirer import prompt
# Log level during development is info
logging.basicConfig(level=logging.WARNING)
# Directories for config generation
CUSTOM_DIR = 'custom_configs'
TEMPLATE_DIR = 'template_configs'
CONFIG_DIRS = [
'influxdb', 'mosquitto', 'nodered', 'ssh', 'treafik', 'volumerize'
]
......@@ -21,17 +24,35 @@ SWARM_PORT = 2377
# ******************************
# Config file functions {{{
# ******************************
def generate_config_folders(base_path):
def generate_config_folders(base_dir):
"""Generate folders for configuration files
:base_path: Path to add folders to
:base_dir: Path to add folders to
"""
base_path = base_dir + '/' + CUSTOM_DIR
if not os.path.exists(base_dir):
os.makedirs(base_dir)
print(f'Initialize configuration in {base_path}')
for d in CONFIG_DIRS:
new_dir = base_path + '/' + d
if not os.path.exists(new_dir):
os.makedirs(new_dir)
def copy_template_config(base_dir, config_path):
"""Copies template configuration files into custom folder
:base_dir: path that contains template and custom folders
:config_path: relative path of config to copy from template
"""
custom_path = base_dir + '/' + CUSTOM_DIR
template_path = base_dir + '/' + TEMPLATE_DIR
print(f'Copy {config_path} from {custom_path to} {template_path}')
pass
# }}}
......@@ -201,12 +222,8 @@ def init_config_dirs_command(args):
base_dir = args.base_dir
if base_dir is None:
current_dir = os.getcwd()
base_dir = current_dir + '/custom_configs'
if not os.path.exists(base_dir):
os.makedirs(base_dir)
base_dir = os.getcwd()
print(f'Initialize configuration in {base_dir}')
generate_config_folders(base_dir)
......@@ -310,7 +327,7 @@ def init_menu():
# init swarm with first machine
if leader is None:
leader = machine
print(f'Creat initial swarm with leader {leader}')
print(f'Create initial swarm with leader {leader}')
if init_swarm_machine(leader):
print('Swarm init successful\n')
else:
......
......@@ -128,10 +128,11 @@ module.exports = {
// the static content (httpStatic), the following properties can be used.
// The pass field is a bcrypt hash of the password.
// See http://nodered.org/docs/security.html#generating-the-password-hash
httpNodeAuth:{
user:"user",
pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."
},
//httpNodeAuth:{
// user:"user",
// pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."
//},
//httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
// The following property can be used to enable HTTPS
......
......@@ -351,7 +351,7 @@ services:
INFLUXDB_DB: "openhab"
INFLUXDB_ADMIN_USER: "ohadmin"
INFLUXDB_ADMIN_PASSWORD: "ohadmin"
INFLUXDB_USER_FILE: "/run/secrets/influx_user"
INFLUXDB_USER: "ohuser"
INFLUXDB_USER_PASSWORD: "ohtest"
networks:
- habnet
......
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