#!/bin/sh

ver_new="$1"
ver_old="$2"

if [ "$(apk version -t "$ver_old" "3.0.20-r4")" = "<" ]; then
	cat >&2 <<-EOF
	*
	* FreeRADIUS utilities (such as radtest, radwho...) were moved into package
	* freeradius-utils. DHCP module was moved into package freeradius-dhcp.
	*
	EOF

	setup-freeradius enable-default-mods >/dev/null 2>&1
fi

if [ "$(apk version -t "$ver_old" "3.0.20-r8")" = "<" ]; then
	cuidb_file_old='/var/log/radius/radacct/cui.sqlite'
	cuidb_file_new='/var/lib/radiusd/cui.sqlite'

	if [ -f "$cuidb_file_old" ] && ! [ -e "$cuidb_file_new" ]; then
		echo "* Moving $cuidb_file_old to $cuidb_file_new" >&2
		mv "$cuidb_file_old" "$cuidb_file_new"
	fi
fi

exit 0
