Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

snf-server.openbsd 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/bin/sh
  2. #
  3. # SNFServer This shell script takes care of starting and stopping
  4. # the MicroNeil SNFServer daemon for OpenBSD systems.
  5. # Author: Alban Deniz
  6. #
  7. # Copyright (C) 2008 ARM Research Labs, LLC.
  8. # See www.armresearch.com for the copyright terms.
  9. #
  10. # Location of installation.
  11. installedDir="PREFIX"
  12. # Location of programs.
  13. dir="$installedDir/sbin"
  14. # Name of config file.
  15. configFile="CONFFILE"
  16. # Name of daemon.
  17. prog="SNFServer"
  18. # Name of client.
  19. clientProg="SNFClient"
  20. # Name of user to run as.
  21. userName="snfilter"
  22. # Start command.
  23. snfStartCmd="$dir/$prog $configFile > /dev/null 2>&1 &"
  24. start(){
  25. SNFPID=`ps -axww | grep $dir/$prog | grep -v grep | awk '{print $1}'`
  26. echo -n " $prog "
  27. if [ -n "$SNFPID" ] ; then
  28. echo "already running"
  29. return 1
  30. else
  31. su -m $userName -c "$snfStartCmd" > /dev/null 2>&1
  32. RETVAL=$?
  33. if [ $RETVAL -eq 0 ]; then
  34. $dir/$clientProg -status.second > /dev/null 2>&1
  35. RETVAL=$?
  36. fi
  37. fi
  38. if [ $RETVAL -eq 0 ]; then
  39. echo "started "
  40. else
  41. echo "failed "
  42. fi
  43. return $RETVAL
  44. }
  45. stopFunction(){
  46. echo -n " $prog "
  47. SNFPID=`ps -axww | grep $dir/$prog | grep -v grep | awk '{print $1}'`
  48. if [ -n "$SNFPID" ]; then
  49. $dir/$clientProg -shutdown > /dev/null 2>&1
  50. sleep 10
  51. SNFPID=`ps -axww | grep $dir/$prog | grep -v grep | awk '{print $1}'`
  52. if [ -n "$SNFPID" ]; then
  53. kill $SNFPID
  54. RETVAL=$?
  55. else
  56. RETVAL=0
  57. fi
  58. echo -n "stopped"
  59. else
  60. echo -n "not running"
  61. RETVAL=1
  62. fi
  63. echo ""
  64. return $RETVAL
  65. }
  66. restart(){
  67. stopFunction
  68. start
  69. }
  70. status(){
  71. SNFPID=`ps -axww | grep $dir/$prog | grep -v grep | awk '{print $1}'`
  72. if [ -n "$SNFPID" ] ; then
  73. echo "$prog (pid $SNFPID) is running"
  74. return 0
  75. else
  76. echo "$prog is not running"
  77. return 0
  78. fi
  79. }
  80. # See how we were called.
  81. case "$1" in
  82. start)
  83. start
  84. ;;
  85. stop)
  86. stopFunction
  87. ;;
  88. status)
  89. status $prog
  90. ;;
  91. restart)
  92. restart
  93. ;;
  94. *)
  95. echo "Usage: $0 {start|stop|status|restart}"
  96. exit 1
  97. esac
  98. exit $?