Skip to content

Commit 2257be4

Browse files
committed
fix: add docker compatibility
fix: allow find to search in symlinks
1 parent 5017989 commit 2257be4

8 files changed

+22
-22
lines changed

lgsm/functions/check.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fi
2121

2222
check_tmuxception.sh
2323

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

41-
if [ "$(whoami)" != "root" ]; then
41+
if [ "$(whoami)" != "root" ] || [ -f /.dockerenv ]; then
4242
allowed_commands_array=(DEBUG START INSTALL)
4343
for allowed_command in "${allowed_commands_array[@]}"; do
4444
if [ "${allowed_command}" == "${commandname}" ]; then

lgsm/functions/check_deps.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ fn_deps_detector() {
301301
}
302302

303303
if [ "${commandname}" == "INSTALL" ]; then
304-
if [ "$(whoami)" == "root" ]; then
304+
if [ "$(whoami)" == "root" ] && [ ! -f /.dockerenv ]; then
305305
echo -e ""
306306
echo -e "${lightyellow}Checking Dependencies as root${default}"
307307
echo -e "================================="

lgsm/functions/check_permissions.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ fn_sys_perm_error_process() {
226226
# Run perm error detect & fix/alert functions on /sys directories.
227227

228228
## Run checks.
229-
if [ "$(whoami)" != "root" ]; then
229+
if [ "$(whoami)" != "root" ] || [ -f /.dockerenv ]; then
230230
fn_check_ownership
231231
fn_check_permissions
232232
if [ "${commandname}" == "START" ]; then

lgsm/functions/check_root.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

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

10-
if [ "$(whoami)" = "root" ]; then
10+
if [ "$(whoami)" == "root" ] && [ ! -f /.dockerenv ]; then
1111
if [ "${commandname}" != "INSTALL" ]; then
1212
fn_print_fail_nl "Do NOT run this script as root!"
1313
if [ -d "${lgsmlogdir}" ]; then

lgsm/functions/command_install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
1111
fn_firstcommand_set
1212

1313
check.sh
14-
if [ "$(whoami)" = "root" ]; then
14+
if [ "$(whoami)" == "root" ] && [ ! -f /.dockerenv ]; then
1515
check_deps.sh
1616
else
1717
install_header.sh

lgsm/functions/core_exit.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn_exit_dev_debug() {
1818
}
1919

2020
# If running dependency check as root will remove any files that belong to root user.
21-
if [ "$(whoami)" == "root" ]; then
21+
if [ "$(whoami)" == "root" ] && [ ! -f /.dockerenv ]; then
2222
find "${lgsmdir}"/ -group root -prune -exec rm -rf {} + > /dev/null 2>&1
2323
find "${logdir}"/ -group root -prune -exec rm -rf {} + > /dev/null 2>&1
2424
fi

lgsm/functions/core_steamcmd.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn_update_steamcmd_remotebuild() {
174174
fi
175175

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

@@ -281,8 +281,8 @@ fn_update_steamcmd_compare() {
281281
}
282282

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

288288
fn_appmanifest_check() {

linuxgsm.sh

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# Debugging
1717
if [ -f ".dev-debug" ]; then
18-
exec 5> dev-debug.log
18+
exec 5>dev-debug.log
1919
BASH_XTRACEFD="5"
2020
set -x
2121
fi
@@ -52,7 +52,7 @@ userinput2="${2}"
5252
[ -n "${LGSM_GITHUBBRANCH}" ] && githubbranch="${LGSM_GITHUBBRANCH}" || githubbranch="master"
5353

5454
# Check that curl is installed before doing anything
55-
if [ ! "$(command -v curl 2> /dev/null)" ]; then
55+
if [ ! "$(command -v curl 2>/dev/null)" ]; then
5656
echo -e "[ FAIL ] Curl is not installed"
5757
exit 1
5858
fi
@@ -213,7 +213,7 @@ fn_install_menu_bash() {
213213
while read -r line || [[ -n "${line}" ]]; do
214214
var=$(echo -e "${line}" | awk -F "," '{print $2 " - " $3}')
215215
menu_options+=("${var}")
216-
done < "${options}"
216+
done <"${options}"
217217
menu_options+=("Cancel")
218218
select option in "${menu_options[@]}"; do
219219
if [ "${option}" ] && [ "${option}" != "Cancel" ]; then
@@ -239,7 +239,7 @@ fn_install_menu_whiptail() {
239239
key=$(echo -e "${line}" | awk -F "," '{print $3}')
240240
val=$(echo -e "${line}" | awk -F "," '{print $2}')
241241
menu_options+=("${val//\"/}" "${key//\"/}")
242-
done < "${options}"
242+
done <"${options}"
243243
OPTION=$(${menucmd} --title "${title}" --menu "${caption}" "${height}" "${width}" "${menuheight}" "${menu_options[@]}" 3>&1 1>&2 2>&3)
244244
if [ $? == 0 ]; then
245245
eval "$resultvar=\"${OPTION}\""
@@ -263,12 +263,12 @@ fn_install_menu() {
263263
fi
264264
done
265265
case "$(basename "${menucmd}")" in
266-
whiptail | dialog)
267-
fn_install_menu_whiptail "${menucmd}" selection "${title}" "${caption}" "${options}" 40 80 30
268-
;;
269-
*)
270-
fn_install_menu_bash selection "${title}" "${caption}" "${options}"
271-
;;
266+
whiptail | dialog)
267+
fn_install_menu_whiptail "${menucmd}" selection "${title}" "${caption}" "${options}" 40 80 30
268+
;;
269+
*)
270+
fn_install_menu_bash selection "${title}" "${caption}" "${options}"
271+
;;
272272
esac
273273
eval "$resultvar=\"${selection}\""
274274
}
@@ -321,7 +321,7 @@ fn_install_file() {
321321
}
322322

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

0 commit comments

Comments
 (0)