Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/sbin/openrc-run3# backward compatibility for existing gentoo layout4#5if [ -d "/var/lib/bitcoin/.bitcoin" ]; then6BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoin/.bitcoin"7else8BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoind"9fi11BITCOIND_CONFIGFILE=${BITCOIND_CONFIGFILE:-/etc/bitcoin/bitcoin.conf}12BITCOIND_PIDDIR=${BITCOIND_PIDDIR:-/var/run/bitcoind}13BITCOIND_PIDFILE=${BITCOIND_PIDFILE:-${BITCOIND_PIDDIR}/bitcoind.pid}14BITCOIND_DATADIR=${BITCOIND_DATADIR:-${BITCOIND_DEFAULT_DATADIR}}15BITCOIND_USER=${BITCOIND_USER:-${BITCOIN_USER:-bitcoin}}16BITCOIND_GROUP=${BITCOIND_GROUP:-bitcoin}17BITCOIND_BIN=${BITCOIND_BIN:-/usr/bin/bitcoind}18BITCOIND_NICE=${BITCOIND_NICE:-${NICELEVEL:-0}}19BITCOIND_OPTS="${BITCOIND_OPTS:-${BITCOIN_OPTS}}"21name="Bitcoin Core Daemon"22description="Bitcoin cryptocurrency P2P network daemon"24command="${BITCOIND_BIN}"25command_args="-pid=\"${BITCOIND_PIDFILE}\" \26-conf=\"${BITCOIND_CONFIGFILE}\" \27-datadir=\"${BITCOIND_DATADIR}\" \28-daemon \29${BITCOIND_OPTS}"31required_files="${BITCOIND_CONFIGFILE}"32start_stop_daemon_args="-u ${BITCOIND_USER} \33-g ${BITCOIND_GROUP} \34-N ${BITCOIND_NICE} -w 2000"35pidfile="${BITCOIND_PIDFILE}"37# The retry schedule to use when stopping the daemon. Could be either38# a timeout in seconds or multiple signal/timeout pairs (like39# "SIGKILL/180 SIGTERM/300")40retry="${BITCOIND_SIGTERM_TIMEOUT}"42depend() {43need localmount net44}46# verify47# 1) that the datadir exists and is writable (or create it)48# 2) that a directory for the pid exists and is writable49# 3) ownership and permissions on the config file50start_pre() {51checkpath \52-d \53--mode 0750 \54--owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \55"${BITCOIND_DATADIR}"57checkpath \58-d \59--mode 0755 \60--owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \61"${BITCOIND_PIDDIR}"63checkpath -f \64-o "${BITCOIND_USER}:${BITCOIND_GROUP}" \65-m 0660 \66"${BITCOIND_CONFIGFILE}"68checkconfig || return 169}71checkconfig()72{73if grep -qs '^rpcuser=' "${BITCOIND_CONFIGFILE}" && \74! grep -qs '^rpcpassword=' "${BITCOIND_CONFIGFILE}" ; then75eerror ""76eerror "ERROR: You must set a secure rpcpassword to run bitcoind."77eerror "The setting must appear in ${BITCOIND_CONFIGFILE}"78eerror ""79eerror "This password is security critical to securing wallets "80eerror "and must not be the same as the rpcuser setting."81eerror "You can generate a suitable random password using the following "82eerror "command from the shell:"83eerror ""84eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"85eerror ""86eerror "It is recommended that you also set alertnotify so you are "87eerror "notified of problems:"88eerror ""89eerror "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \91eerror ""92return 193fi94}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.