]>
Commit | Line | Data |
---|---|---|
234bfbf6 AW |
1 | Sample init scripts and service configuration for bitcoind |
2 | ========================================================== | |
3 | ||
4 | Sample scripts and configuration files for systemd, Upstart and OpenRC | |
5 | can be found in the contrib/init folder. | |
6 | ||
41020ebe W |
7 | contrib/init/bitcoind.service: systemd service unit configuration |
8 | contrib/init/bitcoind.openrc: OpenRC compatible SysV style init script | |
9 | contrib/init/bitcoind.openrcconf: OpenRC conf.d file | |
10 | contrib/init/bitcoind.conf: Upstart service configuration file | |
723664b5 | 11 | contrib/init/bitcoind.init: CentOS compatible SysV style init script |
234bfbf6 AW |
12 | |
13 | 1. Service User | |
14 | --------------------------------- | |
15 | ||
16 | All three startup configurations assume the existence of a "bitcoin" user | |
17 | and group. They must be created before attempting to use these scripts. | |
18 | ||
19 | 2. Configuration | |
20 | --------------------------------- | |
21 | ||
22 | At a bare minimum, bitcoind requires that the rpcpassword setting be set | |
23 | when running as a daemon. If the configuration file does not exist or this | |
24 | setting is not set, bitcoind will shutdown promptly after startup. | |
25 | ||
26 | This password does not have to be remembered or typed as it is mostly used | |
27 | as a fixed token that bitcoind and client programs read from the configuration | |
28 | file, however it is recommended that a strong and secure password be used | |
29 | as this password is security critical to securing the wallet should the | |
30 | wallet be enabled. | |
31 | ||
32 | If bitcoind is run with "-daemon" flag, and no rpcpassword is set, it will | |
33 | print a randomly generated suitable password to stderr. You can also | |
34 | generate one from the shell yourself like this: | |
35 | ||
36 | bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo' | |
37 | ||
38 | Once you have a password in hand, set rpcpassword= in /etc/bitcoin/bitcoin.conf | |
39 | ||
40 | For an example configuration file that describes the configuration settings, | |
41 | see contrib/debian/examples/bitcoin.conf. | |
42 | ||
43 | 3. Paths | |
44 | --------------------------------- | |
45 | ||
46 | All three configurations assume several paths that might need to be adjusted. | |
47 | ||
48 | Binary: /usr/bin/bitcoind | |
49 | Configuration file: /etc/bitcoin/bitcoin.conf | |
50 | Data directory: /var/lib/bitcoind | |
51 | PID file: /var/run/bitcoind/bitcoind.pid (OpenRC and Upstart) | |
52 | /var/lib/bitcoind/bitcoind.pid (systemd) | |
723664b5 | 53 | Lock file: /var/lock/subsys/bitcoind (CentOS) |
234bfbf6 AW |
54 | |
55 | The configuration file, PID directory (if applicable) and data directory | |
56 | should all be owned by the bitcoin user and group. It is advised for security | |
57 | reasons to make the configuration file and data directory only readable by the | |
58 | bitcoin user and group. Access to bitcoin-cli and other bitcoind rpc clients | |
59 | can then be controlled by group membership. | |
60 | ||
61 | 4. Installing Service Configuration | |
62 | ----------------------------------- | |
63 | ||
64 | 4a) systemd | |
65 | ||
7e6d23b1 | 66 | Installing this .service file consists of just copying it to |
234bfbf6 AW |
67 | /usr/lib/systemd/system directory, followed by the command |
68 | "systemctl daemon-reload" in order to update running systemd configuration. | |
69 | ||
70 | To test, run "systemctl start bitcoind" and to enable for system startup run | |
71 | "systemctl enable bitcoind" | |
72 | ||
73 | 4b) OpenRC | |
74 | ||
75 | Rename bitcoind.openrc to bitcoind and drop it in /etc/init.d. Double | |
76 | check ownership and permissions and make it executable. Test it with | |
77 | "/etc/init.d/bitcoind start" and configure it to run on startup with | |
78 | "rc-update add bitcoind" | |
79 | ||
80 | 4c) Upstart (for Debian/Ubuntu based distributions) | |
81 | ||
82 | Drop bitcoind.conf in /etc/init. Test by running "service bitcoind start" | |
83 | it will automatically start on reboot. | |
84 | ||
85 | NOTE: This script is incompatible with CentOS 5 and Amazon Linux 2014 as they | |
723664b5 | 86 | use old versions of Upstart and do not supply the start-stop-daemon utility. |
87 | ||
88 | 4d) CentOS | |
89 | ||
90 | Copy bitcoind.init to /etc/init.d/bitcoind. Test by running "service bitcoind start". | |
91 | ||
92 | Using this script, you can adjust the path and flags to the bitcoind program by | |
93 | setting the BITCOIND and FLAGS environment variables in the file | |
94 | /etc/sysconfig/bitcoind. You can also use the DAEMONOPTS environment variable here. | |
234bfbf6 AW |
95 | |
96 | 5. Auto-respawn | |
97 | ----------------------------------- | |
98 | ||
99 | Auto respawning is currently only configured for Upstart and systemd. | |
100 | Reasonable defaults have been chosen but YMMV. | |
101 | ||
102 |