# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-[[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
+[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+set -e; . /usr/local/lib/bash-bear; set +e
-# usage install-chboot: isntalls chboot to all /boot subvols,
-# in case there is an issue booting and it is needed.
-# Run this when chboot changes.
+usage() {
+ cat <<'EOF'
+Usage: isntall-chboot [-h|--help]
+reinstall chboot to /boot subvols, for chboot updates.
+
+We install to /boot in case there is an issue booting and only the /boot
+vol is readily available. For the bootstrap subvol, this is the normal
+case.
+EOF
+ exit 0
+}
+case $1 in
+ -h|--help) usage ;;
+esac
-cd "${BASH_SOURCE%/*}"
e() { echo "$@"; "$@"; }
e mount -o subvolid=0 $boot_dev $mount_point
shopt -s nullglob
-for dir in $mount_point/*; do
+for dir in "$mount_point"/*; do
btrfs subvol show $dir &>/dev/null || continue
if [[ -e $dir/boot ]]; then
dir=$dir/boot