Skip to content

Commit

Permalink
fix: Check if path to sgoinfre directory even exists
Browse files Browse the repository at this point in the history
  • Loading branch information
itislu committed Apr 29, 2024
1 parent 30fb076 commit 3cf44f4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion 42free.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ script_path="$script_dir/42free.sh"
sgoinfre_root="/sgoinfre/goinfre/Perso/$USER"
sgoinfre_alt="/nfs/sgoinfre/goinfre/Perso/$USER"
sgoinfre="$sgoinfre_root"
sgoinfre_permissions=$(stat -c "%A" "$sgoinfre")
sgoinfre_permissions=$(stat -c "%A" "$sgoinfre" 2>/dev/null)

# Shell config files
bash_config="$HOME/.bashrc"
Expand Down Expand Up @@ -691,6 +691,16 @@ fi

print_update_info "remind"

# Check if sgoinfre exists
if [[ ! -d "$sgoinfre" ]]; then
pretty_print "$indicator_error${sty_bol} There does not seem to be a sgoinfre directory available on your campus.${sty_res}"
pretty_print "If you are sure there is one, please open an issue on GitHub and mention the following things:"
pretty_print " - The campus you are on."
pretty_print " - The path to your sgoinfre directory."
pretty_print "${sty_und}${sty_bri_blu}https://github.com/itislu/42free/issues${sty_res}"
ft_exit $major_error
fi

# Check if the permissions of user's sgoinfre directory are rwx------
if ! $restore && [[ "$sgoinfre_permissions" != "drwx------" ]]; then
pretty_print "$msg_sgoinfre_permissions"
Expand Down

0 comments on commit 3cf44f4

Please sign in to comment.