snac_netbsd 783 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. #
  3. # PROVIDE: snac
  4. # REQUIRE: DAEMON
  5. # KEYWORD: shutdown
  6. . /etc/rc.subr
  7. name="snac"
  8. rcvar=${name}
  9. command="/usr/pkg/bin/snac"
  10. command_args="httpd /PATH/TO/SNACDATA"
  11. snac_log="/var/log/snac.log"
  12. pidfile="/var/run/${name}/${name}.pid"
  13. start_precmd="snac_precmd"
  14. run_as_user="SNACUSER"
  15. snac_precmd() {
  16. # Ensure log file exists and is writable by SNACUSER
  17. touch ${snac_log}
  18. chown ${run_as_user} ${snac_log}
  19. chmod 640 ${snac_log}
  20. # Ensure the run directory exists
  21. if [ ! -d /var/run/${name} ]; then
  22. mkdir -p /var/run/${name}
  23. chown ${run_as_user} /var/run/${name}
  24. fi
  25. command="/bin/sh -c 'cd /var/run/${name}; exec ${command} ${command_args} >${snac_log} 2>&1 & echo \$! >${pidfile}'"
  26. }
  27. load_rc_config $name
  28. run_rc_command "$1"