i2pd-2.6.0-r3.initd 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2016 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. description="C++ daemon for accessing the I2P network"
  5. description_graceful="Graceful shutdown, takes 10 minutes"
  6. command="/usr/bin/i2pd"
  7. command_args="${I2PD_OPTIONS}"
  8. user="${I2PD_USER}:${I2PD_GROUP}"
  9. start_stop_daemon_args="
  10. --user \"${user}\"
  11. --pidfile \"${I2PD_PID}\"
  12. --progress --retry 'SIGTERM/20/SIGKILL/20'
  13. "
  14. I2PD_PID_DIR=$(dirname "${I2PD_PID}")
  15. extra_started_commands="graceful"
  16. depend() {
  17. use dns logger netmount
  18. }
  19. start_pre() {
  20. if [ -z "${I2PD_USER}" ] || \
  21. [ -z "${I2PD_GROUP}" ] || \
  22. [ -z "${I2PD_PID}" ] || \
  23. [ -z "${I2PD_LOG}" ] || \
  24. [ -z "${I2PD_OPTIONS}" ] ; then
  25. eerror "Not all variables I2PD_USER, I2PD_GROUP, I2PD_PID, I2PD_OPTIONS, I2PD_LOG are defined."
  26. eerror "Check your /etc/conf.d/i2pd."
  27. return 1
  28. fi
  29. checkpath -f -o "${user}" "${I2PD_LOG}"
  30. checkpath -d -m 0750 -o "${user}" "${I2PD_PID_DIR}"
  31. }
  32. graceful() {
  33. # on SIGINT, i2pd stops accepting tunnels and shuts down in 600 seconds
  34. ebegin "Gracefully stopping i2pd, this takes 10 minutes"
  35. mark_service_stopping
  36. eval start-stop-daemon --stop ${start_stop_daemon_args} \
  37. --exec "${command}" --retry 'SIGINT/620/SIGTERM/20/SIGKILL/20'
  38. eend $? && mark_service_stopped
  39. }