-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1395 from braydonf/v4
bitcoind address index
- Loading branch information
Showing
12 changed files
with
245 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,6 @@ bower_components | |
report | ||
.DS_Store | ||
|
||
build | ||
|
||
bitcore.js | ||
bitcore.min.js | ||
bitcore.js.sig | ||
bitcore.min.js.sig | ||
tests.js |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
language: node_js | ||
sudo: false | ||
language: node_js | ||
env: | ||
- CXX=g++-4.8 CC=gcc-4.8 | ||
addons: | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- g++-4.8 | ||
- gcc-4.8 | ||
- libzmq3-dev | ||
node_js: | ||
- '0.12' | ||
before_install: | ||
- npm install -g bower | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
- '0.12' | ||
- '4' | ||
install: | ||
- bower install | ||
- npm install | ||
after_script: | ||
- gulp coveralls | ||
script: | ||
- npm run test |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/bin/bash | ||
set -e | ||
set -o pipefail | ||
|
||
log_title() { | ||
local code="\033[" | ||
local color="${code}1;34m" | ||
[ -z "$text" ] && local text="$color$1${code}0m" | ||
echo -e "\n$text" | ||
} | ||
|
||
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." | ||
|
||
package_arch="amd64" | ||
package_version=$(jq -r ".version" "${root_dir}/package.json") | ||
package_maintainer=$(jq -r ".author" "${root_dir}/package.json") | ||
package_description=$(jq -r ".description" "${root_dir}/package.json") | ||
|
||
deb_dir="${root_dir}/build/bitcore_${package_version}_${package_arch}" | ||
|
||
log_title "Making Debian package:\n" | ||
echo -e " Name: bitcore" | ||
echo -e " Version: ${package_version}" | ||
echo -e " Maintainer: ${package_maintainer}" | ||
echo -e " Description: ${package_description}" | ||
echo -e "" | ||
|
||
if [ -e "$deb_dir" ]; then rm -rf "$deb_dir"; fi | ||
|
||
escape() { | ||
sed -e 's/[]\/$*.^|[]/\\&/g' -e 's/&/\\&/g' <<< "$@" | ||
} | ||
|
||
replace_vars() { | ||
declare -r file="$1" | ||
declare -r target_file="$2" | ||
|
||
sed < "$file" \ | ||
-e "s/{{ deb_package_version }}/$(escape $package_version)/g" \ | ||
-e "s/{{ deb_package_description }}/$(escape $package_description)/g" \ | ||
-e "s/{{ deb_package_maintainer }}/$(escape $package_maintainer)/g" \ | ||
-e "s/{{ deb_package_arch }}/$(escape $package_arch)/g" \ | ||
> "$target_file" | ||
} | ||
|
||
log_title "Setting up Debian package:" | ||
mkdir -vp "$deb_dir/DEBIAN" \ | ||
"$deb_dir/etc/bitcore" \ | ||
"$deb_dir/usr/opt/bitcore" \ | ||
"$deb_dir/usr/opt/bitcore/bin" \ | ||
"$deb_dir/usr/bin" | ||
|
||
mkdir -vp "$deb_dir/etc/init" | ||
mkdir -vp "$deb_dir/etc/systemd/system" | ||
replace_vars "${root_dir}/scripts/debian/control" "$deb_dir/DEBIAN/control" | ||
replace_vars "${root_dir}/scripts/debian/postinst" "$deb_dir/DEBIAN/postinst" | ||
replace_vars "${root_dir}/scripts/debian/prerm" "$deb_dir/DEBIAN/prerm" | ||
replace_vars "${root_dir}/scripts/debian/bitcore.conf" "$deb_dir/etc/init/bitcore.conf" | ||
replace_vars "${root_dir}/scripts/debian/bitcore.service" "$deb_dir/etc/systemd/system/bitcore.service" | ||
replace_vars "${root_dir}/scripts/debian/bitcore-bitcoind.conf" "$deb_dir/etc/init/bitcore-bitcoind.conf" | ||
replace_vars "${root_dir}/scripts/debian/bitcore-bitcoind.service" "$deb_dir/etc/systemd/system/bitcore-bitcoind.service" | ||
chmod -vR 0755 "$deb_dir/DEBIAN/" | ||
|
||
log_title "Copying Bitcore" | ||
|
||
app_dir="$deb_dir/usr/opt/bitcore" | ||
|
||
cp -v "${root_dir}/bin/bitcored" "${app_dir}/bin/bitcored" | ||
cp -v "${root_dir}/bin/bitcore" "${app_dir}/bin/bitcore" | ||
chmod -vR 0755 "${app_dir}/bin/bitcore" "${app_dir}/bin/bitcored" | ||
cp -v "${root_dir}/package.json" "${app_dir}" | ||
cp -v "${root_dir}/README.md" "${app_dir}" | ||
cp -v "${root_dir}/index.js" "${app_dir}" | ||
pushd "${deb_dir}/usr/bin" | ||
ln -vs "../opt/bitcore/bin/bitcore" | ||
ln -vs "../opt/bitcore/bin/bitcored" | ||
ln -vs "../opt/bitcore/node_modules/.bin/bitcoind" "bitcore-bitcoind" | ||
popd | ||
|
||
log_title "Installing Bitcore Modules" | ||
pushd "${app_dir}" | ||
VERIFY_BITCOIN_DOWNLOAD=1 npm install --production | ||
echo "Cleanup Node.js addon binaries before packaging:" | ||
find "${app_dir}" -type f -name '*.node' -print -delete | ||
find "${app_dir}" -type f -name '*.o' -print -delete | ||
echo "Cleanup intermediate files:" | ||
rm -v "${deb_dir}/usr/opt/bitcore/node_modules/bitcore-node/bin/bitcoin-0.12.0-linux64.tar.gz" | ||
npm shrinkwrap --dev | ||
popd | ||
|
||
log_title "Building Debian package" | ||
dpkg-deb -Z gzip --verbose --build "$deb_dir" | ||
|
||
log_title "Signing Debian package" | ||
dpkg-sig --sign builder "${deb_dir}.deb" | ||
|
||
echo -e "Success.\n" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
description "Bitcoin Core for Bitcore" | ||
author "BitPay, Inc." | ||
|
||
limit nofile 20000 30000 | ||
|
||
start on runlevel [2345] | ||
stop on runlevel [016] | ||
|
||
kill timeout 300 | ||
kill signal SIGINT | ||
|
||
# user/group for bitcore daemon to run as | ||
setuid bitcore | ||
setgid bitcore | ||
|
||
# home dir of the bitcore daemon user | ||
env HOME=/home/bitcore | ||
|
||
respawn | ||
respawn limit 5 15 | ||
|
||
script | ||
exec bitcore-bitcored -datadir=/home/bitcore/.bitcore/data/ | ||
end script |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[Unit] | ||
Description=Bitcoin Core for Bitcore | ||
Requires=network.target | ||
|
||
[Service] | ||
Type=simple | ||
WorkingDirectory=/usr/opt/bitcore | ||
ExecStart=/usr/bin/bitcore-bitcoind -datadir=/home/bitcore/.bitcore/data/ | ||
ExecReload=/bin/kill -HUP $MAINPID | ||
Restart=on-failure | ||
RestartSec=15 | ||
User=bitcore | ||
ExecStartPre=/bin/mkdir -p /run/bitcore | ||
ExecStartPre=/bin/chown bitcore:bitcore /run/bitcore | ||
ExecStartPre=/bin/chmod 755 /run/bitcore | ||
PermissionsStartOnly=true | ||
TimeoutStopSec=300 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[Unit] | ||
Description={{ deb_package_description }} | ||
Requires=network.target | ||
|
||
[Service] | ||
Type=simple | ||
WorkingDirectory=/usr/opt/bitcore | ||
ExecStart=/usr/opt/bitcore/bin/bitcored | ||
ExecReload=/bin/kill -HUP $MAINPID | ||
Restart=on-failure | ||
RestartSec=15 | ||
User=bitcore | ||
ExecStartPre=/bin/mkdir -p /run/bitcore | ||
ExecStartPre=/bin/chown bitcore:bitcore /run/bitcore | ||
ExecStartPre=/bin/chmod 755 /run/bitcore | ||
PermissionsStartOnly=true | ||
TimeoutStopSec=300 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Package: bitcore | ||
Version: {{ deb_package_version }} | ||
Section: base | ||
Priority: optional | ||
Architecture: {{ deb_package_arch }} | ||
Depends: nodejs, nodejs-legacy, npm, build-essential, libzmq3-dev | ||
Maintainer: {{ deb_package_maintainer }} | ||
Description: {{ deb_package_description }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
set -e | ||
set -o pipefail | ||
|
||
# add group | ||
if ! getent group | grep -q "^bitcore:" ; then | ||
echo "Creating system group: bitcore" | ||
groupadd --system bitcore | ||
fi | ||
|
||
# add user | ||
if ! getent passwd | grep -q "^bitcore:"; then | ||
echo "Creating bitcore system user" | ||
useradd --gid "bitcore" --system -m bitcore | ||
fi | ||
|
||
# build nodejs addons | ||
cd "/usr/opt/bitcore" | ||
SKIP_BITCOIN_DOWNLOAD=1 npm rebuild | ||
|
||
# setup data directory | ||
mkdir -p "/home/bitcore/.bitcore/data" | ||
chown -R bitcore:bitcore "/home/bitcore/.bitcore" | ||
|
||
# start bitcore | ||
if hash service 2> /dev/null; then | ||
service bitcore start || echo "bitcore could not be registered or started" | ||
elif hash start 2> /dev/null; then | ||
start bitcore || echo "bitcore could not be registered or started" | ||
elif hash systemctl 2> /dev/null; then | ||
{ | ||
systemctl enable "bitcore.service" && \ | ||
systemctl start "bitcore.service" | ||
} || echo "bitcore could not be registered or started" | ||
else | ||
echo 'Your system does not appear to use upstart or systemd, so bitcore could not be started' | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
if hash service 2> /dev/null; then | ||
service bitcore stop || echo "bitcore wasn't running!" | ||
elif hash stop 2> /dev/null; then | ||
stop "$service_name" || echo "bitcore wasn't running!" | ||
elif hash systemctl 2> /dev/null; then | ||
systemctl disable "bitcore.service" || echo "bitcore wasn't running!" | ||
else | ||
echo "Your system does not appear to use upstart or systemd, so bitcore could not be stopped" | ||
fi |