mirror of
https://github.com/thingsboard/thingsboard-gateway
synced 2025-10-26 22:31:42 +08:00
Improvements for installation and logs.
This commit is contained in:
BIN
configs.tar.gz
BIN
configs.tar.gz
Binary file not shown.
Binary file not shown.
@@ -15,12 +15,14 @@ sudo rm -rf /usr/lib/python3/dist-packages/jsonschema
|
||||
CURRENT_USER=$USER
|
||||
sudo pip3 install --upgrade jsonschema==3.1.1
|
||||
sudo pip3 install --upgrade bluepy
|
||||
sudo pip3 install --upgrade importlib
|
||||
sudo pip3 install --upgrade importlib-metadata
|
||||
sudo cp -a -r /etc/thingsboard-gateway/extensions /var/lib/thingsboard_gateway/
|
||||
sudo rm -r /etc/thingsboard-gateway/extensions
|
||||
sudo usermod -a -G thingsboard_gateway $CURRENT_USER
|
||||
sudo chown thingsboard_gateway:thingsboard_gateway /var/log/thingsboard-gateway/ -R
|
||||
sudo chown thingsboard_gateway:thingsboard_gateway /etc/thingsboard-gateway/ -R
|
||||
sudo sed 's/\.\/logs/\/var\/log\/thingsboard-gateway/g' /etc/thingsboard-gateway/config/logs.conf >> /etc/thingsboard-gateway/config/logs.conf
|
||||
sudo sed -i 's/\.\/logs/\/var\/log\/thingsboard-gateway/g' /etc/thingsboard-gateway/config/logs.conf >> /etc/thingsboard-gateway/config/logs.conf
|
||||
echo "Installation completed"
|
||||
echo "Enabling daemon..."
|
||||
sudo pidof systemd && sudo systemctl enable thingsboard-gateway || echo "Systemctl not found"
|
||||
|
||||
12
for_build/DEBIAN/pydist-overrides
Normal file
12
for_build/DEBIAN/pydist-overrides
Normal file
@@ -0,0 +1,12 @@
|
||||
pip python3-pip; PEP386
|
||||
lxml python3-lxml; PEP386
|
||||
cryptography python3-cryptography; PEP386
|
||||
jsonpath-rw python3-jsonpath-rw; PEP386
|
||||
jsonpath-rw-ext python3-jsonpath-rw-ext; PEP386
|
||||
opcua python3-opcua; PEP386
|
||||
paho-mqtt python3-paho-mqtt; PEP386
|
||||
pymodbus python3-pymodbus; PEP386
|
||||
pyserial python3-pyserial; PEP386
|
||||
pyyaml python3-PyYAML; PEP386
|
||||
pyrsistent python3-pyrsistent; PEP386
|
||||
importlib python3-importlib; PEP386
|
||||
@@ -8,12 +8,12 @@ storage:
|
||||
read_records_count: 10
|
||||
max_records_count: 1000
|
||||
connectors:
|
||||
#
|
||||
# -
|
||||
# name: MQTT Broker Connector
|
||||
# type: mqtt
|
||||
# configuration: mqtt.json
|
||||
#
|
||||
|
||||
-
|
||||
name: MQTT Broker Connector
|
||||
type: mqtt
|
||||
configuration: mqtt.json
|
||||
|
||||
# -
|
||||
# name: Modbus Connector
|
||||
# type: modbus
|
||||
|
||||
@@ -12,13 +12,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
CURRENT_VERSION=$( grep -Po 'version = \K(.*)$' setup.cfg )
|
||||
if [ "$1" = "clean" ] || [ "$1" = "only_clean" ] ; then
|
||||
sudo rm -rf /var/log/thingsboard-gateway/
|
||||
sudo rm -rf deb_dist/
|
||||
sudo rm -rf dist/
|
||||
sudo rm -rf thingsboard-gateway.egg-info/
|
||||
sudo rm -rf /etc/thingsboard-gateway/
|
||||
sudo rm -rf thingsboard-gateway-2.0.*.tar.gz
|
||||
sudo rm -rf thingsboard-gateway-$CURRENT_VERSION.tar.gz
|
||||
sudo apt remove python3-thingsboard-gateway -y
|
||||
fi
|
||||
|
||||
@@ -29,14 +30,15 @@ if [ "$1" != "only_clean" ] ; then
|
||||
echo "Creating sources for DEB package..."
|
||||
python3 setup.py --command-packages=stdeb.command bdist_deb
|
||||
echo "Adding the files, scripts and permissions in the package"
|
||||
sudo cp -r for_build/etc deb_dist/thingsboard-gateway-2.0.*/debian/python3-thingsboard-gateway
|
||||
sudo cp -r for_build/var deb_dist/thingsboard-gateway-2.0.*/debian/python3-thingsboard-gateway
|
||||
sudo cp -r -a for_build/DEBIAN deb_dist/thingsboard-gateway-2.0.*/debian/python3-thingsboard-gateway
|
||||
sudo chown root:root deb_dist/thingsboard-gateway-2.0.*/debian/python3-thingsboard-gateway/ -R
|
||||
sudo chown root:root deb_dist/thingsboard-gateway-2.0.*/debian/python3-thingsboard-gateway/var/ -R
|
||||
sudo chmod 775 deb_dist/thingsboard-gateway-2.0.*/debian/python3-thingsboard-gateway/DEBIAN/preinst
|
||||
sudo chown root:root deb_dist/thingsboard-gateway-2.0.*/debian/python3-thingsboard-gateway/DEBIAN/preinst
|
||||
sudo cp -r for_build/etc deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway
|
||||
sudo cp -r for_build/var deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway
|
||||
sudo cp -r -a for_build/DEBIAN deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway
|
||||
sudo chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/ -R
|
||||
sudo chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/var/ -R
|
||||
sudo chmod 775 deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/preinst
|
||||
sudo chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/preinst
|
||||
sudo sed -i '/^Depends: .*/ s/$/, libffi-dev, libglib2.0-dev, libxml2-dev, libxslt-dev, libssl-dev, zlib1g-dev/' deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/control >> deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/control
|
||||
# Bulding Deb package
|
||||
dpkg-deb -b deb_dist/thingsboard-gateway-2.0.*/debian/python3-thingsboard-gateway/
|
||||
cp deb_dist/thingsboard-gateway-2.0.*/debian/python3-thingsboard-gateway.deb .
|
||||
dpkg-deb -b deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/
|
||||
cp deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway.deb .
|
||||
fi
|
||||
|
||||
@@ -19,7 +19,7 @@ if [ "$1" = "clean" ] || [ "$1" = "only_clean" ] ; then
|
||||
sudo rm -rf dist/
|
||||
sudo rm -rf thingsboard-gateway.egg-info/
|
||||
sudo rm -rf /etc/thingsboard-gateway/
|
||||
sudo rm -rf thingsboard-gateway-2.*.tar.gz
|
||||
sudo rm -rf thingsboard-gateway-$CURRENT_VERSION.tar.gz
|
||||
sudo rm -rf /home/zenx/rpmbuild/BUILDROOT/*
|
||||
sudo rm -rf build/
|
||||
sudo rm -rf docker/config || echo ''
|
||||
@@ -35,6 +35,7 @@ if [ "$1" != "only_clean" ] ; then
|
||||
# Create sources for DEB package
|
||||
python3 setup.py --command-packages=stdeb.command bdist_deb
|
||||
# Adding the files, scripts and permissions
|
||||
sudo sed -i '/^Depends: .*/ s/$/, libffi-dev, libglib2.0-dev, libxml2-dev, libxslt-dev, libssl-dev, zlib1g-dev/' deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/control >> deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/control
|
||||
sudo cp -r for_build/etc deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway
|
||||
sudo cp -r for_build/var deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway
|
||||
sudo cp -r -a for_build/DEBIAN deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway
|
||||
@@ -42,7 +43,8 @@ if [ "$1" != "only_clean" ] ; then
|
||||
sudo chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/var/ -R
|
||||
sudo chmod 775 deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/preinst
|
||||
sudo chown root:root deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/preinst
|
||||
# Bulding Deb package
|
||||
Bulding Deb package
|
||||
# sudo sed -i 's/Build-Depends.*/Build-Depends: python3-setuptools, python3-all, debhelper (>= 7.4.3), libffi-dev, libglib2.0-dev, libxml2-dev, libxslt-dev, libssl-dev, zlib1g-dev, ${python3: Depends}/g' deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/control >> deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/DEBIAN/control
|
||||
dpkg-deb -b deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway/
|
||||
cp deb_dist/thingsboard-gateway-$CURRENT_VERSION/debian/python3-thingsboard-gateway.deb .
|
||||
cp python3-thingsboard-gateway.deb docker/
|
||||
@@ -72,4 +74,4 @@ if [ "$1" != "only_clean" ] ; then
|
||||
sudo docker build -t thingsboard_gateway .
|
||||
# sudo docker run -d -it --mount type=bind,source="$(pwd)""/logs",target=/var/log/thingsboard-gateway -v config:/etc/thingsboard-gateway/config -v extensions:/var/lib/thingsboard_gateway/extensions --name tb_gateway thingsboard_gateway
|
||||
# sudo docker ps -a | grep tb_gateway
|
||||
fi
|
||||
fi
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = thingsboard-gateway
|
||||
version = 2.0.13
|
||||
version = 2.0.14
|
||||
description = Thingsboard Gateway for IoT devices.
|
||||
long_description = The Thingsboard IoT Gateway is an open-source solution that allows you to integrate devices connected to legacy and third-party systems with Thingsboard.
|
||||
license = Apache Software License (Apache Software License 2.0)
|
||||
|
||||
3
setup.py
3
setup.py
@@ -22,6 +22,7 @@ setup(
|
||||
'thingsboard_gateway.extensions.mqtt', 'thingsboard_gateway.extensions.modbus', 'thingsboard_gateway.extensions.opcua'],
|
||||
install_requires=[
|
||||
'cffi',
|
||||
'pip',
|
||||
'jsonpath-rw',
|
||||
'jsonpath-rw-ext',
|
||||
'jsonschema==3.1.1',
|
||||
@@ -37,7 +38,7 @@ setup(
|
||||
'bluepy',
|
||||
'importlib'
|
||||
],
|
||||
download_url='https://github.com/thingsboard/thingsboard-gateway/archive/2.0.13rc-python.tar.gz',
|
||||
download_url='https://github.com/thingsboard/thingsboard-gateway/archive/2.0.14rc-python.tar.gz',
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'thingsboard-gateway = thingsboard_gateway.tb_gateway:daemon'
|
||||
|
||||
@@ -27,7 +27,7 @@ from thingsboard_gateway.tb_utility.tb_utility import TBUtility
|
||||
|
||||
class BLEConnector(Connector, Thread):
|
||||
def __init__(self, gateway, config, connector_type):
|
||||
super(Thread, self).__init__()
|
||||
super().__init__()
|
||||
self.__connector_type = connector_type
|
||||
self.__default_services = [x for x in range(0x1800, 0x183A)]
|
||||
self.statistics = {'MessagesReceived': 0,
|
||||
|
||||
@@ -30,8 +30,7 @@ class ModbusConnector(Connector, threading.Thread):
|
||||
def __init__(self, gateway, config, connector_type):
|
||||
self.statistics = {'MessagesReceived': 0,
|
||||
'MessagesSent': 0}
|
||||
super(Connector, self).__init__()
|
||||
super(threading.Thread, self).__init__()
|
||||
super().__init__()
|
||||
self.__gateway = gateway
|
||||
self.__connector_type = connector_type
|
||||
self.__master = None
|
||||
|
||||
@@ -27,7 +27,7 @@ from json import loads
|
||||
|
||||
class MqttConnector(Connector, Thread):
|
||||
def __init__(self, gateway, config, connector_type):
|
||||
super(Thread, self).__init__()
|
||||
super().__init__()
|
||||
self.__connector_type = connector_type
|
||||
self.statistics = {'MessagesReceived': 0,
|
||||
'MessagesSent': 0}
|
||||
|
||||
@@ -30,7 +30,7 @@ class OpcUaConnector(Thread, Connector):
|
||||
self.__connector_type = connector_type
|
||||
self.statistics = {'MessagesReceived': 0,
|
||||
'MessagesSent': 0}
|
||||
super(Thread, self).__init__()
|
||||
super().__init__()
|
||||
self.__gateway = gateway
|
||||
self.__server_conf = config.get("server")
|
||||
self.__interest_nodes = []
|
||||
|
||||
@@ -40,7 +40,6 @@ class TBGatewayService:
|
||||
with open(config_file) as config:
|
||||
config = yaml.safe_load(config)
|
||||
self.__config_dir = path.dirname(path.abspath(config_file))+'/'
|
||||
TBUtility.check_logs_directory(self.__config_dir+"logs.conf")
|
||||
logging.config.fileConfig(self.__config_dir+"logs.conf")
|
||||
global log
|
||||
log = logging.getLogger('service')
|
||||
|
||||
@@ -122,31 +122,3 @@ class TBUtility:
|
||||
log.error(e)
|
||||
return None
|
||||
return full_value
|
||||
|
||||
@staticmethod
|
||||
def check_logs_directory(conf_file_path):
|
||||
log = None
|
||||
try:
|
||||
log = getLogger(__name__)
|
||||
except Exception:
|
||||
log = getLogger('service')
|
||||
with open(conf_file_path) as conf_file:
|
||||
logs_directories = set()
|
||||
for line in conf_file.readlines():
|
||||
target = re.search(r"[\"|\'](.+[/])(.+\.log)\"|\'", line)
|
||||
if target:
|
||||
if target.group(1) is not None:
|
||||
logs_directories.add(target.group(1))
|
||||
for logs_dir in logs_directories:
|
||||
if not os.path.exists(logs_dir):
|
||||
if log is not None:
|
||||
log.error("Logs directory not exists.")
|
||||
else:
|
||||
print("ERROR - Logs directory not exists.")
|
||||
try:
|
||||
os.mkdir(logs_dir)
|
||||
except Exception as e:
|
||||
if log is not None:
|
||||
log.exception(e)
|
||||
else:
|
||||
print(e)
|
||||
|
||||
Reference in New Issue
Block a user