Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

Commit

Permalink
Improve subvolume deletion
Browse files Browse the repository at this point in the history
If a subvolume is not mounted, then grep will fail while setting
'devpath', causing the script to error out. Turn this into a conditional
so that the non-zero return code from grep does not exit the current
script.
  • Loading branch information
K Jonathan Harker committed Jun 4, 2019
1 parent ac55b6e commit f699164
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ restore_and_reboot() {
delete_subvolume(){
if [ -d "$1" ]; then
init
devpath=$(grep $1 /proc/mounts | awk '{print $1}')
mount $devpath $2 -o subvol="/@"
btrfs subvolume delete "$2/$1" || true
umount "$2" || true
if devpath=$(grep $1 /proc/mounts | awk '{print $1}') ; then
mount $devpath $2 -o subvol="/@"
btrfs subvolume delete "$2/$1" || true
umount "$2" || true
fi
fi
}

Expand Down

0 comments on commit f699164

Please sign in to comment.