Implement bootstrap

This commit is contained in:
Les De Ridder 2016-05-05 00:04:21 +00:00
parent bd767dac81
commit 783414ce40
3 changed files with 20 additions and 5 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.*
subvols/

View File

@ -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

View File

@ -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