Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add free disk space startup check #351

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions kiauh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function kiauh_update_dialog() {
}

check_euid
check_free_space
init_logfile
set_globals
kiauh_update_dialog
Expand Down
23 changes: 23 additions & 0 deletions scripts/utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,29 @@ function check_euid() {
fi
}

function check_free_space() {
local mount_free mb_rec=2048
local mount_check_regex='^/($|bin|etc|home|lib|mnt|opt|root|sbin|tmp|usr|var)' # all root dirs possibly relevant to software install
for mount_check in $(cat /etc/mtab | grep '^/dev' | cut -d ' ' -f 2 | grep -E '${mount_check_regex}'); do
mount_free=$(($(df -Pk ${mount_check} | sed 1d | grep -v used | awk '{ print $4 "\t" }')/1024))
if [[ ${mount_free} -lt ${mb_req} ]]; then
local yn
while true; do
echo -e "${yellow}Heads up! Free disk space in ${white}${mount_check}${yellow} is only ${white}${mount_free} MB${yellow}.${white}"
read -p "${yellow}You may run into errors installing or updating software that uses this mountpoint. Proceed? (y|N): ${white}" yn
case "${yn}" in
Y|y|Yes|yes)
break;;
N|n|No|no|"")
exit 1;;
*)
echo -e "${red}Please answer "y" or "n"${white}";;
esac
done
fi
done
}

#================================================#
#============= MESSAGE FORMATTING ===============#
#================================================#
Expand Down