init-keepalived 968 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2012 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. opts="reload"
  5. depend() {
  6. use logger
  7. # The interfaces do not actually need to exist to start, it handles them gracefully.
  8. use net
  9. }
  10. extra_commands="checkconfig"
  11. PIDFILE=/var/run/keepalived.pid
  12. checkconfig() {
  13. # keepalived has a config check command, but it does not work while the daemon is running!
  14. if [ ! -e /etc/keepalived/keepalived.conf ] ; then
  15. eerror "You need an /etc/keepalived/keepalived.conf file to run keepalived"
  16. return 1
  17. fi
  18. }
  19. start() {
  20. checkconfig || return 1
  21. ebegin "Starting Keepalived"
  22. start-stop-daemon --start --quiet --pidfile $PIDFILE \
  23. --exec /usr/sbin/keepalived -- $opts
  24. eend $?
  25. }
  26. stop() {
  27. ebegin "Stopping Keepalived"
  28. start-stop-daemon --stop --quiet --pidfile $PIDFILE
  29. eend $?
  30. }
  31. reload() {
  32. ebegin "Reloading keepalived.conf"
  33. start-stop-daemon --pidfile $PIDFILE --signal HUP
  34. eend $?
  35. }