Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # chkconfig: 35 90 12
- # description: Geth Instance
- #
- # Get function from functions library
- USER=ethereum
- DATA_DIR=/opt/ethereum
- GETH_PATH=/usr/local/bin/geth
- PID_FILE=/var/run/geth.pid
- LOG_FILE=/var/log/geth.log
- LOCK_FILE=/var/lock/subsys/geth
- . /etc/init.d/functions
- # Start the service GETH
- start() {
- echo -n "Starting GETH: "
- sudo -u $USER $GETH_PATH --rpc --verbosity 3 --datadir /opt/ethereum >> $LOG_FILE 2>&1 &
- if [ $? -eq "0" ]; then
- echo $! > $PID_FILE
- ### Create the lock file ###
- touch $LOCK_FILE
- success $"geth startup"
- else
- failure $"geth startup"
- fi
- echo
- }
- # Restart the service geth
- stop() {
- echo -n "Stopping GETH: "
- if [ -e $LOCK_FILE ]; then
- if [ -e $PID_FILE ]; then
- PID=$(ps --ppid `cat $PID_FILE` -o pid=)
- if ps -p $PID > /dev/null
- then
- kill $PID
- success $"geth stop"
- else
- echo "Already stopped"
- failure $"geth stop"
- fi
- rm -f $PID_FILE
- else
- failure $"geth stop"
- fi
- rm -f $LOCK_FILE
- fi
- echo
- }
- ### main logic ###
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status geth
- ;;
- restart|reload|condrestart)
- stop
- start
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|status}"
- exit 1
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement