#!/bin/bash
# LGSM fn_update_functions function
# Author: Daniel Gibbs
# Website: http://gameservermanagers.com
# Version: 190515

# Description: Deletes the functions dir to allow re-downloading of functions from GitHub.

fn_printdots "Updating functions"
fn_scriptlog "Updating functions"
sleep 1
echo -ne "\n"
rm -rfv "${rootdir}/functions/"*
exitcode=$?
if [ "${exitcode}" == "0" ]; then
	fn_printok "Updating functions"
	fn_scriptlog "Successfull! Updating functions"
else
	fn_printokfail "Updating functions"
	fn_scriptlog "Failure! Updating functions"
fi
sleep 1
fn_printdots "Checking for ${selfname} script update"
fn_scriptlog "Checking for ${selfname} script update"

currentversion=$(wget -O- -q https://gameservermanagers.com/dl/${selfname}|grep version=)

currentversion

if [ "${version}" == "${currentversion}" ]; then
	fn_printok "New version of ${selfname} available"
	fn_scriptlog "New version of ${selfname} available"
else
	fn_printok "${selfname} is up to date"
	fn_printok "${selfname} is up to date"
fi

echo -ne "\n"
