diff --git a/.gitignore b/.gitignore index 8d98f9d..b43c009 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .* +subvols/ diff --git a/bootstrap.fish b/bootstrap.fish index 45c97b9..6a9009e 100755 --- a/bootstrap.fish +++ b/bootstrap.fish @@ -13,8 +13,13 @@ end echo "Creating subvolume directory..." mkdir $subvoldir -for subvol in (get-subvols) +echo "Creating initial snapshots..." +for pair in (get-subvol-mounts) + set subvol (get-subvol $pair) + set mount (get-mount $pair) + set safename (clean-name $subvol) - echo "Creating initial snapshot for $subvol ($subvoldir/$safename)" - echo $subvol + set safepath $subvoldir/$safename + + sudo btrfs subvolume snapshot -r $mount $safepath end diff --git a/utils.fish b/utils.fish index 123eab7..0aee04c 100755 --- a/utils.fish +++ b/utils.fish @@ -1,7 +1,16 @@ #!/usr/bin/fish -function get-subvols - cat /etc/fstab | grep subvol | sed 's/.*subvol=//;s/)//;s/\t\| \|0//g' +function get-subvol-mounts + #cat /etc/fstab | grep subvol | sed 's/.*subvol=//;s/)//;s/\t\| \|0//g' + cat /etc/fstab | grep btrfs | cut -d\t -f2,4 | sed 's/\(.*\)\t.*,subvol=\(.*\)$/\2 \1/' +end + +function get-subvol + echo $argv | cut -d' ' -f1 +end + +function get-mount + echo $argv | cut -d' ' -f2 end function clean-name