Skip to content

Commit

Permalink
feat: allow running as root when in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
dgibbs64 committed Oct 21, 2022
1 parent 743ec4e commit 09d0a88
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
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
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 09d0a88

Please sign in to comment.