Merge remote-tracking branch 'origin/hheinold/image_improvements'

This commit is contained in:
Holger Hans Peter Freyther 2014-09-25 17:47:26 +02:00
commit 79f4f896ae
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,16 @@
DEPENDS += "openssl-native"
rootpasswd = "${@d.getVar('ROOT_PASS', True) or ""}"
ROOTFS_POSTPROCESS_COMMAND += "set_root_passwd;"
set_root_passwd() {
if [ -n "${rootpasswd}" ]; then
HASHED_PASS=`openssl passwd -1 ${rootpasswd}`
if [ -n "${HASHED_PASS}" ]; then
sed -e "s%^root:[^:]*:%root:${HASHED_PASS}:%" \
-i ${IMAGE_ROOTFS}/etc/shadow
echo "Generated new root-passwd"
fi
fi
}

View File

@ -0,0 +1,18 @@
hostsshkeysfile = "${@d.getVar('SSH_KEYS_FILE', True) or ''}"
ROOTFS_POSTPROCESS_COMMAND += "copy_ssh_keys;"
copy_ssh_keys() {
if [ -n "${hostsshkeysfile}" ]; then
if [ -r "${hostsshkeysfile}" ]; then
echo "Installing sshkeys from ${hostsshkeysfile}"
mkdir -p ${IMAGE_ROOTFS}/home/root/.ssh/
cat ${hostsshkeysfile} >> ${IMAGE_ROOTFS}/home/root/.ssh/authorized_keys
chown root:root ${IMAGE_ROOTFS}/home/root/.ssh/authorized_keys
chmod 0600 ${IMAGE_ROOTFS}/home/root/.ssh/authorized_keys
else
echo "Could not install sshkeys from ${hostsshkeysfile}"
fi
fi
}