You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bitcoind.openrc 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/sbin/runscript
  2. # backward compatibility for existing gentoo layout
  3. #
  4. if [ -d "/var/lib/bitcoin/.bitcoin" ]; then
  5. BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoin/.bitcoin"
  6. else
  7. BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoind"
  8. fi
  9. BITCOIND_CONFIGFILE=${BITCOIND_CONFIGFILE:-/etc/bitcoin/bitcoin.conf}
  10. BITCOIND_PIDDIR=${BITCOIND_PIDDIR:-/var/run/bitcoind}
  11. BITCOIND_PIDFILE=${BITCOIND_PIDFILE:-${BITCOIND_PIDDIR}/bitcoind.pid}
  12. BITCOIND_DATADIR=${BITCOIND_DATADIR:-${BITCOIND_DEFAULT_DATADIR}}
  13. BITCOIND_USER=${BITCOIND_USER:-bitcoin}
  14. BITCOIND_GROUP=${BITCOIND_GROUP:-bitcoin}
  15. BITCOIND_BIN=${BITCOIND_BIN:-/usr/bin/bitcoind}
  16. name="Bitcoin Core Daemon"
  17. description="Bitcoin crypto-currency p2p network daemon"
  18. command="/usr/bin/bitcoind"
  19. command_args="-pid=\"${BITCOIND_PIDFILE}\" \
  20. -conf=\"${BITCOIND_CONFIGFILE}\" \
  21. -datadir=\"${BITCOIND_DATADIR}\" \
  22. -daemon \
  23. ${BITCOIND_OPTS}"
  24. required_files="${BITCOIND_CONFIGFILE}"
  25. start_stop_daemon_args="-u ${BITCOIND_USER} \
  26. -N ${BITCOIND_NICE:-0} -w 2000"
  27. pidfile="${BITCOIND_PIDFILE}"
  28. retry=60
  29. depend() {
  30. need localmount net
  31. }
  32. # verify
  33. # 1) that the datadir exists and is writable (or create it)
  34. # 2) that a directory for the pid exists and is writable
  35. # 3) ownership and permissions on the config file
  36. start_pre() {
  37. checkpath \
  38. -d \
  39. --mode 0750 \
  40. --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \
  41. "${BITCOIND_DATADIR}"
  42. checkpath \
  43. -d \
  44. --mode 0755 \
  45. --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \
  46. "${BITCOIND_PIDDIR}"
  47. checkpath -f \
  48. -o ${BITCOIND_USER}:${BITCOIND_GROUP} \
  49. -m 0660 \
  50. ${BITCOIND_CONFIGFILE}
  51. checkconfig || return 1
  52. }
  53. checkconfig()
  54. {
  55. if ! grep -qs '^rpcpassword=' "${BITCOIND_CONFIGFILE}" ; then
  56. eerror ""
  57. eerror "ERROR: You must set a secure rpcpassword to run bitcoind."
  58. eerror "The setting must appear in ${BITCOIND_CONFIGFILE}"
  59. eerror ""
  60. eerror "This password is security critical to securing wallets "
  61. eerror "and must not be the same as the rpcuser setting."
  62. eerror "You can generate a suitable random password using the following"
  63. eerror "command from the shell:"
  64. eerror ""
  65. eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
  66. eerror ""
  67. eerror "It is also recommended that you also set alertnotify so you are "
  68. eerror "notified of problems:"
  69. eerror ""
  70. eerror "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \
  71. "admin@foo.com"
  72. eerror ""
  73. return 1
  74. fi
  75. }