add hardcoded fallback temp dir

This commit is contained in:
throwaway96 2024-04-20 14:15:00 -04:00
parent 9e1a33c459
commit f691f134f6
1 changed files with 6 additions and 5 deletions

View File

@ -56,13 +56,14 @@ toast 'Script is running!'
umask 022
if ! tempdir="$(mktemp -d)"; then
echo '[x] Failed to create random temporary directory; using fallback'
if ! tempdir="$(mktemp -d -- '/tmp/autoroot.XXXXXX')"; then
echo '[x] Failed to create random temporary directory; using PID-based fallback'
tempdir="/tmp/autoroot.${$}"
if ! mkdir -- "${tempdir}"; then
echo "[!] Fallback temporary directory ${tempdir} already exists"
toast "Fallback temporary directory ${tempdir} already exists"
exit 1
echo "[x] PID-based fallback temporary directory ${tempdir} already exists"
tempdir='/tmp/autoroot.temp'
rm -rf -- "${tempdir}"
mkdir -- "${tempdir}"
fi
fi