-
-
Save you21979/8481694 to your computer and use it in GitHub Desktop.
monacoind を centos6.xで動かすメモ
ansibleで自動インストールする手順です
curl -L https://raw.github.com/you21979/ansible-centos6/master/ansible-centos-install.sh | bash
wget https://gist.github.com/you21979/8481694/raw/60b6c3c7b02a19eab45f2531eb38a816cd1a8c47/monacoin.yml
echo "[app]" > hosts
echo "localhost" >> hosts
ansible-playbook monacoin.yml -i hosts -k
- /opt/monacoin/etc/monacoin.conf
上書きしちゃうとあぶないので手動で。
echo rpcuser=monacoinrpc > /opt/monacoin/etc/monacoin.conf
echo rpcpassword=`date | sha256sum|cut -b 1-44` >> /opt/monacoin/etc/monacoin.conf
echo rpcallowip=127.0.0.1 >> /opt/monacoin/etc/monacoin.conf
echo rpcport=4444 >> /opt/monacoin/etc/monacoin.conf
wget https://gist.github.com/you21979/8481694/raw/8c9955bf64dd438d6883dea53545019748302784/mona-init.sh
cp mona-init.sh /etc/init.d
chmod 755 /etc/init.d/mona-init.sh
/etc/init.d/mona-init.sh start
- monacoin:MNMAEMEiDqupwG7chfXxxGX9tWt8Y44PJx
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 | |
# | |
# monacoind Start monacoind | |
# | |
# chkconfig: 2345 08 92 | |
# description: Starts, stops | |
# | |
# Source function library. | |
. /etc/init.d/functions | |
# | |
MONA=/opt/monacoin | |
DAEMON=$MONA/bin/monacoind | |
CONF=$MONA/etc/monacoin.conf | |
DATA=$MONA/data | |
start() { | |
$DAEMON -conf=$CONF -datadir=$DATA -daemon | |
} | |
stop() { | |
kill `ps -ef|grep $DAEMON|grep -v grep|awk '{print $2}'` | |
} | |
restart() { | |
stop | |
sleep 1 | |
start | |
} | |
case "$1" in | |
start) | |
start | |
RETVAL=$? | |
;; | |
stop) | |
stop | |
RETVAL=$? | |
;; | |
restart|force-reload) | |
restart | |
RETVAL=$? | |
;; | |
*) | |
echo $"Usage: {start|stop|restart}" | |
RETVAL=2 | |
;; | |
esac | |
exit $RETVAL |
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
--- | |
- hosts: all | |
user: root | |
vars: | |
tmpdir: /tmp | |
installdir: /opt/monacoin | |
tasks: | |
- name: yum install | |
yum: name={{item}} state=latest | |
with_items: | |
- git | |
- gcc | |
- gcc-c++ | |
- boost-* | |
- zlib-devel | |
- zlib-static | |
- db4-cxx | |
- db4-devel | |
- name: www download openssl | |
get_url: url=http://www.openssl.org/source/openssl-1.0.1f.tar.gz dest={{tmpdir}} mode=0440 | |
- name: git download miniupnp | |
git: repo=https://github.com/miniupnp/miniupnp.git dest={{tmpdir}}/miniupnp | |
- name: git download monacoin | |
git: repo=https://github.com/monacoinproject/monacoin.git dest={{tmpdir}}/monacoin | |
- name: expand openssl | |
command: tar zxvf {{tmpdir}}/openssl-1.0.1f.tar.gz chdir={{tmpdir}} | |
- name: configure openssl | |
command: ./config chdir={{tmpdir}}/openssl-1.0.1f | |
- name: make openssl | |
command: make chdir={{tmpdir}}/openssl-1.0.1f | |
- name: make miniupnpc | |
command: make chdir={{tmpdir}}/miniupnp/miniupnpc | |
- name: prepare | |
file: src={{tmpdir}}/openssl-1.0.1f/include/openssl path={{tmpdir}}/monacoin/src/openssl state=link | |
- name: prepare | |
file: src={{tmpdir}}/miniupnp/miniupnpc path={{tmpdir}}/monacoin/src/miniupnpc state=link | |
- name: prepare | |
file: src={{tmpdir}}/miniupnp/miniupnpc/libminiupnpc.a path={{tmpdir}}/monacoin/src/libminiupnpc.a state=link | |
- name: make monacoin | |
command: make -f makefile.unix BOOST_LIB_SUFFIX=-mt LDFLAGS="-L{{tmpdir}}/openssl-1.0.1f -L." chdir={{tmpdir}}/monacoin/src | |
- name: install directory create | |
file: dest={{installdir}}/{{item}} state=directory | |
with_items: | |
- bin | |
- etc | |
- data | |
- name: install monacoind {{installdir}}/bin/monacoind | |
copy: src={{tmpdir}}/monacoin/src/monacoind dest={{installdir}}/bin/monacoind mode=0755 |
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
var bitcoin = require('bitcoin'); | |
var client = new bitcoin.Client({ | |
host: 'localhost', | |
port: 4444, | |
user: 'monacoinrpc', | |
pass: 'your password' | |
}); | |
client.getDifficulty(function(err, difficulty) { | |
if (err) { | |
return console.error(err); | |
} | |
console.log('Difficulty: ' + difficulty); | |
}); |
opensslを自前でコンパイルする必要があり、centos6のopensslだと機能足りなくてコアダンプする
monacoindを起動するとmonacoin.confを作れといわれるので作って起動する
あとでansible用意しよう
monacoin.confの設定を最初からローカルのJSON-RPCを通すようにしておきました。ポート4444で。
monacoin.ymlのmonacoinをlitecoinに置き換えるだけでlitecoinもコンパイルできます。git cloneの部分はlitecoinに変える必要あるけども
bitcoin,litecoin,sakuracoin,sha1coinのビルド用のansibleも↓にあります
https://github.com/you21979-storage/ansible-sakuravps
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
opensslが原因でコアダンプするんかな