bug fix
[automated-distro-installer] / install-chboot
index 69f46dfb99848bbbdd6641a98ae15108d0df165a..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
-
-
-x=$(readlink -f "$BASH_SOURCE"); cd ${x%/*}
+set -e; . /usr/local/lib/bash-bear; set +e
 
 usage() {
-    cat <<EOF
-Usage: ${0##*/} [-h|--help]
+    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 $1
+    exit 0
 }
 case $1 in
     -h|--help) usage ;;
@@ -46,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