Good morning,
We have a system that we are building on an Apalis imx8 board. We use a custom imagebase on the “tdx-reference-minimal-image” and we TFTP Boot the board with that image, which works perfectly. This image has a service that we created using a custom layer/custom recipe, this service has the followings:
→ A script Set the password for user “root” : “set_root_password.sh”
→ other files to Configure ssh with id_rsa.pub key to be able to remote login to the board.
→ A service to run on startup one time {After=getty.target}, this service is the entry point to start the set_root_password.
Note that set_root_password.sh set all other need configuration such as network configuration.
The problem is the service doesnt run on startup. It only works if i manually run it using: systemctl start custom-ssh-service.
Here is how the config.bb and the custom-ssh-service:
//-----------------------------------------------------------------------------------
config.bb:
SUMMARY = “Custom SSH Configuration”
DESCRIPTION = “Custom SSH Configuration for Apalis iMX8”
LICENSE = “MIT”
License checksum file is always required
LIC_FILES_CHKSUM = “file://${COREBASE}/meta/files/common-licenses/MIT;md5=”
#inherit systemd
SRC_URI = “file://id_rsa.pub
file://sshd_config
file://sshd.socket
file://set_root_password.sh
file://set_authorized_keys.sh
file://custom-ssh-symlink.service
file://custom-ssh-service.service”
S = “${WORKDIR}”
inherit update-rc.d systemd
SYSTEMD_PACKAGES = “${PN}”
INITSCRIPT_PACKAGES = “${PN}”
SYSTEMD_AUTO_ENABLE ??= “enable”
SYSTEMD_SERVICE_${PN} = “custom-ssh-service.service”
do_install() {
install -d ${D}${sysconfdir}/ssh/
install -d ${D}${sysconfdir}/systemd/system/
install -d ${D}${bindir}
install -m 0644 ${WORKDIR}/id_rsa.pub ${D}${sysconfdir}/ssh/
install -m 0644 ${WORKDIR}/sshd_config ${D}${sysconfdir}/ssh/
install -m 0644 ${WORKDIR}/sshd.socket ${D}${sysconfdir}/systemd/system/
install -m 0755 ${WORKDIR}/set_root_password.sh ${D}${bindir}/
install -m 0755 ${WORKDIR}/set_authorized_keys.sh ${D}${bindir}/
install -m 0644 ${WORKDIR}/custom-ssh-symlink.service ${D}${sysconfdir}/systemd/system/
install -m 0644 ${WORKDIR}/custom-ssh-service.service ${D}${sysconfdir}/systemd/system/
}
FILES_${PN} += “${sysconfdir}/ssh/
${sysconfdir}/systemd/system/
${sysconfdir}/ssh/authorized_keys
${bindir}/set_authorized_keys.sh
${bindir}/set_root_password.sh
${sysconfdir}/systemd/system/custom-ssh-service.service
${sysconfdir}/systemd/system/custom-ssh-symlink.service
${bindir}/”
pkg_postinst:${PN}() {
mkdir -p $D${sysconfdir}/systemd/user/default.target.wants
ln -s ${sysconfdir}/systemd/system/custom-ssh-service.service $D${sysconfdir}/systemd/user/default.target.wants/custom-ssh-service.service
}
//--------------------------------------------------------------------------------------------------------------------------
custom-ssh-service:
[Unit]
Description=Custom SSH Configuration Service
#After=network.target
##--------------------------------------
After=multi-user.target
##-------------------------------------
#After=systemd-user-sessions.service
plymouth-quit-wait.service
#After=rc-local.service
Before=getty.target
IgnoreOnIsolate=yes
#----------------------------------------
#Documentation=man:systemd-firstboot(1)
#DefaultDependencies=no
#Conflicts=shutdown.target
#After=systemd-remount-fs.service
#Before=systemd-sysusers.service sysinit.target shutdown.target
#ConditionPathIsReadWrite=/etc
#---------------------------------------
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/set_root_password.sh start
ExecStart=/usr/bin/set_authorized_keys.sh start
[Install]
WantedBy=multi-user.target
#WantedBy=basic.target
//------------------------------------------------------------------------------------------------------------------------
Please, help us figure out why the service is not running on startup, Thanks!