Cosmetics.
authorFrancois Fleuret <francois@fleuret.org>
Mon, 31 Jul 2017 22:37:34 +0000 (00:37 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Mon, 31 Jul 2017 22:37:34 +0000 (00:37 +0200)
luks_toolbox.sh

index ac4e3a2..ac3f8e6 100755 (executable)
@@ -50,12 +50,14 @@ EOF
 
 ######################################################################
 
-if [[ "$@" == "" ]]; then
+if [[ "$@" == "" ]]
+then
     print_help >&2
     exit 1
 fi
 
-if [[ ! $(id -u) == 0 ]]; then
+if [[ ! $(id -u) == 0 ]]
+then
     echo "This command should be run as root (no offense, but you are $(id -un))." >&2
     exit 1
 fi
@@ -69,19 +71,22 @@ case $1 in
         # mount | grep ^'/dev/dm-[0-9]*' | sed -e 's/^.* on \([^ ]*\) .*$/\1/' | \
 
         mount | grep ^'/dev/mapper' | sed -e 's/^.* on \([^ ]*\) .*$/\1/' | \
-            while read line; do
+            while read line
+            do
                 echo "umount ${line}"
                 umount ${line}
             done
 
         \ls /dev/mapper | grep -v ^control$ | \
-            while read line; do
+            while read line
+            do
                 echo "cryptsetup luksClose ${line[0]}"
                 cryptsetup luksClose "${line[0]}"
             done
 
         losetup -a | sed -e "s/:.*$//" | \
-            while read line; do
+            while read line
+            do
                 echo "losetup -d ${line}"
                 losetup -d ${line}
             done
@@ -109,7 +114,8 @@ case $1 in
 
         read -n 1 KEY
 
-        if [[ ! "${KEY}" == "y" ]]; then
+        if [[ ! "${KEY}" == "y" ]]
+        then
             echo "Cancelled!"
             exit 1
         fi
@@ -144,7 +150,8 @@ case $1 in
 
         read -n 1 KEY
 
-        if [[ "${KEY}" == "y" ]]; then
+        if [[ "${KEY}" == "y" ]]
+        then
             echo
             rsync --itemize-changes --delete --progress -axz "${DIR_MOUNT_SRC}/" "${DIR_MOUNT_DST}/"
         else
@@ -170,19 +177,22 @@ case $1 in
 
         shift
 
-        if [[ "$1" == "-f" ]]; then
+        if [[ "$1" == "-f" ]]
+        then
             force="-f"
             shift
         fi
 
-        if [[ ! -a "$1" ]]; then
+        if [[ ! -a "$1" ]]
+        then
             echo "Cannot find file \`$1'." >&2
             exit 1
         fi
 
         [[ -e "/dev/mapper/crypt-dst" ]] && (echo "/dev/mapper/crypt-dst already exists." >&2 && exit 1)
 
-        if [[ -f "$1" ]]; then
+        if [[ -f "$1" ]]
+        then
             LOOP_DST="$(losetup -f)"
             losetup "${LOOP_DST}" "$1"
             DEVICE="${LOOP_DST}"
@@ -198,7 +208,8 @@ case $1 in
 
         cryptsetup luksClose crypt-dst
 
-        if [[ "${LOOP_DST}" ]]; then
+        if [[ "${LOOP_DST}" ]]
+        then
             losetup -d "${LOOP_DST}" && unset LOOP_DST
         fi
 
@@ -210,7 +221,8 @@ case $1 in
 
     mount|umount)
 
-        if [[ "$1" == "umount" ]]; then
+        if [[ "$1" == "umount" ]]
+        then
             umount=yes
         fi
 
@@ -219,11 +231,13 @@ case $1 in
         mount_point=$(echo $1 | sed -e "s;/*$;;")
         device=$(grep ^/ /etc/fstab | awk '{ print $2" "$1 }' | grep ^${mount_point} | cut -f 2 -d " ")
 
-        if [[ ${device} =~ ^/dev/mapper ]]; then
+        if [[ ${device} =~ ^/dev/mapper ]]
+        then
 
             mapped_device=${device/'/dev/mapper/'/}
 
-            if [[ ${umount} ]]; then
+            if [[ ${umount} ]]
+            then
                 cat <<EOF
 Attempting to unmount
    ${mount_point}.