Skip to content

Commit

Permalink
fix: add docker compatibility
Browse files Browse the repository at this point in the history
fix: allow find to search in symlinks
  • Loading branch information
dgibbs64 committed Oct 22, 2022
1 parent 5017989 commit 2257be4
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions lgsm/functions/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fi

check_tmuxception.sh

if [ "$(whoami)" != "root" ]; then
if [ "$(whoami)" != "root" ] || [ -f /.dockerenv ]; then
if [ "${commandname}" != "MONITOR" ]; then
check_permissions.sh
fi
Expand All @@ -38,7 +38,7 @@ for allowed_command in "${allowed_commands_array[@]}"; do
fi
done

if [ "$(whoami)" != "root" ]; then
if [ "$(whoami)" != "root" ] || [ -f /.dockerenv ]; then
allowed_commands_array=(DEBUG START INSTALL)
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
Expand Down
2 changes: 1 addition & 1 deletion lgsm/functions/check_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ fn_deps_detector() {
}

if [ "${commandname}" == "INSTALL" ]; then
if [ "$(whoami)" == "root" ]; then
if [ "$(whoami)" == "root" ] && [ ! -f /.dockerenv ]; then
echo -e ""
echo -e "${lightyellow}Checking Dependencies as root${default}"
echo -e "================================="
Expand Down
2 changes: 1 addition & 1 deletion lgsm/functions/check_permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ fn_sys_perm_error_process() {
# Run perm error detect & fix/alert functions on /sys directories.

## Run checks.
if [ "$(whoami)" != "root" ]; then
if [ "$(whoami)" != "root" ] || [ -f /.dockerenv ]; then
fn_check_ownership
fn_check_permissions
if [ "${commandname}" == "START" ]; then
Expand Down
2 changes: 1 addition & 1 deletion lgsm/functions/check_root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"

if [ "$(whoami)" = "root" ]; then
if [ "$(whoami)" == "root" ] && [ ! -f /.dockerenv ]; then
if [ "${commandname}" != "INSTALL" ]; then
fn_print_fail_nl "Do NOT run this script as root!"
if [ -d "${lgsmlogdir}" ]; then
Expand Down
2 changes: 1 addition & 1 deletion lgsm/functions/command_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_firstcommand_set

check.sh
if [ "$(whoami)" = "root" ]; then
if [ "$(whoami)" == "root" ] && [ ! -f /.dockerenv ]; then
check_deps.sh
else
install_header.sh
Expand Down
2 changes: 1 addition & 1 deletion lgsm/functions/core_exit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn_exit_dev_debug() {
}

# If running dependency check as root will remove any files that belong to root user.
if [ "$(whoami)" == "root" ]; then
if [ "$(whoami)" == "root" ] && [ ! -f /.dockerenv ]; then
find "${lgsmdir}"/ -group root -prune -exec rm -rf {} + > /dev/null 2>&1
find "${logdir}"/ -group root -prune -exec rm -rf {} + > /dev/null 2>&1
fi
Expand Down
6 changes: 3 additions & 3 deletions lgsm/functions/core_steamcmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fn_update_steamcmd_remotebuild() {
fi

# Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD.
if [ "$(find "${HOME}" -type f -name "appinfo.vdf" | wc -l)" -ne "0" ]; then
if [ "$(find -L "${HOME}" -type f -name "appinfo.vdf" | wc -l)" -ne "0" ]; then
find "${HOME}" -type f -name "appinfo.vdf" -exec rm -f {} \;
fi

Expand Down Expand Up @@ -281,8 +281,8 @@ fn_update_steamcmd_compare() {
}

fn_appmanifest_info() {
appmanifestfile=$(find "${serverfiles}" -type f -name "appmanifest_${appid}.acf")
appmanifestfilewc=$(find "${serverfiles}" -type f -name "appmanifest_${appid}.acf" | wc -l)
appmanifestfile=$(find -L "${serverfiles}" -type f -name "appmanifest_${appid}.acf")
appmanifestfilewc=$(find -L "${serverfiles}" -type f -name "appmanifest_${appid}.acf" | wc -l)
}

fn_appmanifest_check() {
Expand Down
24 changes: 12 additions & 12 deletions linuxgsm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# Debugging
if [ -f ".dev-debug" ]; then
exec 5> dev-debug.log
exec 5>dev-debug.log
BASH_XTRACEFD="5"
set -x
fi
Expand Down Expand Up @@ -52,7 +52,7 @@ userinput2="${2}"
[ -n "${LGSM_GITHUBBRANCH}" ] && githubbranch="${LGSM_GITHUBBRANCH}" || githubbranch="master"

# Check that curl is installed before doing anything
if [ ! "$(command -v curl 2> /dev/null)" ]; then
if [ ! "$(command -v curl 2>/dev/null)" ]; then
echo -e "[ FAIL ] Curl is not installed"
exit 1
fi
Expand Down Expand Up @@ -213,7 +213,7 @@ fn_install_menu_bash() {
while read -r line || [[ -n "${line}" ]]; do
var=$(echo -e "${line}" | awk -F "," '{print $2 " - " $3}')
menu_options+=("${var}")
done < "${options}"
done <"${options}"
menu_options+=("Cancel")
select option in "${menu_options[@]}"; do
if [ "${option}" ] && [ "${option}" != "Cancel" ]; then
Expand All @@ -239,7 +239,7 @@ fn_install_menu_whiptail() {
key=$(echo -e "${line}" | awk -F "," '{print $3}')
val=$(echo -e "${line}" | awk -F "," '{print $2}')
menu_options+=("${val//\"/}" "${key//\"/}")
done < "${options}"
done <"${options}"
OPTION=$(${menucmd} --title "${title}" --menu "${caption}" "${height}" "${width}" "${menuheight}" "${menu_options[@]}" 3>&1 1>&2 2>&3)
if [ $? == 0 ]; then
eval "$resultvar=\"${OPTION}\""
Expand All @@ -263,12 +263,12 @@ fn_install_menu() {
fi
done
case "$(basename "${menucmd}")" in
whiptail | dialog)
fn_install_menu_whiptail "${menucmd}" selection "${title}" "${caption}" "${options}" 40 80 30
;;
*)
fn_install_menu_bash selection "${title}" "${caption}" "${options}"
;;
whiptail | dialog)
fn_install_menu_whiptail "${menucmd}" selection "${title}" "${caption}" "${options}" 40 80 30
;;
*)
fn_install_menu_bash selection "${title}" "${caption}" "${options}"
;;
esac
eval "$resultvar=\"${selection}\""
}
Expand Down Expand Up @@ -321,7 +321,7 @@ fn_install_file() {
}

# Prevent LinuxGSM from running as root. Except if doing a dependency install.
if [ "$(whoami)" == "root" ]; then
if [ "$(whoami)" == "root" ] && [ ! -f /.dockerenv ]; then
if [ "${userinput}" == "install" ] || [ "${userinput}" == "auto-install" ] || [ "${userinput}" == "i" ] || [ "${userinput}" == "ai" ]; then
if [ "${shortname}" == "core" ]; then
echo -e "[ FAIL ] Do NOT run this script as root!"
Expand Down Expand Up @@ -351,7 +351,7 @@ if [ "${shortname}" == "core" ]; then
} | column -s $'\t' -t | more
exit
elif [ "${userinput}" == "install" ] || [ "${userinput}" == "i" ]; then
tail -n +1 "${serverlist}" | awk -F "," '{print $1 "," $2 "," $3}' > "${serverlistmenu}"
tail -n +1 "${serverlist}" | awk -F "," '{print $1 "," $2 "," $3}' >"${serverlistmenu}"
fn_install_menu result "LinuxGSM" "Select game server to install." "${serverlistmenu}"
userinput="${result}"
fn_server_info
Expand Down

0 comments on commit 2257be4

Please sign in to comment.