host-ctr-scripts/ctr-delete-user.sh
Vincent Batts 1748fdcf26
initial commit
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2018-10-17 13:34:56 -04:00

19 lines
368 B
Bash

#!/bin/bash
set -e
user="${1}"
base_dir="/var/lib/machines"
base_subvol="bip.f28.ro"
if [ -z "${user}" ] ; then
echo Please provide the username to delete
exit 1
fi
new_subvol="$(echo ${base_subvol} | cut -d . -f 1)"."${user}"
userdel -r "${user}"
machinectl poweroff "${new_subvol}"
machinectl disable "${new_subvol}"
btrfs sub d "${base_dir}"/"${new_subvol}"