portfwd.init 773 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/sbin/openrc-run
  2. depend() {
  3. need net
  4. }
  5. checkconfig() {
  6. if [ ! -e /etc/portfwd.cfg ] ; then
  7. eerror "You need an /etc/portfwd.cfg file first"
  8. eerror "There are samples in the documentation directory"
  9. return 1
  10. fi
  11. }
  12. start() {
  13. checkconfig || return 1
  14. ebegin "Starting portfwd"
  15. start-stop-daemon --start --quiet --pidfile /var/run/portfwd.pid --exec /usr/sbin/portfwd -- ${PORTFWD_OPTS}
  16. _pid="`ps -C portfwd -o pid= | head -n 1`"
  17. if [ -n "$_pid" ] ; then
  18. echo "${_pid/ /}" > /var/run/portfwd.pid
  19. eend 0
  20. else
  21. eend 1
  22. fi
  23. }
  24. stop() {
  25. ebegin "Stopping portfwd"
  26. start-stop-daemon --stop --quiet --pidfile /var/run/portfwd.pid
  27. if [ $? -eq 0 ]; then
  28. rm -f /var/run/portfwd.pid
  29. fi
  30. eend $?
  31. }