NetworkManager.initd 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/sbin/openrc-run
  2. # Copyright (c) 2008 Saleem Abdulrasool <compnerd@compnerd.org>
  3. # Copyright 2013-2017 Gentoo Foundation
  4. # Distributed under the terms of the GNU General Public License v2
  5. description="NetworkManager daemon. The service is marked as started only \
  6. when a network connection is established."
  7. depend() {
  8. need dbus
  9. use consolekit
  10. provide net
  11. }
  12. start() {
  13. # If we are re-called by a dispatcher event, we want to mark the service
  14. # as started without starting the daemon again
  15. yesno "${IN_BACKGROUND}" && return 0
  16. [ -z "${INACTIVE_TIMEOUT}" ] && INACTIVE_TIMEOUT="1"
  17. ebegin "Starting NetworkManager"
  18. start-stop-daemon --start --quiet --pidfile /run/NetworkManager/NetworkManager.pid \
  19. --exec /usr/sbin/NetworkManager -- --pid-file /run/NetworkManager/NetworkManager.pid
  20. local _retval=$?
  21. eend "${_retval}"
  22. if [ "x${_retval}" = 'x0' ] && ! nm-online -t "${INACTIVE_TIMEOUT}"; then
  23. einfo "Marking NetworkManager as inactive. It will automatically be marked"
  24. einfo "as started after a network connection has been established."
  25. mark_service_inactive
  26. fi
  27. return "${_retval}"
  28. }
  29. stop() {
  30. # If we are re-called by a dispatcher event, we want to mark the service
  31. # as inactive without stopping the daemon
  32. if yesno "${IN_BACKGROUND}"; then
  33. mark_service_inactive "${SVCNAME}"
  34. return 0
  35. fi
  36. ebegin "Stopping NetworkManager"
  37. local pidfile=/run/NetworkManager/NetworkManager.pid
  38. if [ ! -e "${pidfile}" ] && [ -e /var/run/NetworkManager.pid ]; then
  39. # Try stopping the pid file used by <0.9.7
  40. pidfile=/var/run/NetworkManager.pid
  41. start-stop-daemon --stop --quiet --pidfile "${pidfile}"
  42. ret=$?
  43. [ ${ret} = 0 ] && [ -e "${pidfile}" ] && rm "${pidfile}"
  44. eend ${ret}
  45. else
  46. start-stop-daemon --stop --quiet --pidfile "${pidfile}"
  47. eend $?
  48. fi
  49. }
  50. # vim: set ft=gentoo-init-d ts=4 :