diff --git a/Vagrantfile b/Vagrantfile index cc353fa..2b3b4aa 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -95,7 +95,8 @@ Vagrant.configure(2) do |config| chef.environment = 'development' chef.add_recipe 'kosmos-base' chef.add_recipe 'kosmos_encfs' - # chef.add_recipe 'kosmos-postgresql::default' + # chef.add_recipe 'kosmos-bitcoin::snapd' + # chef.add_recipe 'kosmos-mediawiki' # chef.add_recipe 'kosmos-wordpress' # chef.add_recipe 'kosmos-ejabberd' # chef.add_recipe 'kosmos-hubot::botka_freenode' diff --git a/site-cookbooks/kosmos-bitcoin/attributes/default.rb b/site-cookbooks/kosmos-bitcoin/attributes/default.rb index c0b0831..62d6aca 100644 --- a/site-cookbooks/kosmos-bitcoin/attributes/default.rb +++ b/site-cookbooks/kosmos-bitcoin/attributes/default.rb @@ -1,2 +1,24 @@ -node.default['bitcoin']['username'] = 'satoshi' -node.default['bitcoin']['datadir'] = '/mnt/data/bitcoin' +node.default['bitcoin']['username'] = 'bitcoind' +node.default['bitcoin']['usergroup'] = 'bitcoind' +node.default['bitcoin']['datadir'] = '/mnt/data/bitcoin' + +node.default['bitcoin']['conf'] = { + testnet: 0, + irc: 1, + dnsseed: 1, + upnp: 1, + checkblocks: 10, + checklevel: 1, + txindex: 1, + whitelist: "127.0.0.1", + listen: 1, + server: 1, + rpcport: 8332, + rpcssl: 0, + rpcuser: 'bitcoind', + rpcbind: "127.0.0.1:8336", + port: 8335, + gen: 0, + zmqpubrawblock: "tcp://127.0.0.1:8337", + zmqpubrawtx: "tcp://127.0.0.1:8338" +} diff --git a/site-cookbooks/kosmos-bitcoin/recipes/default.rb b/site-cookbooks/kosmos-bitcoin/recipes/snapd.rb similarity index 68% rename from site-cookbooks/kosmos-bitcoin/recipes/default.rb rename to site-cookbooks/kosmos-bitcoin/recipes/snapd.rb index 594251e..a19b861 100644 --- a/site-cookbooks/kosmos-bitcoin/recipes/default.rb +++ b/site-cookbooks/kosmos-bitcoin/recipes/snapd.rb @@ -1,6 +1,6 @@ # # Cookbook:: kosmos-bitcoin -# Recipe:: default +# Recipe:: snapd # # The MIT License (MIT) # @@ -29,10 +29,28 @@ package 'snapd' snap_package 'bitcoin-core' -bitcoin_user = node['bitcoin']['username'] +bitcoin_user = node['bitcoin']['username'] +bitcoin_group = node['bitcoin']['usergroup'] +bitcoin_datadir = node['bitcoin']['datadir'] -# TODO create bitcoin datadir -# TODO create bitcoin.conf in datadir +directory bitcoin_datadir do + owner bitcoin_user + group bitcoin_group + mode '0755' + recursive true + action :create +end + +template "#{bitcoin_datadir}/bitcoin.conf" do + owner bitcoin_user + group bitcoin_group + variables conf: node['bitcoin']['conf'], + mainnet_conf: node['bitcoin']['mainnet_conf'], + testnet_conf: node['bitcoin']['testnet_conf'], + regtest_conf: node['bitcoin']['regtest_conf'] + action :create + # notifies :reload, "service[bitcoin]", :delayed +end mount "/home/#{bitcoin_user}/snap/bitcoin-core/common/.bitcoin" do device node['bitcoin']['data_dir'] diff --git a/site-cookbooks/kosmos-bitcoin/templates/andromeda.conf b/site-cookbooks/kosmos-bitcoin/templates/andromeda.conf new file mode 100644 index 0000000..12ad02b --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/templates/andromeda.conf @@ -0,0 +1,69 @@ +# Network-related settings: + +testnet=0 +irc=1 +dnsseed=1 +upnp=1 +checkblocks=10 +checklevel=1 +txindex=1 +whitelist=127.0.0.1 + +# Maximum number of inbound+outbound connections. +#maxconnections= + +listen=1 + + +# JSON-RPC options (for controlling a running Bitcoin/bitcoind process) + +# server=1 tells Bitcoin to accept JSON-RPC commands. +server=1 + +# You must set rpcuser and rpcpassword to secure the JSON-RPC api +rpcuser=kosmos +rpcpassword=yunobuttcoin + +# By default, only RPC connections from localhost are allowed. Specify +# as many rpcallowip= settings as you like to allow connections from +# other hosts (and you may use * as a wildcard character): +#rpcallowip=192.168.1.* +rpcallowip=127.0.0.1 + +# Listen for RPC connections on this TCP port: +rpcbind=127.0.0.1:8336 + + +# Listen for P2P connections on this TCP port: +port=8335 + +# Use Secure Sockets Layer (also known as TLS or HTTPS) to communicate +# with Bitcoin -server or bitcoind +rpcssl=0 + +# OpenSSL settings used when rpcssl=1 +#rpcsslciphers=TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH + + +# Miscellaneous options + +# Set gen=1 to attempt to generate bitcoins +gen=0 + +# Use SSE instructions to try to generate bitcoins faster. +#4way=1 + +# Pre-generate this many public/private key pairs, so wallet backups will be valid for +# both prior transactions and several dozen future transactions. +#keypool=100 + +# Pay an optional transaction fee every time you send bitcoins. Transactions with fees +# are more likely than free transactions to be included in generated blocks, so may +# be validated sooner. +#paytxfee=0.00 + +# Allow direct connections for the 'pay via IP address' feature. +#allowreceivebyip=1 + +zmqpubrawblock=tcp://127.0.0.1:8337 +zmqpubrawtx=tcp://127.0.0.1:8338 diff --git a/site-cookbooks/kosmos-bitcoin/templates/bitcoin.conf.erb b/site-cookbooks/kosmos-bitcoin/templates/bitcoin.conf.erb new file mode 100644 index 0000000..9e04e05 --- /dev/null +++ b/site-cookbooks/kosmos-bitcoin/templates/bitcoin.conf.erb @@ -0,0 +1,34 @@ +## +## bitcoin.conf configuration file. Lines beginning with # are comments. +## +## Generated by Chef. Do not edit directly, or your changes will be overwritten +## during the next Chef run! +## + +<% @conf.each do |key, value| %> + <%= "#{key}=#{value}" %> +<% end %> + +<% if @mainnet_conf %> +# Options only for mainnet +[main] +<% @mainnet_conf.each do |key, value| %> + <%= "#{key}=#{value}" %> +<% end %> +<% end %> + +<% if @testnet_conf %> +# Options only for testnet +[test] +<% @testnet_conf.each do |key, value| %> + <%= "#{key}=#{value}" %> +<% end %> +<% end %> + +<% if @regtest_conf %> +# Options only for regtest +[regtest] +<% @regtest_conf.each do |key, value| %> + <%= "#{key}=#{value}" %> +<% end %> +<% end %>