sysmocom-configure: add simple framework to run configuration scripts

The configuration scripts are named for the systemd units for which they
generate configuration files. The generator causes them to run before
those units are started.
This commit is contained in:
Jan Luebbe 2015-06-24 14:12:30 +02:00 committed by Holger Hans Peter Freyther
parent 08913496cc
commit 8e104ac413
6 changed files with 84 additions and 0 deletions

View File

@ -17,4 +17,5 @@ RDEPENDS_${PN} = "\
sysmocom-backup \
sysmocom-backup-default \
sysmocom-systemd \
sysmocom-configure \
"

View File

@ -0,0 +1,12 @@
#!/bin/sh
set -eu
TEST_VALUE="default"
. /slot/system.conf
cat >/etc/symocom/test.cfg <<EOF
[main]
bla=$TEST_VALUE
EOF

View File

@ -0,0 +1,12 @@
#!/bin/sh
set -eu
OSMOBSC_VALUE="bar"
. /slot/system.conf
cat >/etc/osmocom/osmo-bsc.cfg <<EOF
#dummy: OSMOBSC_VALUE=$OSMOBSC_VALUE
EOF

View File

@ -0,0 +1,11 @@
#!/bin/sh
TEST_VALUE="default"
. /slot/system.conf
cat >/etc/sysmocom/test.cfg <<EOF
[main]
bla=$TEST_VALUE
model=sysmocom-bsc
EOF

View File

@ -0,0 +1,28 @@
#!/bin/sh
. /slot/system.conf
for HANDLER in $(ls /etc/sysmocom/configure.d/*.sh); do
UNIT=$(basename "$HANDLER" .sh)
cat >$1/${UNIT//./-}-configure.service <<EOF
[Unit]
Description=Generate $UNIT Configuration
After=sysmocom-restore.service
Before=$UNIT
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=$HANDLER
EOF
mkdir -p $1/$UNIT.wants
ln -s /lib/systemd/system/${UNIT//./-}-configure.service $1/$UNIT.wants/
done
if [ -n "$OSMOBSC_ENABLED" ]; then
ln -s /lib/systemd/system/osmo-bsc.service $1/multi-user.target.wants/
fi
if [ -n "$OSMONITB_ENABLED" ]; then
ln -s /lib/systemd/system/osmo-nitb.service $1/multi-user.target.wants/
fi

View File

@ -0,0 +1,20 @@
DESCRIPTION = "sysmocom configuration scripts"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
SRC_URI = " \
file://sysmocom-generator \
file://multi-user.target.sh \
file://osmo-bsc.service.sh \
"
do_install() {
install -d ${D}${systemd_unitdir}/system-generators
install -m 0755 ${WORKDIR}/sysmocom-generator ${D}${systemd_unitdir}/system-generators/
install -d ${D}${sysconfdir}/sysmocom/configure.d
install -m 0755 ${WORKDIR}/*.sh ${D}${sysconfdir}/sysmocom/configure.d/
}
FILES_${PN} += "${systemd_unitdir}/system-generators"