meta-digi/meta-digi-dey/classes/dey-image.bbclass

33 lines
1.2 KiB
Plaintext

# DEY image features.
#
# Copyright (C) 2012 Digi International.
#
# Add build info to rootfs images (/etc/build)
#
inherit image-buildinfo
## DEY rootfs final tuning
dey_rootfs_tuning() {
#######################################################################
## Set root password to 'root' if 'debug-tweaks' is NOT enabled.
## command: echo -n 'root' | mkpasswd -5 -s
#######################################################################
MD5_ROOT_PASSWD='$1$SML0de4S$lOWs3t82QAH0oEf8NyNKA0'
if echo "${IMAGE_FEATURES}" | grep -qs debug-tweaks; then
: # No-op
else
# Shadow passwords ENABLED
if [ -f "${IMAGE_ROOTFS}/etc/shadow" ]; then
sed 's%^root:[^:]*:%root:x:%' <${IMAGE_ROOTFS}/etc/passwd >${IMAGE_ROOTFS}/etc/passwd.new
sed "s%^root:[^:]*:%root:${MD5_ROOT_PASSWD}:%" <${IMAGE_ROOTFS}/etc/shadow >${IMAGE_ROOTFS}/etc/shadow.new
mv ${IMAGE_ROOTFS}/etc/passwd.new ${IMAGE_ROOTFS}/etc/passwd
mv ${IMAGE_ROOTFS}/etc/shadow.new ${IMAGE_ROOTFS}/etc/shadow
# Shadow passwords DISABLED
else
sed "s%^root:[^:]*:%root:${MD5_ROOT_PASSWD}:%" <${IMAGE_ROOTFS}/etc/passwd >${IMAGE_ROOTFS}/etc/passwd.new
mv ${IMAGE_ROOTFS}/etc/passwd.new ${IMAGE_ROOTFS}/etc/passwd
fi
fi
}