From patchwork Sun Sep 8 13:09:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [v3] fff-gateway: Add sanity checks From: Fabian Blaese X-Patchwork-Id: 1181 Message-Id: <20190908130941.18203-1-fabian@blaese.de> To: franken-dev@freifunk.net Date: Sun, 8 Sep 2019 15:09:41 +0200 This adds two checks: - Does gateway config exist? - Does gateway config version match? Signed-off-by: Fabian Bläse Tested-by: Fabian Bläse --- Changes in v2: - Add exit to gateway config check - Fix incorrectly escaped apostrophe Changes in v3: - Move config_version option from gateway.version to gateway.meta - Use uci show instead of undocumented use of uci get for existance test - Remove '-q' from existance test to show uci error message (syntax errors for example) --- .../files/etc/gateway.d/01-version | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/packages/fff/fff-gateway/files/etc/gateway.d/01-version diff --git a/src/packages/fff/fff-gateway/files/etc/gateway.d/01-version b/src/packages/fff/fff-gateway/files/etc/gateway.d/01-version new file mode 100644 index 0000000..1553179 --- /dev/null +++ b/src/packages/fff/fff-gateway/files/etc/gateway.d/01-version @@ -0,0 +1,19 @@ +configure() { + local expected_version=1 + local config_version=$(uci -q get gateway.meta.config_version) + + # check if gateway config exists + if ! uci show gateway > /dev/null; then + echo "ERROR: Gateway config could not be parsed or does not exist." + + exit 1 + fi + + # check version of configuration + if [ "$config_version" != "$expected_version" ]; then + echo "ERROR: Invalid config version. Expected '$expected_version', got '$config_version'." + echo "Please check what has been changed and adjust your config appropriately." + + exit 1 + fi +}