aboutsummaryrefslogblamecommitdiff
path: root/lib/50-zfs
blob: 2948601c11c89ae6fe66dc2c8f11684eab7b7429 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                                                
#!/bin/sh

dataset_exists(){
  # Check if a ZFS dataset exists.
  # $1 = dataset name
  zfs list "$1" > /dev/null 2>&1
}

create_dataset(){
  # Create a ZFS dataset if it doesn't already exists.
  # All options are passed directly to `zfs create`. Assumes the dataset name is
  # passed as the final argument.
  eval "_bccd_dataset=\$$#"
  dataset_exists "$_bccd_dataset" || zfs create -v "$@"
}