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 "$@"
}
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 ||:)
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
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