autoipd.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (c) 2004-2006 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # Contributed by Sven Wegener (swegener@gentoo.org)
  4. # void autoipd_depend(void)
  5. #
  6. # Sets up the dependencies for the module
  7. autoipd_depend() {
  8. after interface
  9. }
  10. # void autoipd_expose(void)
  11. #
  12. # Expose variables that can be configured
  13. autoipd_expose() {
  14. variables autoipd
  15. }
  16. # bool autoipd_start(char *iface)
  17. #
  18. # Tries to configure the interface via avahi-autoipd
  19. autoipd_start() {
  20. local iface="${1}" ifvar="$(bash_variable "${iface}")" opts="autoipd_${ifvar}" addr=""
  21. interface_exists "${iface}" true || return 1
  22. ebegin "Starting avahi-autoipd"
  23. if /usr/sbin/avahi-autoipd --daemonize --syslog --wait ${!opts} "${iface}"
  24. then
  25. eend 0
  26. addr="$(interface_get_address "${iface}")"
  27. einfo "${iface} received address ${addr}"
  28. return 0
  29. fi
  30. eend "${?}" "Failed to get address via avahi-autoipd!"
  31. }
  32. # bool autoipd_stop(char *iface)
  33. #
  34. # Stops a running avahi-autoipd instance
  35. autoipd_stop() {
  36. local iface="${1}"
  37. /usr/sbin/avahi-autoipd --check --syslog "${iface}" || return 0
  38. ebegin "Stopping avahi-autoipd"
  39. /usr/sbin/avahi-autoipd --kill --syslog "${iface}"
  40. eend "${?}" "Failed to stop running avahi-autoipd instance!"
  41. }
  42. # vim: set ts=4 :