Use functions

This commit is contained in:
Les De Ridder 2016-05-04 23:15:35 +00:00
parent a7bb5cfd85
commit bd767dac81
4 changed files with 14 additions and 5 deletions

View File

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

View File

@ -1,2 +0,0 @@
#!/usr/bin/fish
sed 's/\//-/g'

View File

@ -1,2 +0,0 @@
#!/usr/bin/fish
cat /etc/fstab | grep subvol | sed 's/.*subvol=//;s/)//;s/\t\| \|0//g'

9
utils.fish Executable file
View File

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