enable ecne and noble
[automated-distro-installer] / install-chboot
index d066101642454420d7664649dbc1f9fc88d61104..041302df3904e109b8b669dfb113551904eb1fda 100755 (executable)
 # 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
 
-x=$(readlink -f "$BASH_SOURCE"); cd ${x%/*}
 
 e() { echo "$@"; "$@"; }
 
@@ -33,7 +42,7 @@ mount_point=$(mktemp -d)
 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