-
-
Save BenMorganIO/9293fc731c45d363813432f4ede6a4b3 to your computer and use it in GitHub Desktop.
Geth init.d script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: geth | |
# Required-Start: $local_fs $remote_fs | |
# Required-Stop: | |
# X-Start-Before: rmnologin | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: | |
# Short-Description: Ethereum Mining | |
### END INIT INFO | |
NAME="geth" | |
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" | |
set -e | |
. /lib/lsb/init-functions | |
start() { | |
printf "Starting '$NAME'... " | |
geth --etherbase '0x123456789' --mine >> /var/log/geth.log 2>&1 & | |
printf "done\n" | |
} | |
stop() { | |
printf "Stopping '$NAME'... " | |
[ -z `cat /var/run/$NAME.pid 2>/dev/null` ] || \ | |
while test -d /proc/$(cat /var/run/$NAME.pid); do | |
killtree $(cat /var/run/$NAME.pid) 15 | |
sleep 0.5 | |
done | |
[ -z `cat /var/run/$NAME.pid 2>/dev/null` ] || rm /var/run/$NAME.pid | |
printf "done\n" | |
} | |
status() { | |
status_of_proc -p /var/run/$NAME.pid "" $NAME && exit 0 || exit $? | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
status) | |
status | |
;; | |
*) | |
echo "Usage: $NAME {start|stop|restart|status}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment