From: Ian Kelling Date: Wed, 11 May 2022 19:03:03 +0000 (-0400) Subject: fixes X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=253530bdfb6da78f7b33f7af11a031359f02ef84;p=distro-setup fixes --- diff --git a/brc2 b/brc2 index 5035ca2..d374c52 100644 --- a/brc2 +++ b/brc2 @@ -1138,15 +1138,15 @@ mns() { # mount namespace ns=$1 shift s mkdir -p /root/mount_namespaces - if ! s mountpoint /root/mount_namespaces >/dev/null; then - m s mount --bind /root/mount_namespaces /root/mount_namespaces + if ! sudo mountpoint /root/mount_namespaces >/dev/null; then + m sudo mount --bind /root/mount_namespaces /root/mount_namespaces fi - m s mount --make-private /root/mount_namespaces + m sudo mount --make-private /root/mount_namespaces if [[ ! -e /root/mount_namespaces/$ns ]]; then - s touch /root/mount_namespaces/$ns + m sudo touch /root/mount_namespaces/$ns fi - if ! s mountpoint /root/mount_namespaces/$ns >/dev/null; then - m unshare --propagation slave --mount=/root/mount_namespaces/$ns /bin/true + if ! sudo mountpoint /root/mount_namespaces/$ns >/dev/null; then + m sudo unshare --propagation slave --mount=/root/mount_namespaces/$ns /bin/true fi m sudo -E /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@" } @@ -1164,7 +1164,7 @@ lom() { local l base if [[ $1 == /* ]]; then base=${1##*/} - if mountpoint -q /mnt/$base; then + if mns $base mountpoint -q /mnt/$base; then return 0 fi l=$(losetup -j $1 | sed -rn 's/^([^ ]+): .*/\1/p' | head -n1 ||:) @@ -1179,12 +1179,12 @@ lom() { fi fi m sudo mkdir -p /mnt/$base - m mns mount /dev/mapper/$base /mnt/$base - m mns chown $USER:$USER /mnt/$base + m mns $base mount /dev/mapper/$base /mnt/$base + m mns $base chown $USER:$USER /mnt/$base else base=$1 - if mns mountpoint /mnt/$base &>/dev/null; then - m mns umount /mnt/$base + if mns $base mountpoint /mnt/$base &>/dev/null; then + m mns $base umount /mnt/$base fi if sudo cryptsetup status /dev/mapper/$base &>/dev/null; then if ! m sudo cryptsetup luksClose /dev/mapper/$base; then @@ -1780,7 +1780,7 @@ mailnncheck() { vpncmd() { - m sudo -E env "PATH=$PATH" nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*client.conf") -n -m "$@" + m sudo -E env "PATH=$PATH" nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*client.conf") -n "$@" } vpnf() { sudo -v