2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 01:51:26 +00:00
ovs/rhel/usr_lib_systemd_system_ovsdb-server.service
Timothy Redaelli 6403a49f3e rhel/systemd: Change owner recursively and also on /etc/openvswitch.
Since we use a floating user (user with dynamic userid) and floating
groups (groups with dynamic groupid), when you use bootc the uid/gid of
the directory may change and so it's necessary to be sure that the
uid/gid is updated each time you try to start the daemon.

ovsdb-server.service is the correct place to do that, since
ovs-vswitchd.service uses After=ovsdb-server.service and so it's always started
after it.

See https://github.com/bootc-dev/bootc/issues/673#issuecomment-2493912762

Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2025-03-28 10:36:30 -04:00

34 lines
1.4 KiB
Desktop File

[Unit]
Description=Open vSwitch Database Unit
After=syslog.target network-pre.target
Before=network.target network.service
Wants=ovs-delete-transient-ports.service
PartOf=openvswitch.service
[Service]
Type=forking
PIDFile=/run/openvswitch/ovsdb-server.pid
Restart=on-failure
EnvironmentFile=/etc/openvswitch/default.conf
EnvironmentFile=-/etc/sysconfig/openvswitch
EnvironmentFile=-/run/openvswitch.useropts
# Environment is reloaded for each Exec*, make sure to
# remove openvswitch.useropts first to reload a fresh
# OVS_USER_ID from default.conf or sysconfig.
ExecStartPre=/usr/bin/rm -f /run/openvswitch.useropts
ExecStartPre=-/usr/bin/chown -R ${OVS_USER_ID} \
/etc/openvswitch /run/openvswitch /var/log/openvswitch
ExecStartPre=/bin/sh -c '/usr/bin/echo "OVS_USER_ID=${OVS_USER_ID}" > /run/openvswitch.useropts'
ExecStartPre=/bin/sh -c 'if [ "$${OVS_USER_ID/:*/}" != "root" ]; then /usr/bin/echo "OVS_USER_OPT=--ovs-user=${OVS_USER_ID}" >> /run/openvswitch.useropts; fi'
ExecStart=/usr/share/openvswitch/scripts/ovs-ctl \
--no-ovs-vswitchd --no-monitor --system-id=random \
${OVS_USER_OPT} \
start $OPTIONS
ExecStop=/usr/share/openvswitch/scripts/ovs-ctl --no-ovs-vswitchd stop
ExecReload=/usr/share/openvswitch/scripts/ovs-ctl --no-ovs-vswitchd \
${OVS_USER_OPT} \
--no-monitor restart $OPTIONS
TimeoutSec=300