if [ -e "/usr/lib/lsb/init-functions" ]; then
  . /usr/lib/lsb/init-functions
elif [ -e "/lib/lsb/init-functions" ]; then
  . /lib/lsb/init-functions
fi

VERSION=$(grep version var/lib/pkg/grat-os-version |cut -d " " -f2)
[ ! -d etc/ports ] && mkdir -p etc/ports
for i in base cli gui \
cli-extra gui-extra \
xfce4 xfce4-extra \
mate mate-extra \
kde5 kde5-extra \
lxqt lxqt-extra \
lxde lxde-extra \
nos
do
   if [ ! -f etc/ports/$i.cards ]; then
      echo "host=repo.grat-os.fr
destination=/usr/ports/$i
version=$VERSION
collection=$i" > etc/ports/$i.cards
      log_success_msg "${WARNING} /etc/ports/$i.cards created ${NORMAL}"
      log_warning_msg "${WARNING} Double check /etc/ports/$i and adapted to your needs ${NORMAL}"
   else
      log_warning_msg "${WARNING} Double check /etc/ports/$i and adapted to this version of Grat-OS ${NORMAL}"
   fi
done
if [ ! -f etc/pkgmk.conf ]; then
   if [ -f etc/pkgmk.conf.example ]; then
	cp etc/pkgmk.conf.example etc/pkgmk.conf
	log_success_msg "${WARNING} /etc/pkgmk.conf.example copied as /etc/pkgmk.conf ${NORMAL}"
	log_warning_msg "${WARNING} Double check /etc/pkgmk.conf and adapted to your needs ${NORMAL}"
   fi
fi
