From 62477143f2cf7bd8d6b915b2da47c9076585c2f2 Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Fri, 15 Jan 2021 20:02:10 -0500 Subject: [PATCH] Dependency check. Remove tmp_dir on exit. --- lug-helper.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lug-helper.sh b/lug-helper.sh index ba412d6..513ed3a 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -38,6 +38,12 @@ # Contributor: https://github.com/Termuellinator ############################################################################ +# Check for dependencies +if [ ! -x "$(command -v mktemp2)" ] || [ ! -x "$(command -v basename)" ]; then + echo -e "One or more required packages were not found on this system.\nPlease check that the following packages are installed:\n- mktemp (part of gnu coreutils)\n- basename (part of gnu coreutils)" + exit 1 +fi + wine_conf="winedir.conf" game_conf="gamedir.conf" backup_conf="backupdir.conf" @@ -57,7 +63,9 @@ fi # .config subdirectory conf_subdir="starcitizen-lug" -tmp_dir="$(mktemp -d --suffix=".lughelper" || echo "/tmp")" +# Temporary directory +tmp_dir="$(mktemp -d --suffix=".lughelper")" +trap 'rm -r "$tmp_dir"' EXIT # The game's user subdirectory name user_subdir_name="USER"