diff --git a/bootstrap.fish b/bootstrap.fish index f5ec9a7..45c97b9 100755 --- a/bootstrap.fish +++ b/bootstrap.fish @@ -3,14 +3,18 @@ set scriptdir (dirname (status --current-filename)) source $scriptdir/config.fish +source $scriptdir/utils.fish if test -d $subvoldir echo "Backup directory already exists, aborting..." exit end +echo "Creating subvolume directory..." mkdir $subvoldir -for subvol in (eval $scriptdir/get-subvols.fish) +for subvol in (get-subvols) + set safename (clean-name $subvol) + echo "Creating initial snapshot for $subvol ($subvoldir/$safename)" echo $subvol end diff --git a/clean-names.fish b/clean-names.fish deleted file mode 100755 index 42b6f83..0000000 --- a/clean-names.fish +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/fish -sed 's/\//-/g' diff --git a/get-subvols.fish b/get-subvols.fish deleted file mode 100755 index a4225da..0000000 --- a/get-subvols.fish +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/fish -cat /etc/fstab | grep subvol | sed 's/.*subvol=//;s/)//;s/\t\| \|0//g' diff --git a/utils.fish b/utils.fish new file mode 100755 index 0000000..123eab7 --- /dev/null +++ b/utils.fish @@ -0,0 +1,9 @@ +#!/usr/bin/fish + +function get-subvols + cat /etc/fstab | grep subvol | sed 's/.*subvol=//;s/)//;s/\t\| \|0//g' +end + +function clean-name + echo $argv | sed 's/\//-/g' +end