Check if user has sudo rights and keep sudo from timing out

This commit is contained in:
RealStickman 2023-05-21 16:36:52 +02:00
parent d2a9f4443b
commit d1c1c51a5e

View File

@ -4,6 +4,22 @@
# NOTE ignore errors from missing "||". Try getting the line below to work
#set -euo pipefail
# function to keep sudo from timing out
function func_dont_timeout {
while true; do
sudo -v
sleep 60
done
}
# check if user is root
if [ "$EUID" -ne 0 ]; then
sudo -v
fi
# keep sudo active in background
func_dont_timeout &
# get current directory
setupdir=$(pwd)