mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-11 14:18:50 +00:00
Merge pull request #39 from danielwelch/master
configure datapath with env variable
This commit is contained in:
+10
-2
@@ -1,8 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -f /app/data/configuration.yaml ]; then
|
||||
if [ ! -z "$ZIGBEE2MQTT_DATA" ]; then
|
||||
DATA="$ZIGBEE2MQTT_DATA"
|
||||
else
|
||||
DATA="/app/data"
|
||||
fi
|
||||
|
||||
echo "Using '$DATA' as data directory"
|
||||
|
||||
if [ ! -f "$DATA/configuration.yaml" ]; then
|
||||
echo "Creating configuration file..."
|
||||
cp /app/configuration.yaml /app/data/configuration.yaml
|
||||
cp /app/configuration.yaml "$DATA/configuration.yaml"
|
||||
fi
|
||||
|
||||
npm start
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
const path = require('path');
|
||||
|
||||
let dataPath = null;
|
||||
|
||||
if (process.env.ZIGBEE2MQTT_DATA) {
|
||||
dataPath = process.env.ZIGBEE2MQTT_DATA;
|
||||
}
|
||||
else {
|
||||
dataPath = path.join(__dirname, '..', '..', 'data');
|
||||
dataPath = path.normalize(dataPath);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
joinPath: (file) => path.join(dataPath, file)
|
||||
}
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
const winston = require('winston');
|
||||
const data = require('./data');
|
||||
|
||||
const logger = new (winston.Logger)({
|
||||
transports: [
|
||||
new (winston.transports.File)({
|
||||
filename: 'data/log.txt',
|
||||
filename: data.joinPath('log.txt'),
|
||||
json: false,
|
||||
level: winston.level.info,
|
||||
maxFiles: 3,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
const YAWN = require('yawn-yaml/cjs');
|
||||
const fs = require('fs');
|
||||
const file = `${__dirname}/../../data/configuration.yaml`;
|
||||
const data = require('./data');
|
||||
const file = data.joinPath('configuration.yaml');
|
||||
|
||||
let yawn = read();
|
||||
|
||||
function write() {
|
||||
|
||||
+2
-1
@@ -2,10 +2,11 @@ const ZShepherd = require('zigbee-shepherd');
|
||||
const logger = require('./util/logger');
|
||||
const settings = require('./util/settings');
|
||||
const deviceMapping = require('./devices');
|
||||
const data = require('./util/data');
|
||||
|
||||
const shepherdSettings = {
|
||||
net: {panId: 0x1a62},
|
||||
dbPath: `${__dirname}/../data/database.db`
|
||||
dbPath: data.joinPath('database.db')
|
||||
};
|
||||
|
||||
class Zigbee {
|
||||
|
||||
Reference in New Issue
Block a user