quarta-feira, 22 de março de 2017

linux - Ubuntu 14.04 iperf3 Upstart Script



Ubuntu 14.04 iperf3 Upstart Script


I had a requirement for running an iperf3 server in daemon mode. This needed to survive server reboots, and therefore start automatically at boot. This example might help network engineers that have limited linux skills (like myself).
I took this example from DigitalOcean, but for the stopping of the service to work properly I had to add expect fork to the code.
You’ll first need to install iperf3 on the machine.
Once iperf3 is installed place the following code in a new text file in /etc/init/ with a .conf extension. I used /etc/init/iperf3.conf
description "Iperf 3 Upstart Script"
author      "Author"

start on filesystem or runlevel [2345]
stop on shutdown
expect fork

script

    exec /usr/bin/iperf3 -s -D
    echo $$ > /var/run/iperf3.pid

end script

pre-start script
    echo "[`date`] Iperf 3 Server Starting" >> /var/log/iperf3.log
end script

pre-stop script
    rm /var/run/iperf3.pid
    echo "[`date`] Iperf 3 Server Stopping" >> /var/log/iperf3.log
end script
The Iperf3 daemon should now run automatically at boot. You can use the sudo service iperf3 stop, sudo service iperf3 start and sudo service iperf3 status commands to manage the service.


fonte: http://www.packetnerd.com/?p=190

---- or
https://thatservernerd.com/2016/05/27/build-an-iperf3-server-on-ubuntu-server-14-04/

https://scottlinux.com/2014/12/08/how-to-create-a-systemd-service-in-linux-centos-7/

0 comentários: