File tree 4 files changed +15
-3
lines changed
4 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 3
3
shopt -s extglob
4
4
5
5
unshare=0
6
+ keepresolvconf=0
6
7
7
8
m4_include(common)
8
9
@@ -13,6 +14,7 @@ usage: ${0##*/} chroot-dir [command] [arguments...]
13
14
-h Print this help message
14
15
-N Run in unshare mode as a regular user
15
16
-u <user>[:group] Specify non-root user and optional group to use
17
+ -r Do not change the resolv.conf within the chroot
16
18
17
19
If 'command' is unspecified, ${0##*/ } will launch /bin/bash.
18
20
@@ -79,7 +81,9 @@ arch-chroot() {
79
81
[[ -d $chrootdir ]] || die " Can't create chroot on non-directory %s" " $chrootdir "
80
82
81
83
$setup " $chrootdir " || die " failed to setup chroot %s" " $chrootdir "
82
- chroot_add_resolv_conf " $chrootdir " || die " failed to setup resolv.conf"
84
+ if (( ! keepresolvconf )) ; then
85
+ chroot_add_resolv_conf " $chrootdir " || die " failed to setup resolv.conf"
86
+ fi
83
87
84
88
if ! mountpoint -q " $chrootdir " ; then
85
89
warning " $chrootdir is not a mountpoint. This may have undesirable side effects."
@@ -91,7 +95,7 @@ arch-chroot() {
91
95
SHELL=/bin/bash $pid_unshare chroot " ${chroot_args[@]} " -- " $chrootdir " " ${args[@]} "
92
96
}
93
97
94
- while getopts ' :hNu:' flag; do
98
+ while getopts ' :hNu:r ' flag; do
95
99
case $flag in
96
100
h)
97
101
usage
@@ -103,6 +107,9 @@ while getopts ':hNu:' flag; do
103
107
u)
104
108
userspec=$OPTARG
105
109
;;
110
+ r)
111
+ keepresolvconf=1
112
+ ;;
106
113
:)
107
114
die ' %s: option requires an argument -- ' \' ' %s' \' " ${0##*/ } " " $OPTARG "
108
115
;;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ _arch_chroot() {
2
2
compopt +o dirnames
3
3
local cur prev opts i
4
4
_init_completion -n : || return
5
- opts="-N -u -h"
5
+ opts="-N -u -r - h"
6
6
7
7
for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do
8
8
if [[ -d ${i} ]]; then
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ local -a args=(
5
5
'(-h --help)'{-h,--help}'[display help]'
6
6
'-N[Run in unshare mode as a regular user]'
7
7
'-u[The non-root user and optional group to use]: :->userspecs'
8
+ '-r[Do not change the resolv.conf within the chroot]'
8
9
'1:new root directory:_directories'
9
10
'*:::command:_normal'
10
11
)
Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ Options
40
40
*-u <user>[:group]* ::
41
41
Specify non-root user and optional group to use.
42
42
43
+ *-r* ::
44
+ Do not change the resolv.conf within the chroot. This means that the resolver
45
+ might not work in the chroot, which could be the required state.
46
+
43
47
*-h* ::
44
48
Output syntax and command line options.
45
49
You can’t perform that action at this time.
0 commit comments