net-p2p/cardano-node: + Daemon for running Cardano blockchain node.

Sponsored by: Cardano BSD Alliance <cardanobsd.org>
This commit is contained in:
Gleb Popov 2022-08-14 21:44:28 +03:00
parent 78deabb5e1
commit 228df192b9
7 changed files with 1739 additions and 2 deletions

2
GIDs
View File

@ -250,7 +250,7 @@ jitsi:*:306:
jicofo:*:307:jitsi
jvb:*:308:jitsi
wazuh:*:309:
# free: 310
cardano:*:310:
# free: 311
_sphinx:*:312:
_fastdfs:*:313:

2
UIDs
View File

@ -255,7 +255,7 @@ jitsi:*:306:306::0:0:Jitsi Meet Owner:/nonexistent:/usr/sbin/nologin
jicofo:*:307:307::0:0:Jitsi Conference Focus Owner:/nonexistent:/usr/sbin/nologin
jvb:*:308:308::0:0:Jitsi VideoBridge Owner:/nonexistent:/usr/sbin/nologin
wazuh:*:309:309::0:0:Wazuh Owner:/var/ossec:/usr/sbin/nologin
# free: 310
cardano:*:310:310::0:0:Cardano Node Daemon:/nonexistent:/usr/sbin/nologin
# free: 311
_sphinx:*:312:312::0:0:Sphinxsearch Owner:/nonexistent:/usr/sbin/nologin
_fastdfs:*:313:313::0:0:FastDFS Owner:/nonexistent:/usr/sbin/nologin

View File

@ -17,6 +17,7 @@
SUBDIR += btcheck
SUBDIR += btpd
SUBDIR += c-lightning
SUBDIR += cardano-node
SUBDIR += cpuminer
SUBDIR += createtorrent
SUBDIR += ctcs

View File

@ -0,0 +1,417 @@
PORTNAME= cardano-node
PORTVERSION= 1.35.3
CATEGORIES= net-p2p
MAINTAINER= arrowd@FreeBSD.org
COMMENT= Core component of the Cardano decentralized blockchain
LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/LICENSE
BUILD_DEPENDS= ghc-8.10.7:lang/ghc810
USES= autoreconf:build cabal gmake libtool pkgconfig
USE_GITHUB= yes
GH_ACCOUNT= input-output-hk
GH_TUPLE= denisshevchenko:threepenny-gui:4ec92ded05ccf59ba4a874be4b404ac1b6d666b6:threepenny_gui/dist-newstyle/src/threepenn_-bd6c9d7cf9bd56f0 \
haskell-works:hw-aeson:6dc309ff4260c71d9a18c220cbae8aa1dfe2a02e:hw_aeson/dist-newstyle/src/hw-aeson-446b671374758b54 \
input-output-hk:Win32-network:3825d3abf75f83f406c1f7161883c438dac7277d:Win32_network/dist-newstyle/src/Win32-net_-5b9448ed2f179086 \
input-output-hk:cardano-base:0f3a867493059e650cda69e20a5cbf1ace289a57:cardano_base/dist-newstyle/src/cardano-b_-c8db9876882556ed \
input-output-hk:cardano-crypto:f73079303f663e028288f9f4a9e08bcca39a923e:cardano_crypto/dist-newstyle/src/cardano-c_-253fd88117badd8f \
input-output-hk:cardano-ledger:c7c63dabdb215ebdaed8b63274965966f2bf408f:cardano_ledger/dist-newstyle/src/cardano-l_-516df916d2b8a647 \
input-output-hk:cardano-prelude:bb4ed71ba8e587f672d06edf9d2e376f4b055555:cardano_prelude/dist-newstyle/src/cardano-p_-cae013aee062332a \
input-output-hk:ekg-forward:297cd9db5074339a2fb2e5ae7d0780debb670c63:ekg_forward/dist-newstyle/src/ekg-forwa_-439c40ba89351585 \
input-output-hk:flat:ee59880f47ab835dbd73bea0847dab7869fc20d8:flat/dist-newstyle/src/flat-9eba9ae2d4d970a \
input-output-hk:goblins:cde90a2b27f79187ca8310b6549331e59595e7ba:goblins/dist-newstyle/src/goblins-67efee8d68d79164 \
input-output-hk:hedgehog-extras:714ee03a5a786a05fc57ac5d2f1c2edce4660d85:hedgehog_extras/dist-newstyle/src/hedgehog-_-586c3da22a5ce29b \
input-output-hk:io-sim:f4183f274d88d0ad15817c7052df3a6a8b40e6dc:io_sim/dist-newstyle/src/io-sim-5409b7204b6dc065 \
input-output-hk:iohk-monitoring-framework:066f7002aac5a0efc20e49643fea45454f226caa:iohk_monitoring_framework/dist-newstyle/src/iohk-moni_-1defcf7452717dc5 \
input-output-hk:optparse-applicative:7497a29cb998721a9068d5725d49461f2bba0e7a:optparse_applicative/dist-newstyle/src/optparse-_-3cd678a226e0281a \
input-output-hk:ouroboros-network:cb9eba406ceb2df338d8384b35c8addfe2067201:ouroboros_network/dist-newstyle/src/ouroboros_-e51b1e265e7bb521 \
input-output-hk:plutus:a56c96598b4b25c9e28215214d25189331087244:plutus/dist-newstyle/src/plutus-5e27fa0483bd0166 \
input-output-hk:typed-protocols:181601bc3d9e9d21a671ce01e0b481348b3ca104:typed_protocols/dist-newstyle/src/typed-pro_-3f57698e3fbfd050 \
vshabanov:ekg-json:00ebe7211c981686e65730b7144fbf5350462608:ekg_json/dist-newstyle/src/ekg-json-e51d7dff12d02a95
GH_TUPLE+= input-output-hk:libsodium:${LIBSODIUM_HASH}:sodium \
bitcoin-core:secp256k1:${SECP256K1_HASH}:secp
CARDANO_NODE_HASH= 950c4e222086fed5ca53564e642434ce9307b0b9
LIBSODIUM_HASH= 66f017f16633f2060db25e17c170c2afa0f2a8a1
# Obtained from https://github.com/input-output-hk/cardano-node/blob/master/.github/workflows/github-page.yml#L21
SECP256K1_HASH= ac83be33d0956faf6b7f61a60ab524ef7d6a473a
USE_RC_SUBR= cardano_node
MAKE_ENV= PKG_CONFIG_PATH=${LIBS_PREFIX}${PREFIX}/libdata/pkgconfig/
LIBS_PREFIX= ${WRKDIR}/libs_install
BINARY_ALIAS= git=true
USERS= cardano
GROUPS= cardano
USE_CABAL= Diff-0.4.1 \
Glob-0.10.2_3 \
HUnit-1.6.2.0 \
Histogram-0.1.0.2 \
HsOpenSSL-0.11.7.2_3 \
ListLike-4.7.6 \
MonadRandom-0.5.3_2 \
OneTuple-0.3.1_3 \
Only-0.1_1 \
QuickCheck-2.14.2 \
SHA-1.6.4.4 \
SafeSemaphore-0.10.1_1 \
StateVar-1.2.2 \
Stream-0.4.7.2 \
Unique-0.4.7.9 \
abstract-deque-0.3 \
abstract-par-0.3.3 \
adjunctions-4.4_2 \
aeson-2.0.2.0_1 \
aeson-pretty-0.8.9_2 \
algebraic-graphs-0.6_1 \
ansi-terminal-0.11.1 \
ansi-wl-pprint-0.6.9_3 \
ap-normalize-0.1.0.1 \
appar-0.1.8 \
asn1-encoding-0.9.6_2 \
asn1-parse-0.9.5 \
asn1-types-0.3.4 \
assoc-1.0.2_3 \
async-2.2.4_1 \
async-extras-0.1.3.2 \
async-timer-0.1.4.1 \
atomic-primops-0.8.4 \
attoparsec-0.13.2.5_2 \
attoparsec-iso8601-1.0.2.0_3 \
auto-update-0.1.6 \
barbies-2.0.3.1 \
base-compat-0.11.2_1 \
base-compat-batteries-0.11.2 \
base-orphans-0.8.6 \
base16-0.3.1.0 \
base16-bytestring-1.0.2.0 \
base58-bytestring-0.1.0 \
base64-bytestring-1.2.1.0 \
base64-bytestring-type-1.0.1_14 \
basement-0.0.12_1 \
bech32-1.1.2 \
bifunctors-5.5.11_1 \
bimap-0.4.0_1 \
bin-0.1_2 \
binary-orphans-1.0.2_1 \
blaze-builder-0.4.2.2_1 \
blaze-html-0.9.1.2_2 \
blaze-markup-0.8.2.8_2 \
bsb-http-chunked-0.0.0.4_3 \
byteorder-1.0.4 \
bytestring-builder-0.10.8.2.0 \
cabal-doctest-1.0.9_2 \
call-stack-0.4.0 \
canonical-json-0.6.0.0_1 \
case-insensitive-1.2.1.0 \
cassava-0.5.2.0_9 \
cborg-0.2.6.0_2 \
cereal-0.5.8.2_1 \
charset-0.3.9 \
clock-0.8.3 \
cmdargs-0.10.21 \
code-page-0.2.1 \
colour-2.3.6 \
comonad-5.0.8_1 \
composition-prelude-3.0.0.2 \
concurrent-output-1.10.15 \
conduit-1.3.4.2 \
connection-0.3.1_1 \
constraints-0.13.3 \
constraints-extras-0.3.2.1 \
contravariant-1.5.5 \
cookie-0.4.5 \
criterion-1.5.13.0_2 \
criterion-measurement-0.1.3.0 \
cryptonite-0.27_1 \
data-accessor-0.2.3 \
data-accessor-transformers-0.2.1.7 \
data-default-0.7.1.1 \
data-default-class-0.1.2.0 \
data-default-instances-containers-0.0.1 \
data-default-instances-dlist-0.0.1 \
data-default-instances-old-locale-0.0.1 \
data-fix-0.3.2_3 \
dec-0.0.4_1 \
dense-linear-algebra-0.1.0.0 \
dependent-map-0.4.0.0 \
dependent-sum-0.7.1.0_2 \
dependent-sum-template-0.1.1.1 \
deque-0.4.4 \
deriving-aeson-0.2.8_1 \
deriving-compat-0.6 \
dictionary-sharing-0.1.0.0_3 \
digest-0.0.1.3 \
distributive-0.6.2.1_1 \
dlist-1.0 \
dns-3.0.4_1 \
dom-lt-0.2.3 \
easy-file-0.2.2 \
either-5.0.1.1_1 \
ekg-0.4.0.15_8 \
ekg-core-0.1.1.7_2 \
entropy-0.4.1.7 \
erf-2.0.0.0 \
extra-1.7.10 \
fast-logger-3.1.1 \
fgl-5.7.0.3 \
file-embed-0.0.15.0 \
filelock-0.1.1.5 \
fin-0.1.1_2 \
fingertree-0.1.5.0 \
fmlist-0.9.4 \
foldl-1.4.12_4 \
formatting-6.3.7_2 \
foundation-0.0.26.1_1 \
free-5.1.7_1 \
generic-data-0.9.2.1 \
generic-deriving-1.14.1 \
generic-monoid-0.1.0.1_1 \
generic-random-1.5.0.1 \
gnuplot-0.5.7 \
graphviz-2999.20.1.0 \
gray-code-0.3.1 \
groups-0.5.3 \
half-0.3.1 \
happy-1.20.0_1 \
hashable-1.3.5.0_1 \
haskell-lexer-1.1 \
haskell-src-exts-1.23.1 \
hedgehog-1.1.1_2 \
hedgehog-corpus-0.2.0 \
hedgehog-quickcheck-0.1.1_3 \
hostname-1.0 \
hourglass-0.2.12 \
hsc2hs-0.68.8_1 \
hspec-2.9.4 \
hspec-core-2.9.4 \
hspec-discover-2.9.4 \
hspec-expectations-0.8.2 \
http-api-data-0.4.3_6 \
http-client-0.7.11_1 \
http-client-tls-0.3.6.1 \
http-date-0.0.11 \
http-media-0.8.0.0_6 \
http-types-0.12.3 \
http2-3.0.3 \
indexed-traversable-0.1.2_2 \
indexed-traversable-instances-0.1.1_1 \
int-cast-0.2.0.0_4 \
integer-logarithms-1.0.3.1_3 \
invariant-0.5.5 \
io-streams-1.5.2.1_2 \
io-streams-haproxy-1.0.1.0_5 \
iproute-1.7.12 \
ixset-typed-0.5 \
js-chart-2.9.4.1 \
kan-extensions-5.2.3 \
katip-0.8.7.0_2 \
lazy-search-0.1.2.1 \
lazysmallcheck-0.6 \
lens-5.1_1 \
libyaml-0.1.2 \
lifted-async-0.10.2.2 \
lifted-base-0.2.3.12 \
list-t-1.0.5.1 \
logict-0.7.0.3_1 \
math-functions-0.3.4.2 \
megaparsec-9.2.0_2 \
memory-0.16.0_1 \
mersenne-random-pure64-0.2.2.0_1 \
microlens-0.4.12.0 \
microlens-mtl-0.2.0.1 \
microlens-th-0.4.3.10 \
microstache-1.0.2_3 \
mime-types-0.1.0.9 \
mmorph-1.1.5_1 \
monad-control-1.0.3.1 \
monad-par-0.3.5_2 \
monad-par-extras-0.3.3 \
mono-traversable-1.0.15.3 \
monoidal-containers-0.6.2.0_1 \
moo-1.2 \
mtl-compat-0.2.2 \
mwc-random-0.15.0.2_1 \
network-3.1.2.7 \
network-byte-order-0.1.6_1 \
network-uri-2.6.4.1 \
newtype-0.2.2.0_3 \
nothunks-0.1.3 \
old-locale-1.0.0.7_2 \
old-time-1.1.0.3_2 \
openssl-streams-1.2.3.0_1 \
optparse-applicative-0.17.0.0 \
optparse-generic-1.4.7_2 \
parallel-3.2.2.0_5 \
parser-combinators-1.3.0 \
parsers-0.12.10_2 \
partial-order-0.2.0.0 \
pem-0.2.4 \
pipes-4.3.16_3 \
polyparse-1.13_5 \
pretty-show-1.10 \
pretty-simple-4.0.0.0 \
prettyprinter-1.7.1 \
prettyprinter-ansi-terminal-1.1.3 \
primitive-0.7.3.0_2 \
process-extras-0.7.4 \
profunctors-5.6.2_2 \
prometheus-2.2.3 \
protolude-0.3.0 \
psqueues-0.2.7.3 \
quickcheck-instances-0.3.27_2 \
quickcheck-io-0.2.0 \
quiet-0.2 \
ral-0.1_2 \
random-1.2.1 \
random-shuffle-0.0.4 \
readable-0.3.1 \
recursion-schemes-5.2.2.2 \
reducers-3.12.4_2 \
reflection-2.1.6_1 \
regex-base-0.94.0.2_1 \
regex-posix-0.96.0.1_1 \
resourcet-1.2.4.3_1 \
safe-0.3.19 \
safe-exceptions-0.1.7.2 \
safecopy-0.10.4.2_4 \
scientific-0.3.7.0_3 \
secp256k1-haskell-0.6.0 \
selective-0.4.2 \
semialign-1.2.0.1_3 \
semigroupoids-5.3.7 \
semigroups-0.20 \
serialise-0.2.4.0_1 \
servant-0.19_4 \
servant-server-0.19_1 \
setenv-0.1.1.3_1 \
show-combinators-0.2.0.0_2 \
simple-sendfile-0.2.30 \
singleton-bool-0.1.5_3 \
size-based-0.1.2.0_1 \
snap-blaze-0.2.1.5 \
snap-core-1.0.4.2_1 \
snap-server-1.1.2.0_1 \
socks-0.6.1 \
some-1.0.2 \
sop-core-0.5.0.2 \
split-0.2.3.4_2 \
splitmix-0.1.0.4_1 \
statistics-0.16.0.1 \
statistics-linreg-0.3 \
streaming-0.2.3.1 \
streaming-binary-0.2.2.0 \
streaming-bytestring-0.2.1 \
streaming-commons-0.2.2.4 \
strict-0.4.0.1_4 \
strict-list-0.1.6 \
string-conv-0.1.2 \
string-conversions-0.4.0.1 \
string-qq-0.0.4 \
syb-0.7.2.1 \
system-filepath-0.4.14_1 \
tagged-0.8.6.1_3 \
tasty-1.4.2.1_2 \
tasty-expected-failure-0.12.3 \
tasty-golden-2.3.5 \
tasty-hedgehog-1.1.0.0_3 \
tasty-hunit-0.10.0.3 \
tasty-quickcheck-0.10.2 \
tasty-th-0.1.7 \
tdigest-0.2.1.1_3 \
temporary-1.3 \
terminal-size-0.3.2.1 \
testing-type-modifiers-0.1.0.1 \
text-short-0.1.5_1 \
tf-random-0.5 \
th-abstraction-0.4.3.0 \
th-compat-0.1.3_1 \
th-expand-syns-0.4.9.0 \
th-extras-0.0.0.6 \
th-lift-0.8.2_2 \
th-lift-instances-0.1.19_1 \
th-orphans-0.13.12_2 \
th-reify-many-0.1.10 \
th-utilities-0.2.4.3 \
these-1.1.1.1_6 \
time-compat-1.9.6.1_4 \
time-manager-0.0.0 \
time-units-1.0.0 \
tls-1.5.7 \
transformers-base-0.4.6 \
transformers-compat-0.6.6 \
transformers-except-0.1.2 \
tree-diff-0.2.1.1_2 \
type-equality-1_4 \
typed-process-0.2.8.0_1 \
typerep-map-0.5.0.0 \
unagi-chan-0.4.1.4 \
unbounded-delays-0.1.1.1 \
unix-bytestring-0.3.7.6 \
unix-compat-0.5.4_1 \
unix-time-0.4.7 \
unliftio-0.2.21.0 \
unliftio-core-0.2.0.1_2 \
unordered-containers-0.2.16.0 \
utf8-string-1.0.2 \
utility-ht-0.0.16 \
uuid-types-1.0.5_3 \
validation-selective-0.1.0.1 \
vault-0.3.1.5_2 \
vector-0.12.3.1_2 \
vector-algorithms-0.8.0.4_2 \
vector-binary-instances-0.2.5.2_2 \
vector-th-unbox-0.2.2_3 \
void-0.7.3 \
wai-3.2.3 \
wai-app-static-3.1.7.2_1 \
wai-extra-3.1.8 \
wai-logger-2.4.0 \
warp-3.3.19 \
wcwidth-0.0.2 \
websockets-0.12.7.3_1 \
websockets-snap-0.10.3.1 \
witherable-0.4.2_3 \
wl-pprint-annotated-0.1.0.1_1 \
wl-pprint-text-1.2.0.2 \
word8-0.1.3 \
x509-1.7.6 \
x509-store-1.6.9 \
x509-system-1.6.7 \
x509-validation-1.6.12 \
yaml-0.11.7.0 \
zlib-0.6.2.3_1 \
zlib-bindings-0.1.1.5_2
CABAL_PROJECT= append
CABAL_EXECUTABLES= cardano-node cardano-cli cardano-submit-api cardano-tracer
post-patch:
${REINPLACE_CMD} -e 's/$$(gitRevFromGit)/"${CARDANO_NODE_HASH}"/' \
-e '/Cardano.Git.RevFromGit/d' \
${WRKSRC}/cardano-git-rev/src/Cardano/Git/Rev.hs
${ECHO_CMD} "package *" >> ${WRKSRC}/cabal.project.${PORTNAME}
${ECHO_CMD} " extra-include-dirs: ${LIBS_PREFIX}${PREFIX}/include" >> ${WRKSRC}/cabal.project.${PORTNAME}
${ECHO_CMD} " extra-lib-dirs: ${LIBS_PREFIX}${PREFIX}/lib" >> ${WRKSRC}/cabal.project.${PORTNAME}
pre-build:
cd ${WRKSRC_sodium} && ./autogen.sh
cd ${WRKSRC_sodium} && ./configure --prefix=${PREFIX} --with-pthreads --disable-shared
cd ${WRKSRC_sodium} && ${GMAKE} -j${MAKE_JOBS_NUMBER} && ${GMAKE} DESTDIR=${LIBS_PREFIX} ${INSTALL_TARGET}
${MKDIR} ${LIBS_PREFIX}${PREFIX}/libdata/pkgconfig
${MV} ${LIBS_PREFIX}${PREFIX}/lib/pkgconfig/libsodium.pc ${LIBS_PREFIX}${PREFIX}/libdata/pkgconfig/libsodium.pc
cd ${WRKSRC_secp} && ./autogen.sh
cd ${WRKSRC_secp} && ./configure --prefix=${PREFIX} --enable-module-schnorrsig --enable-experimental --with-pic --disable-shared
cd ${WRKSRC_secp} && ${GMAKE} -j${MAKE_JOBS_NUMBER} && ${GMAKE} DESTDIR=${LIBS_PREFIX} ${INSTALL_TARGET}
${MV} ${LIBS_PREFIX}${PREFIX}/lib/pkgconfig/libsecp256k1.pc ${LIBS_PREFIX}${PREFIX}/libdata/pkgconfig/libsecp256k1.pc
.include <bsd.port.mk>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,309 @@
#!/bin/sh
# PROVIDE: cardano_node
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# -----------------------------------------------------------------------------
#
# This script supports running multiple instances of the daemon.
# To run additional instances make a symlink to script under different name:
#
# % ln -s %%PREFIX%%/etc/rc.d/cardano_node %%PREFIX%%/etc/rc.d/SOMENAME
#
# and define corresponding SOMENAME_* variables in /etc/rc.conf
# For example, if you linked the script to cardano_node_testnet, then each
# variable listed below should read as cardano_node_testnet_enable, etc.
#
# -----------------------------------------------------------------------------
#
# Add the following lines to /etc/rc.conf to enable this service:
#
# cardano_node_enable: Set to YES to enable cardano-node.
# Default: "NO"
#
# cardano_node_home: An absolute path to the daemon home directory.
# The directory will be created if not exists.
# Default: "/var/db/cardano_node"
#
# cardano_node_net: A network name to connect to.
# Default: "mainnet"
#
# cardano_node_port: Port to listen for connections on.
# Default: "6000"
#
# Advanced settings that usually don't need to be changed for simple usage cases:
#
# cardano_node_host: Host address to bind to.
# Default: "0.0.0.0"
#
#
# cardano_node_socket: An absolute path to the daemon socket file.
# Default: "${cardano_node_home}/cardano-node.sock"
#
# cardano_node_db: An absolute path to the database directory.
# Default: "${cardano_node_home}/${cardano_node_net}-db"
#
# cardano_node_topology: An absolute or a relative to ${cardano_node_home} path
# to the topology JSON file.
# Default: "${cardano_node_net}-configs/topology.json"
#
# cardano_node_config: An absolute or a relative to ${cardano_node_home} path
# to the cardano-node config.json file.
# Default: "${cardano_node_net}-configs/config.json"
#
# cardano_node_rts_flags: GHC runtime flags to be passed between "+RTS" and "-RTS".
# See https://downloads.haskell.org/ghc/latest/docs/html/users_guide/runtime_control.html
# for the meaning of these flags.
# Default: "-N -A64m -n4m -F1.2 -qg1"
#
# cardano_node_flags: Any additional command line flags to pass to cardano-node.
# Default: ""
#
. /etc/rc.subr
# The following code snippet was taken from security/openvpn/files/openvpn.in rc script.
# service(8) does not create an authentic environment, try to guess,
# and as of 10.3-RELEASE-p0, it will not find the indented name=
# assignments below. So give it a default.
# Trailing semicolon also for service(8)'s benefit:
name="$file" ;
case "$0" in
/etc/rc*)
# during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
# so get the name of the script from $_file
name="$_file"
;;
*/service)
# do not use this as $0
;;
*)
name="$0"
;;
esac
# default name to "cardano_node" if guessing failed
# Trailing semicolon also for service(8)'s benefit:
name="${name:-cardano_node}" ;
name="${name##*/}"
desc="Cardano Node daemon"
rcvar="${name}_enable"
command=%%PREFIX%%/bin/cardano-node
cardano_deployment_url="https://raw.githubusercontent.com/cardano-bsd-alliance/freebsd-ports-cardano-artifacts/master/cardano-node"
cardano_config_files="config byron-genesis shelley-genesis alonzo-genesis topology submit-api-config"
cardano_networks="mainnet testnet"
start_cmd="cardano_node_start"
start_precmd="cardano_node_prestart"
stop_cmd="cardano_node_stop"
status_cmd="cardano_node_status"
reload_cmd="cardano_node_reload"
fetch_cmd="cardano_node_fetch"
extra_commands="status fetch reload"
load_rc_config $name
eval ": \${${name}_enable:=NO}"
eval ": \${${name}_home:=\"/var/db/cardano_node\"}"
eval ": \${${name}_net:=\"mainnet\"}"
eval ": \${${name}_host:=\"0.0.0.0\"}"
eval ": \${${name}_port:=\"6000\"}"
eval ": \${${name}_socket:=\"\${${name}_home}/cardano-node.sock\"}"
eval ": \${${name}_db:=\"\${${name}_home}/\${${name}_net}-db\"}"
eval ": \${${name}_topology:=\"\${${name}_net}-configs/topology.json\"}"
eval ": \${${name}_config:=\"\${${name}_net}-configs/config.json\"}"
eval ": \${${name}_rts_flags:=\"-N -A64m -n4m -F1.2 -qg1\"}"
eval ": \${${name}_flags:=\"\"}"
# aliases
eval "_home=\${${name}_home}"
eval "_topology=\${${name}_topology}"
eval "_config=\${${name}_config}"
eval "_socket=\${${name}_socket}"
eval "_db=\${${name}_db}"
eval "_rts_flags=\${${name}_rts_flags}"
eval "_host=\${${name}_host}"
eval "_port=\${${name}_port}"
eval "_flags=\${${name}_flags}"
jail_root="${_home}/jail"
jail_topology="/topology_dir/`basename ${_topology}`"
jail_config="/config_dir/`basename ${_config}`"
jail_socket="/socket/`basename ${_socket}`"
jail_cmd="jail -c name=${name}_jail path=${jail_root} exec.jail_user=cardano exec.system_jail_user ip4=inherit ip6=inherit host=inherit"
pidfile="/var/run/${name}.pid"
flags="run +RTS ${_rts_flags} -RTS \
--database-path /db \
--host-addr ${_host} \
--port ${_port} \
--socket-path ${jail_socket} \
--topology ${jail_topology} \
--config ${jail_config} \
${_flags}"
sanity_check()
{
if [ ! -f "${_home}/${_topology}" -a ! -f "/${_topology}" ]
then
echo "Invalid value for ${name}_topology: missing file ${_topology}"
echo "You might want to run service ${name} onefetch"
exit 1
fi
if [ ! -f "${_home}/${_config}" -a ! -f "/${_config}" ]
then
echo "Invalid value for cardano_node_config: missing file ${_config}"
echo "You might want to run service ${name} onefetch"
exit 1
fi
return 0
}
_jail_dirs="/bin /etc /lib /libexec /socket"
_jail_mount_points="/dev /config_dir /topology_dir /db /logs"
create_jail()
{
destroy_jail
for d in ${_jail_dirs} ${_jail_mount_points}
do
mkdir -p "${jail_root}${d}"
done
cp /etc/resolv.conf "${jail_root}/etc/"
cp /etc/services "${jail_root}/etc/"
cp "$command" "${jail_root}/bin/"
ldd "$command" | cut -s -d " " -f 3 | grep -E '^(/lib|/usr)' | sort -u | xargs -I % cp % "${jail_root}/lib/"
# TODO: daemon fails with "Network.Socket.bind: permission denied" without suid
chmod +s "${jail_root}/bin/cardano-node"
cp /usr/sbin/nologin "${jail_root}/bin/"
cp /libexec/ld-elf.so.1 "${jail_root}/libexec"
# change directory because $cardano_node_{config,topology} may be relative paths
cd ${_home}
mount_nullfs -o ro `dirname ${_config}` "${jail_root}/config_dir"
mount_nullfs -o ro `dirname ${_topology}` "${jail_root}/topology_dir"
mount_nullfs "${_db}" "${jail_root}/db"
mount_nullfs "${_home}/logs" "${jail_root}/logs"
mount -o ruleset=4 -t devfs devfs "${jail_root}/dev"
}
destroy_jail()
{
for d in ${_jail_mount_points}
do
if [ -d "${jail_root}${d}" ]; then
umount -f "${jail_root}${d}" 2> /dev/null
fi
done
for d in ${_jail_dirs}
do
rm -rf "${jail_root}${d}"
done
for d in ${_jail_mount_points}
do
rmdir "${jail_root}${d}" 2> /dev/null
done
rmdir "${jail_root}" 2> /dev/null
}
cardano_node_prestart()
{
# Create Cardano home directory, if not exists
if [ ! -d "${_home}" ]; then
mkdir -p "${_home}"
chown cardano:cardano "${_home}"
fi
# Do the same for the logs directory
if [ ! -d "${_home}/logs" ]; then
mkdir -p "${_home}/logs"
chown cardano:cardano "${_home}/logs"
fi
# Remove the symlink to the socket file if there is no pid file
if [ -L "${_socket}" -a ! -f $pidfile ]; then
rm "${_socket}"
fi
sanity_check
}
cardano_node_start()
{
check_startmsgs && echo "Starting ${name}."
create_jail
if [ "$?" != "0" ]
then
echo "Failed to start ${name}: jail creation error"
return 1
fi
cd $_home && /usr/sbin/daemon -p $pidfile -S -T cardano-node \
${jail_cmd} command=/bin/cardano-node ${flags} 2>&1 > /dev/null
ln -s "${jail_root}/${jail_socket}" "${_socket}"
}
cardano_node_stop()
{
pid=$(check_pidfile "${pidfile}" jail)
if [ -z "${pid}" ]
then
echo "${name} is not running"
destroy_jail
return 1
else
echo "Stopping ${name}."
killall -j ${name}_jail -INT
wait_for_pids "$pid"
destroy_jail
rm ${_socket}
fi
}
cardano_node_status()
{
pid=$(check_pidfile "${pidfile}" jail)
if [ -z "${pid}" ]
then
echo "${name} is not running"
return 1
else
echo ${name} is running as pid $pid
fi
}
cardano_node_reload()
{
pid=$(check_pidfile "${pidfile}" jail)
if [ -z "${pid}" ]
then
echo "${name} is not running"
return 1
else
killall -j ${name}_jail -HUP
fi
}
cardano_node_fetch()
{
for net in ${cardano_networks}
do
echo "===> Fetching configuration files for ${net}"
mkdir -p "${_home}/${net}-configs"
mkdir -p "${_home}/${net}-db"
/usr/bin/apply "/usr/bin/fetch -a -o \
${_home}/${net}-configs ${cardano_deployment_url}/${net}-configs/%1.json" $cardano_config_files
chown -R cardano:cardano "${_home}/${net}-configs"
chown -R cardano:cardano "${_home}/${net}-db"
done
}
run_rc_command "$1"

View File

@ -0,0 +1,9 @@
Cardano is a proof-of-stake blockchain platform built by a decentralized
community of scientists, engineers, and thought leaders. Cardano is based on
Ouroboros, an environmentally sustainable, verifiably secure consensus protocol
with rigorous security guarantees.
This package provides a daemon program to run the Cardano node and a CLI
management tool.
WWW: https://cardano.org/