create-vmachine: Prompt for and set a root password
parent
1cc87ab55d
commit
3e66d9345d
|
@ -17,6 +17,17 @@ fi
|
|||
: ${MOUNTPOINT:=/mnt/new_vmachine}
|
||||
: ${PORTAGE_PROFILE:="default/linux/amd64/13.0"}
|
||||
|
||||
while [[ -z ${VM_ROOTPW} ]]; do
|
||||
read -sp 'New VM root password: ' VM_ROOTPW
|
||||
echo
|
||||
read -sp 'Confirm root password: ' confirm_rootpw
|
||||
echo
|
||||
if [[ ${VM_ROOTPW} != ${confirm_rootpw} ]]; then
|
||||
echo "Passwords don't match" >&2
|
||||
unset VM_ROOTPW
|
||||
fi
|
||||
done
|
||||
|
||||
set -e
|
||||
|
||||
PORTDIR=$(portageq envvar PORTDIR)
|
||||
|
@ -116,8 +127,8 @@ ln -s /proc/mounts "${MOUNTPOINT}"/etc/mtab
|
|||
ln -s /run/resolv.conf "${MOUNTPOINT}"/etc/resolv.conf
|
||||
ln -s /run/ntp.conf "${MOUNTPOINT}"/etc/ntp.conf
|
||||
|
||||
echo "Blanking root password..."
|
||||
sed -i 's/^root:.*/root::0:0:::::/' "${MOUNTPOINT}"/etc/shadow
|
||||
echo "Setting root password..."
|
||||
echo "root:${VM_ROOTPW}" | chroot "${MOUNTPOINT}" chpasswd
|
||||
|
||||
echo "Enabling serial console..."
|
||||
sed -i 's/#s0/s0/' "${MOUNTPOINT}"/etc/inittab
|
||||
|
|
Loading…
Reference in New Issue