mirror of
https://github.com/aclist/dztui.git
synced 2024-12-27 21:02:36 +01:00
fix(checks): Check vm.max_map_count
using cat
This solves multiple issues: - We don't need `sudo` to check the value anymore - Some systems may not have `sysctl` available - IDK about desktops, but my Debian server doesn't have this command (for whatever reason)
This commit is contained in:
parent
8dc9ad3313
commit
ae01c04caa
1 changed files with 14 additions and 10 deletions
24
dzgui.sh
24
dzgui.sh
|
@ -402,13 +402,19 @@ check_architecture(){
|
|||
}
|
||||
check_map_count(){
|
||||
[[ $is_steam_deck -gt 0 ]] && return 0
|
||||
local count=1048576
|
||||
local min_count=1048576
|
||||
local conf_file="/etc/sysctl.d/dayz.conf"
|
||||
if [[ -f $conf_file ]]; then
|
||||
logger DEBUG "System map count is already $count or higher"
|
||||
local current_count
|
||||
if [[ ! -f /proc/sys/vm/max_map_count ]]; then
|
||||
logger WARN "File \`/proc/sys/vm/max_map_count\` desn't exist!"
|
||||
return 1
|
||||
fi
|
||||
current_count=$(cat /proc/sys/vm/max_map_count)
|
||||
if [[ $current_count -ge $min_count ]]; then
|
||||
logger DEBUG "System map count is set to ${current_count}"
|
||||
return 0
|
||||
fi
|
||||
qdialog "sudo password required to check system vm map count." "OK" "Cancel"
|
||||
qdialog "sudo password required to set system vm map count." "OK" "Cancel"
|
||||
if [[ $? -eq 0 ]]; then
|
||||
local pass
|
||||
logger INFO "Prompting user for sudo escalation"
|
||||
|
@ -417,13 +423,11 @@ check_map_count(){
|
|||
logger WARN "User aborted password prompt"
|
||||
return 1
|
||||
fi
|
||||
local ct=$(sudo -S <<< "$pass" sh -c "sysctl -q vm.max_map_count | awk -F'= ' '{print \$2}'")
|
||||
logger DEBUG "Old map count is $ct"
|
||||
local new_ct
|
||||
[[ $ct -lt $count ]] && ct=$count
|
||||
sudo -S <<< "$pass" sh -c "echo 'vm.max_map_count=$ct' > $conf_file"
|
||||
logger DEBUG "Old map count is $current_count"
|
||||
[[ $current_count -lt $min_count ]] && current_count=$min_count
|
||||
sudo -S <<< "$pass" sh -c "echo 'vm.max_map_count=${current_count}' > $conf_file"
|
||||
sudo sysctl -p "$conf_file"
|
||||
logger DEBUG "Updated map count to $count"
|
||||
logger DEBUG "Updated map count to $min_count"
|
||||
else
|
||||
logger WARN "User aborted map count prompt"
|
||||
return 1
|
||||
|
|
Loading…
Reference in a new issue