#!/bin/bash set -e . /usr/lib/wb-utils/wb_env.sh wb_source "of" APP_NAME=wb-mqtt-gpio CONFFILE_NAME=$APP_NAME.conf CONFFILE=/etc/$CONFFILE_NAME OLD_APP_NAME=wb-homa-gpio OLD_CONFFILE_NAME=$OLD_APP_NAME.conf OLD_CONFFILE=/etc/$OLD_CONFFILE_NAME function is_installed() { dpkg -s "$1" &> /dev/null } function get_version() { dpkg-query --show --showformat '${Version}' "$1" is_installed "$1" } KERNEL_VERSION=$(get_version linux-image-wb2 || get_version linux-image-wb6 || true) if [ -z "$KERNEL_VERSION" ]; then # wb7 or newer, so no default config BOARD_CONF="devicetree" elif of_node_exists /wirenboard/gpios && dpkg --compare-versions "$KERNEL_VERSION" gt "4.9+wb20181227130340"; then BOARD_CONF="devicetree" else # older kernel version contained incomplete gpios devicetree node case "$WB_VERSION" in "61" | "60" | "58" | "55" | "52" ) BOARD_CONF="wb${WB_VERSION}" ;; "50" ) BOARD_CONF="wbsh5" ;; "41" ) BOARD_CONF="wbsh4" ;; "32" ) BOARD_CONF="wbsh3" ;; "KMON1" ) BOARD_CONF="mka3" ;; "CQC10" ) BOARD_CONF="cqc10" ;; * ) BOARD_CONF="default" ;; esac fi if [ -f /var/lib/$OLD_APP_NAME/libwbmqtt.db ]; then mkdir -p /var/lib/$APP_NAME cp /var/lib/$OLD_APP_NAME/libwbmqtt.db /var/lib/$APP_NAME/libwbmqtt.db fi if [ -f $OLD_CONFFILE ]; then ucf --debconf-ok $OLD_CONFFILE $CONFFILE cp -f $OLD_CONFFILE /usr/share/$APP_NAME/$OLD_CONFFILE_NAME.old rm -f $OLD_CONFFILE else ucf --debconf-ok "/usr/share/$APP_NAME/$CONFFILE_NAME.$BOARD_CONF" "$CONFFILE" fi ln -s $CONFFILE $OLD_CONFFILE deb-systemd-helper enable wb-mqtt-gpio.service >/dev/null || true # Automatically added by dh_systemd_start/13.3.4 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true deb-systemd-invoke start 'wb-mqtt-gpio.service' >/dev/null || true fi fi # End automatically added section