#!/bin/sh
[ ! -f /etc/init.d/seafile ] && exit 0

if [ ! -d /usr/share/seafile/seafile-data ]
then
   echo "*** Installation completed, running configuration script..."
   /etc/init.d/seafile setup

   if [ $? -ne 0 ]
   then
      echo
      echo "*** ERROR: Configuration failed. Please fix the issues if any and re-run the script using the command below:"
      echo "*** \"/etc/init.d/seafile setup\""
   fi
else
   echo "*** seafile-data directory already exists."
   echo
   echo "*** In case you are upgrading seafile, please run the appropriate upgrade script"
   echo "*** manually before using the new version."
   echo "*** Upgrade scripts are located at \"/usr/share/seafile/seafile-server/upgrade\""
   echo
   echo "*** For more information, please read http://manual.seafile.com/deploy/upgrade.html"
fi
