mirror of
https://github.com/aclist/dztui.git
synced 2025-01-01 15:12:05 +01:00
fix: sudo escalation
This commit is contained in:
parent
9fee338ba4
commit
1e1f647eb7
1 changed files with 20 additions and 7 deletions
27
dzgui.sh
27
dzgui.sh
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
version=3.2.6
|
version=3.2.7
|
||||||
|
|
||||||
aid=221100
|
aid=221100
|
||||||
game="dayz"
|
game="dayz"
|
||||||
|
@ -1724,12 +1724,24 @@ setup(){
|
||||||
check_map_count(){
|
check_map_count(){
|
||||||
count=1048576
|
count=1048576
|
||||||
echo "[DZGUI] Checking system map count"
|
echo "[DZGUI] Checking system map count"
|
||||||
if [[ $(sudo sysctl -q vm.max_map_count | awk -F"= " '{print $2}') -lt $count ]]; then
|
if [[ ! -f /etc/sysctl.d/dayz.conf ]]; 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 [[ $parent != "bash" ]]; then
|
||||||
if [[ $? -eq 0 ]]; then
|
$steamsafe_zenity --question --width 500 --title="DZGUI" --text "sudo password required to check system vm map count." 2>/dev/null
|
||||||
pass=$($steamsafe_zenity --password)
|
if [[ $? -eq 0 ]]; then
|
||||||
sudo -S <<< "$pass" sh -c "echo 'vm.max_map_count=1048576' > /etc/sysctl.d/dayz.conf"
|
pass=$($steamsafe_zenity --password)
|
||||||
sudo sysctl -p /etc/sysctl.d/dayz.conf
|
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
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -1827,4 +1839,5 @@ main(){
|
||||||
#TODO: tech debt: cruddy handling for steam forking
|
#TODO: tech debt: cruddy handling for steam forking
|
||||||
[[ $? -eq 1 ]] && pkill -f dzgui.sh
|
[[ $? -eq 1 ]] && pkill -f dzgui.sh
|
||||||
}
|
}
|
||||||
|
parent=$(cat /proc/$PPID/comm)
|
||||||
main
|
main
|
||||||
|
|
Loading…
Reference in a new issue