#!/bin/sh

if [ "$2" = "POST_INSTALL" ]; then
	if [ ! -f /usr/local/etc/sympa/sympa.conf -o ! -f /usr/local/etc/sympa/data_structure.version ]; then
		cp -p /usr/local/etc/sympa/sympa.conf.sample /usr/local/etc/sympa/sympa.conf
		chmod u+w /usr/local/etc/sympa/sympa.conf
	else
		if [ $(tail -1 /usr/local/etc/sympa/data_structure.version | cut -d. -f3) -lt 2 ]; then
			echo "It seems you are upgrading from version <6.2 ($(cat /usr/local/etc/sympa/data_structure.version))"
			echo "You'll have to read https://sympa-community.github.io/manual/upgrade/notes.html and (at least) run:"
			echo " # /usr/local/libexec/sympa/sympa.pl --upgrade_config_location"
			echo " # /usr/local/libexec/sympa/sympa.pl --upgrade"
			echo " # /usr/local/libexec/sympa/upgrade_bulk_spool.pl"
			echo " # /usr/local/libexec/sympa/upgrade_send_spool.pl"
			echo "to update your config files to the new layout"
		else
			echo "to upgrade, run:"
			echo " # /usr/local/libexec/sympa/sympa.pl --upgrade"
      echo ""
      echo "Don't forget to read:"
      echo "  https://sympa-community.github.io/manual/upgrade/notes.html"
		fi
	fi
fi

exit 0
