diff --git a/lib/bkctld-inc b/lib/bkctld-inc index 94ae9a2..049e5cf 100755 --- a/lib/bkctld-inc +++ b/lib/bkctld-inc @@ -15,10 +15,9 @@ create_inc_btrfs() { inc_path=$(inc_path "${jail_name}" "${inc_name}") btrfs_bin=$(command -v btrfs) - ### Pseudo-code - # if [ -z "${btrfs_bin}" ]; then - # error "Can't find btrfs" - # fi + if [ -z "${btrfs_bin}" ]; then + error "btrfs not found. Please install brtfs-progs." + fi if dry_run; then echo "[dry-run] btrfs subvolume snapshot of ${jail_path} to ${inc_path}" diff --git a/lib/bkctld-inc-lock b/lib/bkctld-inc-lock index 6e69196..a71edf0 100755 --- a/lib/bkctld-inc-lock +++ b/lib/bkctld-inc-lock @@ -12,8 +12,12 @@ target_path="${2:?}" lock_target() { target="${1:?}" + btrfs_bin=$(command -v btrfs) + if [ -z ${btrfs_bin} ]; then + error "btrfs not found. Please install brtfs-progs." + fi if is_btrfs "${target}"; then - btrfs property set -ts "${target}" ro true + ${btrfs_bin} property set -ts "${target}" ro true info "Lock ${target}: done". else info "Lock ${target}: not BTRFS, nothing done". @@ -21,8 +25,12 @@ lock_target() { } unlock_target() { target="${1:?}" + btrfs_bin=$(command -v btrfs) + if [ -z ${btrfs_bin} ]; then + error "btrfs not found. Please install brtfs-progs." + fi if is_btrfs "${target}"; then - btrfs property set -ts "${target}" ro false + ${btrfs_bin} property set -ts "${target}" ro false info "Unlock ${target}: done." else info "Unlock ${target}: not BTRFS, nothing done." diff --git a/lib/bkctld-init b/lib/bkctld-init index 6b52815..1e35f19 100755 --- a/lib/bkctld-init +++ b/lib/bkctld-init @@ -18,9 +18,13 @@ test -d "${jail_path}" && error "Skip jail \`${jail_name}' : it already exists" # Create config and jails directory mkdir --parents "${CONFDIR}" "${JAILDIR}" +btrfs_bin=$(command -v btrfs) +if [ -z ${btrfs_bin} ]; then + error "btrfs not found. Please install brtfs-progs." +fi if is_btrfs "$(dirname "${JAILDIR}")" || is_btrfs "${JAILDIR}"; then - /bin/btrfs subvolume create "${jail_path}" + ${btrfs_bin} subvolume create "${jail_path}" else mkdir --parents "${jail_path}" fi diff --git a/lib/bkctld-remove b/lib/bkctld-remove index dab3b6c..731d414 100755 --- a/lib/bkctld-remove +++ b/lib/bkctld-remove @@ -52,9 +52,13 @@ fi rm -f "${CONFDIR}/${jail_name}" rm -rf "$(jail_config_dir "${jail_name}")" -jail_inode=$(stat --format=%i "${jail_path}") -if [ "${jail_inode}" -eq 256 ]; then - /bin/btrfs subvolume delete "${jail_path}" | debug +btrfs_bin=$(command -v btrfs) +if [ -z ${btrfs_bin} ]; then + error "btrfs not found. Please install brtfs-progs." +fi + +if is_btrfs "${jail_path}"; then + ${btrfs_bin} subvolume delete "${jail_path}" | debug else rm -rf "${jail_path:?}" | debug fi @@ -65,7 +69,7 @@ if [ -d "${incs_path}" ]; then for inc in ${incs}; do inc_inode=$(stat --format=%i "${incs_path}/${inc}") if [ "${inc_inode}" -eq 256 ]; then - /bin/btrfs subvolume delete "${incs_path}/${inc}" | debug + ${btrfs_bin} subvolume delete "${incs_path}/${inc}" | debug else warning "You need to purge \`${incs_path}/${inc}' manually" fi diff --git a/lib/bkctld-rm b/lib/bkctld-rm index 7b1df54..926877e 100755 --- a/lib/bkctld-rm +++ b/lib/bkctld-rm @@ -61,11 +61,16 @@ delete_inc_btrfs() { inc_name=$2 inc_path=$(inc_path "${jail_name}" "${inc_name}") + btrfs_bin=$(command -v btrfs) + + if [ -z ${btrfs_bin} ]; then + error "btrfs not found. Please install brtfs-progs." + fi if dry_run; then echo "[dry-run] delete btrfs subvolume ${inc_path}" else - /bin/btrfs subvolume delete "${inc_path}" | debug + ${btrfs_bin} subvolume delete "${inc_path}" | debug fi } delete_inc_ext4() {