From 89a68e03a7891680d1deab748fd41184c668c046 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 18 Mar 2016 19:05:41 +0000 Subject: [PATCH] Added extra protections against incorrect rm --- functions/command_update_functions.sh | 40 ++++++++++++++++++++++ lgsm/functions/command_update_functions.sh | 19 +++++----- 2 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 functions/command_update_functions.sh diff --git a/functions/command_update_functions.sh b/functions/command_update_functions.sh new file mode 100644 index 000000000..a23cf58a1 --- /dev/null +++ b/functions/command_update_functions.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# LGSM update_functions.sh function +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +lgsm_version="270216" + +# Description: Deletes the functions dir to allow re-downloading of functions from GitHub. + +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +check.sh +fn_print_dots "Updating functions" +fn_scriptlog "Updating functions" +sleep 1 +echo -ne "\n" + + + +# Removed legecy functions dir +if [ -n "${rootdir}" ]; then + if [ -d "${rootdir}/functions/" ]; then + rm -rfv "${rootdir}/functions/" + exitcode=$? + fi +fi + +if [ -n "${functionsdir}" ]; then + if [ -d "${functionsdir}" ]; then + rm -rfv "${functionsdir}/"* + exitcode=$? + fi +fi + +if [ "${exitcode}" == "0" ]; then + fn_print_ok "Updating functions" + fn_scriptlog "Success! Updating functions" +else + fn_print_fail "Updating functions" + fn_scriptlog "Failure! Updating functions" +fi +echo -ne "\n" \ No newline at end of file diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 9c0ac4b90..a23cf58a1 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -13,18 +13,21 @@ fn_scriptlog "Updating functions" sleep 1 echo -ne "\n" + + # Removed legecy functions dir -if [ -d "${rootdir}/functions/" ]; then - rm -rfv "${rootdir}/functions/" - exitcode=$? +if [ -n "${rootdir}" ]; then + if [ -d "${rootdir}/functions/" ]; then + rm -rfv "${rootdir}/functions/" + exitcode=$? + fi fi if [ -n "${functionsdir}" ]; then - rm -rfv "${functionsdir}/"* - exitcode=$? -else - fn_print_fail "Updating functions" - fn_scriptlog "Failure! Updating functions" + if [ -d "${functionsdir}" ]; then + rm -rfv "${functionsdir}/"* + exitcode=$? + fi fi if [ "${exitcode}" == "0" ]; then