OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.7 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../runit/rocknet_runit.sh
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; version 2 of the License. A copy of the
  12. # GNU General Public License can be found in the file COPYING.
  13. # --- SDE-COPYRIGHT-NOTE-END ---
  14. export CANUSESERVICE=1
  15. service_create() {
  16. local service_name=$1 runstring="$2" finishstring="$3"
  17. mkdir -p $rocknet_tmp_base/$service_name/log
  18. # ./run
  19. cat <<-EOT > $rocknet_tmp_base/$service_name/run
  20. #!/bin/sh
  21. exec 2>&1
  22. $runstring
  23. EOT
  24. # ./log/run
  25. cat <<-EOT > $rocknet_tmp_base/$service_name/log/run
  26. #!/bin/sh
  27. exec 2>&1
  28. if [ ! -d /var/log/$service_name ]; then
  29. mkdir -p /var/log/$service_name
  30. chown log /var/log/$service_name
  31. fi
  32. exec chpst -ulog svlogd -tt /var/log/$service_name
  33. EOT
  34. # ./finish
  35. if [ "$finishstring" ]; then
  36. cat <<-EOT > $rocknet_tmp_base/$service_name/finish
  37. #!/bin/sh
  38. exec 2>&1
  39. $finishstring
  40. EOT
  41. chmod +x $rocknet_tmp_base/$service_name/finish
  42. fi
  43. chmod +x $rocknet_tmp_base/$service_name/{,log/}run
  44. ln -nfs $rocknet_tmp_base/$service_name/ /service/$service_name
  45. }
  46. service_destroy() {
  47. local service_name=$1 x=
  48. for x in . log; do
  49. if [ -d /service/$service_name/$x/supervise ]; then
  50. runsvctrl d /service/$service_name/$x
  51. svwaitdown /service/$service_name/$x
  52. fi
  53. done
  54. rm -f /service/$service_name
  55. rm -rf $rocknet_tmp_base/$service_name/
  56. }