#!/bin/bash

# Check latest version
URL="http://update.zentyal.org/last-7.1.txt"
TIMEOUT="300"
DEST="/var/lib/zentyal/latestversion"
wget --timeout $TIMEOUT $URL -O $DEST >/dev/null 2>&1

# Stop services if commercial trial expired
if [ $(/usr/share/zentyal/shell '$global->edition()') == "trial-expired" ]; then
  zs restart >/dev/null
fi

if [ -f '/var/lib/zentyal/.commercial-edition' ]; then
  /usr/share/zentyal/check_license
fi

if [ $? == 1 ]; then
  zs webadmin stop
fi