um-service-cfg: Configuration support for user module services
User module provides few information over i2c bus, e.g. ip, version,.. Access /proc/device-tree/user_module/ for checking availability of user module and get information and stores settings under /etc/user-module/ Port definitions for each services is provided through this recipe and not through device tree. Would be nice feature for future improvements. socket-uart and cannelloni depends on that recipe. BugzID: 56443 Signed-off-by: Ramon Moesching <ramon.moesching@netmodule.com>
This commit is contained in:
parent
e13bb7edfe
commit
f46f7a1dca
|
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=Check whether user module is present and configure user space services
|
||||
Requires=um-service-config.service user-module.target
|
||||
After=um-service-config.service user-module.target
|
||||
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/um-rgpio-config
|
||||
EnvironmentFile=/etc/user-module/network.conf
|
||||
|
||||
[Install]
|
||||
WantedBy=user-module.target
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
UM_SYSFS_REMOTE_GPIO="/sys/class/remote-gpio/remote-gpio/config"
|
||||
|
||||
if [ -z $USER_MODULE_ipv4_addr ]; then
|
||||
echo Start script by systemd service or set variables
|
||||
else
|
||||
if [ -d $UM_SYSFS_REMOTE_GPIO ]; then
|
||||
if [[ `cat $UM_SYSFS_REMOTE_GPIO/ip` != $USER_MODULE_ipv4_addr || `cat $UM_SYSFS_REMOTE_GPIO/port` != $USER_MODULE_ipv4_port ]]; then
|
||||
echo $USER_MODULE_ipv4_addr > $UM_SYSFS_REMOTE_GPIO/ip
|
||||
echo $USER_MODULE_remote_gpio_port > $UM_SYSFS_REMOTE_GPIO/port
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
exit 1
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Check whether user module is present and configure user space services
|
||||
After=user-module.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/um-service-config
|
||||
|
||||
[Install]
|
||||
WantedBy=user-module.target
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
|
||||
UM_CONFIG_PATH=/etc/user-module
|
||||
UM_CONFIG_FILE=network.conf
|
||||
UM_CONFIG=$UM_CONFIG_PATH/$UM_CONFIG_FILE
|
||||
UM_PORTS=$UM_CONFIG_PATH/ports
|
||||
|
||||
UM_DTS_NODE=/proc/device-tree/user_module
|
||||
|
||||
DEBUG_NOTE_ORIGIN=$0
|
||||
|
||||
if [ -f $UM_CONFIG ]; then
|
||||
rm $UM_CONFIG
|
||||
else
|
||||
mkdir -p $UM_CONFIG_PATH
|
||||
fi
|
||||
|
||||
|
||||
# fetch user module status and network informations
|
||||
for f in $UM_DTS_NODE/*; do
|
||||
echo "USER_MODULE_${f##*/}=\"`cat $f`\"" | sed -E "s/,|-/_/g" >> $UM_CONFIG
|
||||
done
|
||||
|
||||
cat $UM_PORTS >> $UM_CONFIG
|
||||
|
||||
# source all fetched informations
|
||||
source $UM_CONFIG
|
||||
|
||||
if [[ $USER_MODULE_status = "disabled" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ping $USER_MODULE_ipv4_addr -w 3 -c 1
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo $DEBUG_NOTE_ORIGIN: Target with ipv4 $USER_MODULE_ipv4_addr available
|
||||
exit 0
|
||||
else
|
||||
echo $DEBUG_NOTE_ORIGIN: Target with ipv4 $USER_MODULE_ipv4_addr not available
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[Unit]
|
||||
Description=Just fetch user module informations from proc filesystem
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
# Copyright (C) 2019 Ramon Moesching <ramon.moesching@netmodule.com>
|
||||
# Released under the MIT license (see COPYING.MIT for the terms)
|
||||
inherit systemd
|
||||
LICENSE = "MIT"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
|
||||
FILESEXTRAPATHS_prepend := "${THISDIR}/config:"
|
||||
|
||||
SRC_URI = " \
|
||||
file://um-service-config.service \
|
||||
file://um-service-config.sh \
|
||||
file://user-module.target \
|
||||
file://um-rgpio-config.sh \
|
||||
file://um-rgpio-config.service \
|
||||
file://ports \
|
||||
"
|
||||
|
||||
FILES_${PN} = "${systemd_unitdir}/system ${bindir} /etc/user-module"
|
||||
|
||||
SYSTEMD_SERVICE_${PN} =" \
|
||||
um-service-config.service \
|
||||
um-rgpio-config.service \
|
||||
user-module.target \
|
||||
"
|
||||
|
||||
do_install_append() {
|
||||
# port config
|
||||
echo "USER_MODULE_kline_port=\"2202\"" >> ${WORKDIR}/ports
|
||||
echo "USER_MODULE_lin_port=\"2200\"" >> ${WORKDIR}/ports
|
||||
echo "USER_MODULE_uart_port=\"2204\"" >> ${WORKDIR}/ports
|
||||
echo "USER_MODULE_cannellonie_port_remote=\"20000\"" >> ${WORKDIR}/ports
|
||||
echo "USER_MODULE_cannellonie_port_local=\"20000\"" >> ${WORKDIR}/ports
|
||||
echo "USER_MODULE_remote_gpio_port=\"6666\"" >> ${WORKDIR}/ports
|
||||
|
||||
install -d ${D}/etc/user-module
|
||||
install -m 644 ${WORKDIR}/ports ${D}/etc/user-module/ports
|
||||
}
|
||||
|
||||
|
||||
do_install() {
|
||||
|
||||
install -d ${D}${systemd_unitdir}/system
|
||||
install -m 644 ${WORKDIR}/um-service-config.service ${D}${systemd_unitdir}/system/
|
||||
|
||||
install -d ${D}${systemd_system_unitdir}/
|
||||
install -m 0644 ${WORKDIR}/user-module.target ${D}${systemd_system_unitdir}/
|
||||
|
||||
install -d ${D}${systemd_system_unitdir}/multi-user.target.wants
|
||||
ln -sf ${systemd_system_unitdir}/user-module.target ${D}${systemd_system_unitdir}/multi-user.target.wants/user-module.target
|
||||
|
||||
install -d ${D}${bindir}
|
||||
install -m 744 ${WORKDIR}/um-service-config.sh ${D}${bindir}/um-service-config
|
||||
|
||||
install -d ${D}${systemd_unitdir}/system
|
||||
install -m 644 ${WORKDIR}/um-rgpio-config.service ${D}${systemd_unitdir}/system/
|
||||
install -d ${D}${bindir}
|
||||
install -m 744 ${WORKDIR}/um-rgpio-config.sh ${D}${bindir}/um-rgpio-config
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue