From 6ef68d0c8356bf041fe65ca6d27c27a26f9d3a48 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 3 Apr 2016 23:33:46 -0400 Subject: [PATCH] gentoo-sync: use namespaces --- .bin/gentoo-sync | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.bin/gentoo-sync b/.bin/gentoo-sync index 11bd717..ed2c071 100755 --- a/.bin/gentoo-sync +++ b/.bin/gentoo-sync @@ -10,6 +10,27 @@ GS_DEBUG=false conf="/etc/gentoo-sync.conf" [[ -e ${conf} ]] && . "${conf}" +bootstrap() { + [[ $(id -u) -eq 0 ]] || exec sudo env -uUNSHARE HOME="$HOME" "$0" "$@" + + if [[ -z ${UNSHARE} ]] ; then + mount_args= + if type -P unshare >&/dev/null ; then + test_arg() { unshare "$@" -- true >&/dev/null && uargs+=( "$@" ) || :; } + uargs=( -m ) + test_arg -u + test_arg -i + test_arg -p -f --mount-proc + test_arg --propagation=private + UNSHARE=true exec unshare "${uargs[@]}" -- "$0" "$@" + fi + else + mount_args='-n' + fi + unset UNSHARE +} +bootstrap "$@" + usage() { cat <<-EOF Usage: ${0##*/} [options] @@ -58,7 +79,6 @@ for x ; do esac done -[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || : ${GS_DEBUG} && set -x logdir="/var/log" -- 2.39.5