rc.aprx.new 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. #
  3. # aprx daemon control script.
  4. # Written for Slackware Linux by JK Wood <joshuakwood@gmail.com>
  5. BIN=/sbin/aprx
  6. CONF=/etc/aprx.conf
  7. PID=/var/run/aprx.pid
  8. aprx_start() {
  9. # Sanity checks.
  10. if [ ! -r $CONF ]; then # no config file, exit:
  11. echo "$CONF does not appear to exist. Abort."
  12. exit 1
  13. fi
  14. if [ -s $PID ]; then
  15. echo "aprx appears to already be running?"
  16. exit 1
  17. fi
  18. echo "Starting aprx daemon..."
  19. if [ -x $BIN ]; then
  20. $BIN -f $CONF
  21. fi
  22. }
  23. aprx_stop() {
  24. echo "Shutdown aprx gracefully..."
  25. if [ -r $PID ]; then
  26. kill -HUP $(cat $PID)
  27. rm -f $PID
  28. else
  29. killall -HUP -q aprx
  30. fi
  31. echo
  32. }
  33. aprx_restart() {
  34. aprx_stop
  35. sleep 3
  36. aprx_start
  37. }
  38. aprx_status() {
  39. if [ -e $PID ]; then
  40. echo "aprx is running."
  41. else
  42. echo "arpx is stopped."
  43. exit 1
  44. fi
  45. }
  46. case "$1" in
  47. start)
  48. aprx_start
  49. ;;
  50. stop)
  51. aprx_stop
  52. ;;
  53. restart)
  54. aprx_restart
  55. ;;
  56. status)
  57. aprx_status
  58. ;;
  59. *)
  60. echo "usage: `basename $0` {start|stop|restart|status}"
  61. esac