meta-netmodule-distro/recipes-extended/um-service-cfg/files/um-service-config.sh

34 lines
677 B
Bash

#!/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 | tr -d '\0' `\"" | 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
elif [[ $USER_MODULE_status = "okay" ]]; then
exit 0
fi