Commit 7b895364 authored by Karel Hanák's avatar Karel Hanák

Debian package: default configuration package, gateway postinst configuration

Signed-off-by: Karel Hanák's avatarKarel Hanák <karel.hanak@microrisc.com>
parent ae6e16a6
Pipeline #3975 passed with stages
in 67 minutes and 33 seconds
......@@ -13,7 +13,7 @@ Vcs-Browser: https://gitlab.iqrf.org/open-source/iqrf-gateway-daemon
Package: iqrf-gateway-daemon
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Depends: ${misc:Depends}, ${shlibs:Depends}, jq
Replaces: iqrf-daemon (<< 2.0.0)
Breaks: iqrf-daemon (<< 2.0.0)
Description: IQRF Gateway Daemon
......@@ -25,3 +25,9 @@ Description: IQRF Gateway Daemon
.
The Daemon utilizes multiple communication channels UDP, MQ, WebSocket and MQTT
and can be managed through the IQRF Gateway Webapp.
Package: iqrf-gateway-daemon-default-cfg
Architecture: all
Depends: iqrf-gateway-daemon (= ${binary:Version})
Description: IQRF Gateway Daemon - Default Configuration
Default configuration files for IQRF Gateway Daemon.
\ No newline at end of file
src/start-IqrfDaemon/configuration/*.json usr/share/iqrf-gateway/default/daemon
src/start-IqrfDaemon/configuration-LinDeploy/*.json usr/share/iqrf-gateway/default/daemon
src/start-IqrfDaemon/cfgSchemas usr/share/iqrf-gateway/default/daemon
src/start-IqrfDaemon/scheduler usr/share/iqrf-gateway/default/daemon
src/start-IqrfDaemon/metaData usr/share/iqrf-gateway/default/daemon
\ No newline at end of file
#!/bin/bash
# After install script for iqrf-gateway-daemon-default-cfg
set -e
if [ "$1" = "configure" ]; then
confDir="/usr/share/iqrf-gateway/default/daemon/"
if [ -f /etc/iqrf-gateway.json ]
then
gwProduct=$(jq -r '.gwProduct' /etc/iqrf-gateway.json)
if [[ $gwProduct == "IQD-GW-01" || $gwProduct == "IQD-GW-01A" ]]; then
gwId=$(jq -r '.gwId' /etc/iqrf-gateway.json)
if [ -f "${confDir}iqrf__IqrfSpi.json" ]; then
jq --unbuffered '.instance = "iqrf::IqrfSpi-/dev/spidev1.0" | .IqrfInterface = "/dev/spidev1.0" | .powerEnableGpioPin = 19 | .busEnableGpioPin = 10 | .pgmSwitchGpioPin = 3' "${confDir}iqrf__IqrfSpi.json" > tmp.json && mv tmp.json "${confDir}iqrf__IqrfSpi.json"
fi
if [ -f "${confDir}iqrf__IqrfUart.json" ]; then
jq --unbuffered '.instance = "iqrf::IqrfUart-/dev/ttyS1" | .IqrfInterface = "/dev/ttyS1" | .powerEnableGpioPin = 19 | .busEnableGpioPin = 10 | .pgmSwitchGpioPin = -1 | .+ {spiReset: false}' "${confDir}iqrf__IqrfUart.json" > tmp.json && mv tmp.json "${confDir}iqrf__IqrfUart.json"
fi
if [ -f "${confDir}iqrf__JsonSplitter.json" ]; then
jq --unbuffered --arg gwId "$gwId" '.insId = "iqdgw01-" + $gwId' "${confDir}iqrf__JsonSplitter.json" > tmp.json && mv tmp.json "${confDir}iqrf__JsonSplitter.json"
fi
if [ -f "${confDir}iqrf__MqttMessaging.json" ]; then
jq --unbuffered --arg gwId "$gwId" '.ClientId = $gwId | .TopicRequest = "gateway/" + $gwId + "/iqrf/requests" | .TopicResponse = "gateway/" + $gwId + "/iqrf/responses"' "${confDir}iqrf__MqttMessaging.json" > tmp.json && mv tmp.json "${confDir}iqrf__MqttMessaging.json"
fi
if [ -f "${confDir}iqrf__IdeCounterpart.json" ]; then
jq --unbuffered --arg gwId "$gwId" '.gwIdentModeByte = 34 | .gwIdentName = "IQD-GW-01" | .gwIdentNetBios = "iqdgw01-" + $gwId' "${confDir}iqrf__IdeCounterpart.json" > tmp.json && mv tmp.json "${confDir}iqrf__IdeCounterpart.json"
fi
fi
fi
fi
\ No newline at end of file
......@@ -32,9 +32,36 @@ remove_old_dirs() {
rm -f /lib/systemd/system/iqrfgd2.service
}
configure_gateway() {
confDir="/etc/iqrf-gateway-daemon/"
if [ -f /etc/iqrf-gateway.json ]
then
gwProduct=$(jq -r '.gwProduct' /etc/iqrf-gateway.json)
if [[ $gwProduct == "IQD-GW-01" || $gwProduct == "IQD-GW-01A" ]]; then
gwId=$(jq -r '.gwId' /etc/iqrf-gateway.json)
if [ -f "${confDir}iqrf__IqrfSpi.json" ]; then
jq --unbuffered '.instance = "iqrf::IqrfSpi-/dev/spidev1.0" | .IqrfInterface = "/dev/spidev1.0" | .powerEnableGpioPin = 19 | .busEnableGpioPin = 10 | .pgmSwitchGpioPin = 3' "${confDir}iqrf__IqrfSpi.json" > tmp.json && mv tmp.json "${confDir}iqrf__IqrfSpi.json"
fi
if [ -f "${confDir}iqrf__IqrfUart.json" ]; then
jq --unbuffered '.instance = "iqrf::IqrfUart-/dev/ttyS1" | .IqrfInterface = "/dev/ttyS1" | .powerEnableGpioPin = 19 | .busEnableGpioPin = 10 | .pgmSwitchGpioPin = -1 | .+ {spiReset: false}' "${confDir}iqrf__IqrfUart.json" > tmp.json && mv tmp.json "${confDir}iqrf__IqrfUart.json"
fi
if [ -f "${confDir}iqrf__JsonSplitter.json" ]; then
jq --unbuffered --arg gwId "$gwId" '.insId = "iqdgw01-" + $gwId' "${confDir}iqrf__JsonSplitter.json" > tmp.json && mv tmp.json "${confDir}iqrf__JsonSplitter.json"
fi
if [ -f "${confDir}iqrf__MqttMessaging.json" ]; then
jq --unbuffered --arg gwId "$gwId" '.ClientId = $gwId | .TopicRequest = "gateway/" + $gwId + "/iqrf/requests" | .TopicResponse = "gateway/" + $gwId + "/iqrf/responses"' "${confDir}iqrf__MqttMessaging.json" > tmp.json && mv tmp.json "${confDir}iqrf__MqttMessaging.json"
fi
if [ -f "${confDir}iqrf__IdeCounterpart.json" ]; then
jq --unbuffered --arg gwId "$gwId" '.gwIdentModeByte = 34 | .gwIdentName = "IQD-GW-01" | .gwIdentNetBios = "iqdgw01-" + $gwId' "${confDir}iqrf__IdeCounterpart.json" > tmp.json && mv tmp.json "${confDir}iqrf__IdeCounterpart.json"
fi
fi
fi
}
if [ "$1" = "configure" ]; then
openssl_create_ca
remove_old_dirs
configure_gateway
fi
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ]; then
......
......@@ -12,7 +12,7 @@ daemon_remove_data() {
rm -rf /var/cache/iqrf-gateway-daemon/
}
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
if [ "$1" = "purge" ]; then
daemon_remove_data
daemon_remove_config
fi
......
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