4 Commits dd617bc627 ... 8c260debe3

Tác giả SHA1 Thông báo Ngày
  Vinicius Teshima 8c260debe3 Fixing Size test when creating file 10 tháng trước cách đây
  Vinicius Teshima 3feddccf3f Checking for folder existing on mount function 10 tháng trước cách đây
  Vinicius Teshima a31a8baabe Fixing rmdir cmd 10 tháng trước cách đây
  Vinicius Teshima 93838b75a9 Fixing directory permission check 10 tháng trước cách đây
1 tập tin đã thay đổi với 6 bổ sung7 xóa
  1. 6 7
      luks.sh

+ 6 - 7
luks.sh

@@ -18,8 +18,11 @@ TRY_AND_RETRY () {
 }
 
 sudo_prog='sudo --prompt=Sudo_Password:'
+cur_uid="$(id -u)"
+cur_gid="$(id -g)"
 
 _MOUNT () {
+	test -e "${2}" || TRY_AND_RETRY "mkdir ${2}" "Failed to create directory: ${2}"
 	echo "Mounting ${1} into ${2}"
 	TRY_AND_RETRY "${sudo_prog} mount ${1} ${2}" "Failed to mound ${1} on ${2}."
 	echo "Succesfully Mounted ${1} into ${2}"
@@ -34,7 +37,7 @@ _LUKS_OPEN () {
 _CHECK_DIR_PERM () {
 	dir_perm="$(stat -c '%u:%g' "${1}")"
 	cur_perm="${cur_uid}:${cur_gid}"
-	test "$dir_perm" = "$cur_perm" || return 0
+	test "$dir_perm" = "$cur_perm" && return 0
 	echo -n "Directory ${1} is not owned by current user. Want to change direcory owner? (Y/n) "
 	read choose
 	case "$choose" in
@@ -51,8 +54,6 @@ name="$(echo "$file" | cut -d. -f1)"
 _name="__${name}__"
 ext="$(echo "$file" | cut -d. -f2)"
 block_dev="/dev/mapper/${_name}"
-cur_uid="$(id -u)"
-cur_gid="$(id -g)"
 
 test "$ext" = 'luks' || ERR "File $file_path does not have extencion .luks." 1
 
@@ -81,11 +82,9 @@ then
 			N|n) exit 0 ;;
 		esac
 
-		TRY_AND_RETRY rmdir "./${name}" "Failed to remove directory: ./${name}"
+		TRY_AND_RETRY "rmdir ./${name}" "Failed to remove directory: ./${name}"
 		exit 0
 	fi
-else
-	mkdir ./"$name"
 fi
 
 if test -e "$file_path"
@@ -103,7 +102,7 @@ else
 
 	echo -n "What size? (10G) "
 	read _size
-	if test "$choose" = ''
+	if test "$_size" = ''
 	then
 		_size='10G'
 	fi