Merge remote-tracking branch 'origin/pull/50'
* origin/pull/50: arch-chroot: add option to preserve the chroot resolv.conf
This commit is contained in:
commit
77c3cc7c1b
@ -3,6 +3,7 @@
|
|||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
|
|
||||||
unshare=0
|
unshare=0
|
||||||
|
keepresolvconf=0
|
||||||
|
|
||||||
m4_include(common)
|
m4_include(common)
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ usage: ${0##*/} chroot-dir [command] [arguments...]
|
|||||||
-h Print this help message
|
-h Print this help message
|
||||||
-N Run in unshare mode as a regular user
|
-N Run in unshare mode as a regular user
|
||||||
-u <user>[:group] Specify non-root user and optional group to use
|
-u <user>[:group] Specify non-root user and optional group to use
|
||||||
|
-r Do not change the resolv.conf within the chroot
|
||||||
|
|
||||||
If 'command' is unspecified, ${0##*/} will launch /bin/bash.
|
If 'command' is unspecified, ${0##*/} will launch /bin/bash.
|
||||||
|
|
||||||
@ -79,7 +81,9 @@ arch-chroot() {
|
|||||||
[[ -d $chrootdir ]] || die "Can't create chroot on non-directory %s" "$chrootdir"
|
[[ -d $chrootdir ]] || die "Can't create chroot on non-directory %s" "$chrootdir"
|
||||||
|
|
||||||
$setup "$chrootdir" || die "failed to setup chroot %s" "$chrootdir"
|
$setup "$chrootdir" || die "failed to setup chroot %s" "$chrootdir"
|
||||||
chroot_add_resolv_conf "$chrootdir" || die "failed to setup resolv.conf"
|
if (( ! keepresolvconf )); then
|
||||||
|
chroot_add_resolv_conf "$chrootdir" || die "failed to setup resolv.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
if ! mountpoint -q "$chrootdir"; then
|
if ! mountpoint -q "$chrootdir"; then
|
||||||
warning "$chrootdir is not a mountpoint. This may have undesirable side effects."
|
warning "$chrootdir is not a mountpoint. This may have undesirable side effects."
|
||||||
@ -91,7 +95,7 @@ arch-chroot() {
|
|||||||
SHELL=/bin/bash $pid_unshare chroot "${chroot_args[@]}" -- "$chrootdir" "${args[@]}"
|
SHELL=/bin/bash $pid_unshare chroot "${chroot_args[@]}" -- "$chrootdir" "${args[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts ':hNu:' flag; do
|
while getopts ':hNu:r' flag; do
|
||||||
case $flag in
|
case $flag in
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
@ -103,6 +107,9 @@ while getopts ':hNu:' flag; do
|
|||||||
u)
|
u)
|
||||||
userspec=$OPTARG
|
userspec=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
r)
|
||||||
|
keepresolvconf=1
|
||||||
|
;;
|
||||||
:)
|
:)
|
||||||
die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG"
|
die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
@ -2,7 +2,7 @@ _arch_chroot() {
|
|||||||
compopt +o dirnames
|
compopt +o dirnames
|
||||||
local cur prev opts i
|
local cur prev opts i
|
||||||
_init_completion -n : || return
|
_init_completion -n : || return
|
||||||
opts="-N -u -h"
|
opts="-N -u -r -h"
|
||||||
|
|
||||||
for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do
|
for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do
|
||||||
if [[ -d ${i} ]]; then
|
if [[ -d ${i} ]]; then
|
||||||
|
@ -5,6 +5,7 @@ local -a args=(
|
|||||||
'(-h --help)'{-h,--help}'[display help]'
|
'(-h --help)'{-h,--help}'[display help]'
|
||||||
'-N[Run in unshare mode as a regular user]'
|
'-N[Run in unshare mode as a regular user]'
|
||||||
'-u[The non-root user and optional group to use]: :->userspecs'
|
'-u[The non-root user and optional group to use]: :->userspecs'
|
||||||
|
'-r[Do not change the resolv.conf within the chroot]'
|
||||||
'1:new root directory:_directories'
|
'1:new root directory:_directories'
|
||||||
'*:::command:_normal'
|
'*:::command:_normal'
|
||||||
)
|
)
|
||||||
|
@ -40,6 +40,10 @@ Options
|
|||||||
*-u <user>[:group]*::
|
*-u <user>[:group]*::
|
||||||
Specify non-root user and optional group to use.
|
Specify non-root user and optional group to use.
|
||||||
|
|
||||||
|
*-r*::
|
||||||
|
Do not change the resolv.conf within the chroot. This means that the resolver
|
||||||
|
might not work in the chroot, which could be the required state.
|
||||||
|
|
||||||
*-h*::
|
*-h*::
|
||||||
Output syntax and command line options.
|
Output syntax and command line options.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user