Browse Source

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.
hfreyther/linux-4.1-upgrade
Jan Luebbe 7 years ago committed by Holger Hans Peter Freyther
parent
commit
8e104ac413
  1. 1
      recipes-apps/tasks/task-sysmocom-tools.bb
  2. 12
      recipes-config/sysmocom-configure/files/multi-user.target.sh
  3. 12
      recipes-config/sysmocom-configure/files/osmo-bsc.service.sh
  4. 11
      recipes-config/sysmocom-configure/files/sysmocom-bsc/multi-user.target.sh
  5. 28
      recipes-config/sysmocom-configure/files/sysmocom-generator
  6. 20
      recipes-config/sysmocom-configure/sysmocom-configure_1.0.bb

1
recipes-apps/tasks/task-sysmocom-tools.bb

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

12
recipes-config/sysmocom-configure/files/multi-user.target.sh

@ -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

12
recipes-config/sysmocom-configure/files/osmo-bsc.service.sh

@ -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

11
recipes-config/sysmocom-configure/files/sysmocom-bsc/multi-user.target.sh

@ -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

28
recipes-config/sysmocom-configure/files/sysmocom-generator

@ -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

20
recipes-config/sysmocom-configure/sysmocom-configure_1.0.bb

@ -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"
Loading…
Cancel
Save