
check_pre_systemd()
{
   oldver=$1
   major=${oldver%%.*}
   patch=${oldver##*.}
   minor=${oldver##$major.}
   minor=${minor%%.$patch}
   echo "Old version: $oldver"
   echo "Major: $major"
   echo "Minor: $minor"
   echo "Patch: $patch"

   if test $major -gt 2; then
     return 1
   fi
   if test $major -lt 2; then
     return 0
   fi
   if test $minor -lt 4; then
      return 0
   fi
   return 1
}


post_install()
{
systemctl enable mdd
systemctl start mdd
 return 0
}

pre_upgrade()
{
  oldver=$2
  if check_pre_systemd $oldver; then
     sv down sdd
  else
     systemctl stop sdd
  fi
  return 0
}

post_upgrade()
{
  oldver=$2

  if check_pre_systemd $oldver; then
     remove-service sdd
     systemctl enable sdd
  fi

  systemctl start sdd
  return 0

}

pre_remove()
{
systemctl stop sdd
systemctl disable sdd
}

