diff --git a/os/debian/postinst b/os/debian/postinst index a34fa9167a844326f146f7874d928789ab924ec2..f79eb82bb7ca5aa5a4df8403edcfe0db8f976f78 100755 --- a/os/debian/postinst +++ b/os/debian/postinst @@ -1,10 +1,29 @@ #!/bin/bash -e . /usr/share/debconf/confmodule + + DAP_CHAINS_NAME="cellframe" DAP_APP_NAME="$DAP_CHAINS_NAME-node" DAP_PREFIX="/opt/$DAP_APP_NAME" +new_ver=$(dpkg-query --show --showformat='${Version}' $DAP_APP_NAME) +old_ver="$2" + +echo "New version: $new_ver" +echo "Old version: $old_ver" + +OLD_MINOR=( $( printf "%s\n" "$old_ver" | cut -c 3-3 | sort -nr) ) +NEW_MINOR=( $( printf "%s\n" "$new_ver" | cut -c 3-3 | sort -nr) ) + + +if (( NEW_MINOR > OLD_MINOR )); then + echo "Need update cellframe-node configs..." +else + echo "No need to update cellframe-node configs, write as new" +fi + + DAP_CFG_TPL="$DAP_PREFIX/share/configs/$DAP_APP_NAME.cfg.tpl" # Store write config to new if present smth @@ -16,7 +35,13 @@ DAP_CFG="$DAP_PREFIX/etc/$DAP_APP_NAME.cfg" # Init node config if [ -e "$DAP_CFG" ]; then - DAP_CFG="$DAP_PREFIX/etc/$DAP_APP_NAME.cfg.dpkg-new" + if (( NEW_MINOR > OLD_MINOR )); then + echo "Need update cellframe-node.cfg ..." + DAP_CFG="$DAP_PREFIX/etc/$DAP_APP_NAME.cfg" + else + echo "No need to update cellframe-node.cfg, write as new" + DAP_CFG="$DAP_PREFIX/etc/$DAP_APP_NAME.cfg.dpkg-new" + fi else DAP_CFG="$DAP_PREFIX/etc/$DAP_APP_NAME.cfg" fi @@ -175,8 +200,15 @@ if [ "$RET" = "true" ]; then DAP_CFG_NET="$DAP_PREFIX/etc/network/$NET_NAME.cfg" DAP_CFG_NET_TPL="$DAP_PREFIX/share/configs/network/$NET_NAME.cfg.tpl" DAP_NET_CFG="" + if [ -e "$DAP_CFG_NET" ]; then - DAP_NET_CFG="$DAP_PREFIX/etc/network/$NET_NAME.cfg.dpkg-new" + if (( NEW_MINOR > OLD_MINOR )); then + echo "Need update Backbone.cfg ..." + DAP_NET_CFG="$DAP_PREFIX/etc/network/$NET_NAME.cfg" + else + echo "No need to update Backbone.cfg, write as new" + DAP_NET_CFG="$DAP_PREFIX/etc/network/$NET_NAME.cfg.dpkg.new" + fi else DAP_NET_CFG="$DAP_PREFIX/etc/network/$NET_NAME.cfg" fi