Advertisement
Guest User

Untitled

a guest
May 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # chkconfig: 35 90 12
  4. # description: Geth Instance
  5. #
  6. # Get function from functions library
  7. USER=ethereum
  8. DATA_DIR=/opt/ethereum
  9. GETH_PATH=/usr/local/bin/geth
  10. PID_FILE=/var/run/geth.pid
  11. LOG_FILE=/var/log/geth.log
  12. LOCK_FILE=/var/lock/subsys/geth
  13.  
  14. . /etc/init.d/functions
  15. # Start the service GETH
  16. start() {
  17. echo -n "Starting GETH: "
  18. sudo -u $USER $GETH_PATH --rpc --verbosity 3 --datadir /opt/ethereum >> $LOG_FILE 2>&1 &
  19. if [ $? -eq "0" ]; then
  20. echo $! > $PID_FILE
  21. ### Create the lock file ###
  22. touch $LOCK_FILE
  23. success $"geth startup"
  24. else
  25. failure $"geth startup"
  26. fi
  27. echo
  28. }
  29. # Restart the service geth
  30. stop() {
  31. echo -n "Stopping GETH: "
  32. if [ -e $LOCK_FILE ]; then
  33. if [ -e $PID_FILE ]; then
  34. PID=$(ps --ppid `cat $PID_FILE` -o pid=)
  35. if ps -p $PID > /dev/null
  36. then
  37. kill $PID
  38. success $"geth stop"
  39. else
  40. echo "Already stopped"
  41. failure $"geth stop"
  42. fi
  43. rm -f $PID_FILE
  44. else
  45. failure $"geth stop"
  46. fi
  47. rm -f $LOCK_FILE
  48. fi
  49. echo
  50. }
  51. ### main logic ###
  52. case "$1" in
  53. start)
  54. start
  55. ;;
  56. stop)
  57. stop
  58. ;;
  59. status)
  60. status geth
  61. ;;
  62. restart|reload|condrestart)
  63. stop
  64. start
  65. ;;
  66. *)
  67. echo $"Usage: $0 {start|stop|restart|reload|status}"
  68. exit 1
  69. esac
  70. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement