klipper.initd 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/sbin/openrc-run
  2. # Copyright 2022 Gentoo Authors
  3. # Distributed under the terms of the GNU General Public License v2
  4. name="Klipper daemon"
  5. description="3D printer firmware with motion planning on the host"
  6. pidfile=${pidfile:-"/run/${RC_SVCNAME}.pid"}
  7. user=${user:-${RC_SVCNAME}}
  8. group=${group:-${RC_SVCNAME}}
  9. : ${klipper_config:=${KLIPPER_CONFIG:-/etc/klipper/printer.cfg}}
  10. : ${klipper_socket:=${KLIPPER_SOCKET:-/run/${RC_SVCNAME}/${RC_SVCNAME}.sock}}
  11. : ${klipper_log:=${KLIPPER_LOG:-/tmp/klippy.log}}
  12. command="/usr/libexec/${RC_SVCNAME}/klippy/klippy.py"
  13. command_args="${command_args:-${klipper_config} --api-server=${klipper_socket} --logfile=${klipper_log}}"
  14. command_background="true"
  15. retry="TERM/25/KILL/5"
  16. start_pre() {
  17. # We need to test if runtime directories exists, since script will fail if it does not
  18. checkpath --owner ${RC_SVCNAME}:${RC_SVCNAME} --mode 0775 -q -d "${klipper_config%\/*}"
  19. checkpath --owner ${RC_SVCNAME}:${RC_SVCNAME} --mode 0755 -q -d "${klipper_socket%\/*}"
  20. checkpath --owner ${RC_SVCNAME}:${RC_SVCNAME} --mode 0755 -q -d "${klipper_log%\/*}"
  21. }
  22. depend() {
  23. need localmount
  24. need udev
  25. after net
  26. }
  27. start_stop_daemon_args="--user ${user} --group ${group} \
  28. --stdout ${klipper_log} \
  29. --stderr ${klipper_log}"