1
0
Fork 0
mirror of https://github.com/aclist/dztui.git synced 2025-01-01 15:12:05 +01:00

Exit handling

This commit is contained in:
aclist 2022-10-08 11:30:13 +09:00
parent 0998b43c01
commit f60857a64a

View file

@ -27,9 +27,7 @@ steamcmd_modlist(){
move_files(){ move_files(){
printf "\n" printf "\n"
log "Moving mods from $staging_dir to $workshop_dir" log "Moving mods from $staging_dir to $workshop_dir"
if [[ $dist == "steamos" ]]; then if [[ $staging_dir == "/tmp" ]]; then
chown -R $USER:$gid "$staging_dir"/steamapps
else
sudo chown -R $USER:$gid "$staging_dir"/steamapps sudo chown -R $USER:$gid "$staging_dir"/steamapps
fi fi
cp -R "$staging_dir"/steamapps/workshop/content/$aid/* "$workshop_dir" cp -R "$staging_dir"/steamapps/workshop/content/$aid/* "$workshop_dir"
@ -63,12 +61,17 @@ move_files(){
# done # done
#} #}
test_dir(){ test_dir(){
[[ $dist == "steamos" ]] && { staging_dir="/tmp"; return 0; } if [[ $dist == "steamos" ]]; then
staging_dir="$HOME/.local/share/dzgui/mods"
mkdir -p $staging_dir
return 0
fi
sudo -u steam test -w "$staging_dir" sudo -u steam test -w "$staging_dir"
rc=$? rc=$?
if [[ $rc -eq 1 ]]; then if [[ $rc -eq 1 ]]; then
fail "User '$steamcmd_user' does not have write access to $staging_dir. Reverting to /tmp" fail "User '$steamcmd_user' does not have write access to $staging_dir. Reverting to /tmp"
staging_dir="/tmp" staging_dir="/tmp"
return 0
fi fi
} }
auto_mod_download(){ auto_mod_download(){
@ -79,9 +82,7 @@ auto_mod_download(){
done done
if [[ -d "$staging_dir/steamapps" ]]; then if [[ -d "$staging_dir/steamapps" ]]; then
log "Sanitizing $staging_dir" log "Sanitizing $staging_dir"
if [[ $dist == "steamos" ]]; then if [[ $staging_dir == "/tmp" ]]; then
chown -R $USER:$gid "$staging_dir"/steamapps
else
sudo chown -R $USER:$gid "$staging_dir"/steamapps sudo chown -R $USER:$gid "$staging_dir"/steamapps
fi fi
rm -r "$staging_dir"/steamapps rm -r "$staging_dir"/steamapps
@ -274,14 +275,16 @@ check_dist(){
} }
return_to_dzg(){ return_to_dzg(){
if [[ $ret -eq 1 ]]; then if [[ $ret -eq 1 ]]; then
fail "Errors occurred. Type any key to return to DZGUI and kick off manual install." fail "Errors occurred."
else else
pass "Mods installed successfully. Type any key to return to DZGUI." pass "Mods installed successfully."
fi fi
read -n1 key # read -n1 key
case $key in # case $key in
*) exit 1 ;; # *) exit 0 ;;
esac # esac
zenity --text-info --title="DZGUI" --width=390 --height=452 --html --filename="$HOME/.local/share/dzgui/helpers/d.webp" --cancel-label="OK"
return 0
} }
cleanup(){ cleanup(){
tput cnorm tput cnorm