Guest User

Untitled

a guest
Jul 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # redis - this script starts and stops the redis-server daemon
  4. #
  5. # chkconfig: - 85 15
  6. # description: Redis is a persistent key-value database
  7. # processname: redis-server
  8. # config: /etc/redis/redis.conf
  9. # config: /etc/sysconfig/redis
  10. # pidfile: /var/run/redis.pid
  11.  
  12. # Source function library.
  13. . /etc/rc.d/init.d/functions
  14.  
  15. # Source networking configuration.
  16. . /etc/sysconfig/network
  17.  
  18. # Check that networking is up.
  19. [ "$NETWORKING" = "no" ] && exit 0
  20.  
  21. redis="/usr/local/sbin/redis-server"
  22. prog=$(basename $redis)
  23.  
  24. REDIS_CONF_FILE="/usr/local/etc/redis.conf"
  25.  
  26. [ -f /etc/sysconfig/redis ] && . /etc/sysconfig/redis
  27.  
  28. lockfile=/var/lock/subsys/redis
  29.  
  30. start() {
  31. [ -x $redis ] || exit 5
  32. [ -f $REDIS_CONF_FILE ] || exit 6
  33. echo -n $"Starting $prog: "
  34. daemon $redis $REDIS_CONF_FILE
  35. retval=$?
  36. echo
  37. [ $retval -eq 0 ] && touch $lockfile
  38. return $retval
  39. }
  40.  
  41. stop() {
  42. echo -n $"Stopping $prog: "
  43. killproc $prog -QUIT
  44. retval=$?
  45. echo
  46. [ $retval -eq 0 ] && rm -f $lockfile
  47. return $retval
  48. }
  49.  
  50. restart() {
  51. stop
  52. start
  53. }
  54.  
  55. reload() {
  56. echo -n $"Reloading $prog: "
  57. killproc $redis -HUP
  58. RETVAL=$?
  59. echo
  60. }
  61.  
  62. force_reload() {
  63. restart
  64. }
  65.  
  66. rh_status() {
  67. status $prog
  68. }
  69.  
  70. rh_status_q() {
  71. rh_status >/dev/null 2>&1
  72. }
  73.  
  74. case "$1" in
  75. start)
  76. rh_status_q && exit 0
  77. $1
  78. ;;
  79. stop)
  80. rh_status_q || exit 0
  81. $1
  82. ;;
  83. restart|configtest)
  84. $1
  85. ;;
  86. reload)
  87. rh_status_q || exit 7
  88. $1
  89. ;;
  90. force-reload)
  91. force_reload
  92. ;;
  93. status)
  94. rh_status
  95. ;;
  96. condrestart|try-restart)
  97. rh_status_q || exit 0
  98. ;;
  99. *)
  100. echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
  101. exit 2
  102. esac
Add Comment
Please, Sign In to add comment