Skip to content

Instantly share code, notes, and snippets.

@mwyau
Forked from steveh/etc-samba-smb.conf
Created May 23, 2021 16:03
Show Gist options
  • Select an option

  • Save mwyau/02a9ad5164986fcfaa133e34c7b8b489 to your computer and use it in GitHub Desktop.

Select an option

Save mwyau/02a9ad5164986fcfaa133e34c7b8b489 to your computer and use it in GitHub Desktop.
Samba dfree and zfs on Ubuntu 14.04
# File: /etc/samba/smb.conf
dfree command = /usr/local/bin/dfree
# File: /etc/sudoers
ALL ALL = NOPASSWD: /usr/local/bin/zfs-get-used, /usr/local/bin/zfs-get-available
#!/bin/bash
# File: /usr/local/bin/dfree
CUR_PATH=$PWD
FILESYSTEM=$(df -PT $CUR_PATH | tail -1 | awk '{print $2}')
if [ $FILESYSTEM = 'zfs' ]; then
USED=$(sudo zfs-get-used $CUR_PATH)
AVAIL=$(sudo zfs-get-available $CUR_PATH)
AVAIL_KB=$(expr $AVAIL / 1024)
TOTAL_KB=$(expr $USED / 1024 + $AVAIL / 1024)
echo $TOTAL_KB $AVAIL_KB
else
df -PT $CUR_PATH | tail -1 | awk '{print $3" "$5}'
fi
#!/bin/bash
# File: /usr/local/bin/zfs-get-available
zfs get -o value -Hp available $1
#!/bin/bash
# File: /usr/local/bin/zfs-get-used
zfs get -o value -Hp used $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment