diff --git a/dzgui.sh b/dzgui.sh index 24dcd48..b80a0aa 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/bin/bash set -o pipefail -version=3.2.6 +version=3.2.7 aid=221100 game="dayz" @@ -1724,12 +1724,24 @@ setup(){ check_map_count(){ count=1048576 echo "[DZGUI] Checking system map count" - if [[ $(sudo sysctl -q vm.max_map_count | awk -F"= " '{print $2}') -lt $count ]]; then - $steamsafe_zenity --question --width 500 --title="DZGUI" --text "System map count must be $count or higher to run DayZ with Wine.\nIncrease map count and make this change permanent? (will prompt for sudo password)" 2>/dev/null - if [[ $? -eq 0 ]]; then - pass=$($steamsafe_zenity --password) - sudo -S <<< "$pass" sh -c "echo 'vm.max_map_count=1048576' > /etc/sysctl.d/dayz.conf" - sudo sysctl -p /etc/sysctl.d/dayz.conf + if [[ ! -f /etc/sysctl.d/dayz.conf ]]; then + if [[ $parent != "bash" ]]; then + $steamsafe_zenity --question --width 500 --title="DZGUI" --text "sudo password required to check system vm map count." 2>/dev/null + if [[ $? -eq 0 ]]; then + pass=$($steamsafe_zenity --password) + local ct=$(sudo -S <<< "$pass" sh -c "sudo sysctl -q vm.max_map_count | awk -F"= " '{print $2}')") + if [[ $ct -lt $count ]]; then + sudo sysctl -p /etc/sysctl.d/dayz.conf + pass=$($steamsafe_zenity --password) + fi + else + return + fi + else + if [[ $(sudo sysctl -q vm.max_map_count | awk -F"= " '{print $2}') -lt $count ]]; then + sudo echo 'vm.max_map_count=1048576' > /etc/sysctl.d/dayz.conf + sudo sysctl -p /etc/sysctl.d/dayz.conf + fi fi fi } @@ -1827,4 +1839,5 @@ main(){ #TODO: tech debt: cruddy handling for steam forking [[ $? -eq 1 ]] && pkill -f dzgui.sh } +parent=$(cat /proc/$PPID/comm) main