fetchmail.initd 993 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/sbin/openrc-run
  2. piddir=${pid_dir:-/var/run/fetchmail}
  3. pid_file=${piddir}/${RC_SVCNAME}.pid
  4. rcfile=/etc/${RC_SVCNAME}rc
  5. depend() {
  6. need net
  7. use mta
  8. }
  9. checkconfig() {
  10. if [ ! -f ${rcfile} ]; then
  11. eerror "Configuration file ${rcfile} not found"
  12. return 1
  13. fi
  14. local fetchmail_instance
  15. fetchmail_instance=${RC_SVCNAME##*.}
  16. if [ -n "${fetchmail_instance}" -a "${RC_SVCNAME}" != "fetchmail" ]; then
  17. fidfile=/var/lib/fetchmail/.fetchids.${RC_SVCNAME}
  18. else
  19. fidfile=/var/lib/fetchmail/.fetchids
  20. fi
  21. if [ ! -d ${piddir} ]; then
  22. checkpath -q -d -o fetchmail:fetchmail -m 0755 ${piddir} || return 1
  23. fi
  24. }
  25. start() {
  26. checkconfig || return 1
  27. ebegin "Starting ${RC_SVCNAME}"
  28. start-stop-daemon --start --pidfile ${pid_file} \
  29. --user fetchmail --exec /usr/bin/fetchmail \
  30. -- -d ${polling_period} -f ${rcfile} \
  31. --pidfile ${pid_file} -i ${fidfile}
  32. eend ${?}
  33. }
  34. stop() {
  35. ebegin "Stopping ${RC_SVCNAME}"
  36. start-stop-daemon --stop --quiet --pidfile ${pid_file}
  37. eend ${?}
  38. }