mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-09 05:56:58 +02:00
Added a function to update chroot sudoers automatically.
This function is now called by enter_chroot.sh. A separate change will call the function from make_chroot Change-Id: I4fc07c413e56db3e5e7617428f20f2ffc02790d7 BUG=chromium-os:7072 TEST=Took root out of sudoers and ran enter_chroot.sh script; saw that it was re-added. Review URL: http://codereview.chromium.org/3909001
This commit is contained in:
parent
62d75f0582
commit
0c9e88de6c
20
common.sh
20
common.sh
@ -460,3 +460,23 @@ print_time_elapsed() {
|
|||||||
seconds="$(( $elapsed_seconds % 60 ))"
|
seconds="$(( $elapsed_seconds % 60 ))"
|
||||||
echo "Elapsed time: ${minutes}m${seconds}s"
|
echo "Elapsed time: ${minutes}m${seconds}s"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function is a place to put code to incrementally update the
|
||||||
|
# chroot so that users don't need to fully re-make it. It should
|
||||||
|
# be called from scripts that are run _outside_ the chroot.
|
||||||
|
#
|
||||||
|
# Please put date information so it's easy to keep track of when
|
||||||
|
# old hacks can be retired and so that people can detect when a
|
||||||
|
# hack triggered when it shouldn't have.
|
||||||
|
#
|
||||||
|
# ${1} specifies the location of the chroot.
|
||||||
|
chroot_hacks_from_outside() {
|
||||||
|
# Give args better names.
|
||||||
|
local chroot_dir="${1}"
|
||||||
|
|
||||||
|
# Add root as a sudoer if not already done.
|
||||||
|
if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then
|
||||||
|
info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers"
|
||||||
|
sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
@ -254,6 +254,10 @@ then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Apply any hacks needed to update the chroot.
|
||||||
|
chroot_hacks_from_outside "${FLAGS_chroot}"
|
||||||
|
|
||||||
|
|
||||||
# Make sure we unmount before exiting
|
# Make sure we unmount before exiting
|
||||||
trap teardown_env EXIT
|
trap teardown_env EXIT
|
||||||
setup_env
|
setup_env
|
||||||
|
Loading…
Reference in New Issue
Block a user