From: Mike Frysinger Date: Mon, 4 Apr 2016 03:33:46 +0000 (-0400) Subject: gentoo-sync: use namespaces X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=6ef68d0c8356bf041fe65ca6d27c27a26f9d3a48;p=home.git gentoo-sync: use namespaces --- 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"