plumgrid.conf
description "PLUMgrid Interface Manager Service"
start on (started libvirt-bin and net-device-up IFACE!=lo)
respawn
pre-start script
/opt/pg/scripts/systemd_pre_start.sh
for i in {1..5}; do
sleep 4
if [ -S /var/run/libvirt/libvirt-sock ]; then
break
fi
done
[ ! -S /var/run/libvirt/libvirt-sock ] && echo "libvirt socket not found" && exit 1
[ -r /var/run/libvirt/lxc/plumgrid.pid ] || virsh -c lxc: start plumgrid
end script
post-start script
/opt/pg/scripts/systemd_post_start.sh
end script
post-stop script
virsh -c lxc: destroy plumgrid
/opt/pg/scripts/systemd_post_stop.sh
end script
script
exec tail -f /dev/null --pid `cat /var/run/libvirt/lxc/plumgrid.pid`
end script
systemd_post_start.sh
#!/bin/bash
[ -r /opt/pg/scripts/pg_startup_helper.sh ] || exit 1
. /opt/pg/scripts/pg_startup_helper.sh
if [ "$pg_syslog_ng_ip" ] && [ "$pg_syslog_ng_port" ]; then
pg_send_udp ${pg_syslog_ng_ip} ${pg_syslog_ng_port} 3 "pgnodeperiodicstatus{\"systemd_post_start\": \"OK\"}"
fi
ifc_list_file=/var/run/plumgrid/lxc/ifc_list_gateway
for i in {1..20}; do
if [ -r $ifc_list_file ]; then
dev=$(cat $ifc_list_file | grep fabric_core | awk '{print $1}')
if [[ "$dev" != "" ]]; then
driver=$(ethtool -i $dev | grep driver: | awk '{print $2}')
if [[ "$driver" = "mlx4_en" ]]; then
tryexec ip link add vxlan9876 type vxlan id 9876 group 239.1.1.1 dev $dev dstport 4789
tryexec ip link set dev $dev up
tryexec ip link set dev vxlan9876 up
tryexec ethtool -K $dev tx-udp_tnl-segmentation on
fi
break
fi
fi
sleep 3
done
exit 0
systemd_post_stop.sh
#!/bin/bash
[ -r /opt/pg/scripts/pg_startup_helper.sh ] || exit 1
. /opt/pg/scripts/pg_startup_helper.sh
tryexec ip link del vxlan9876
exit 0