mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-02-14 17:49:53 +00:00
ref!: move convenience scripts to dashcore-utils
This commit is contained in:
112
dashcore-utils/README.md
Normal file
112
dashcore-utils/README.md
Normal file
@@ -0,0 +1,112 @@
|
||||
---
|
||||
title: Dash Core Desktop Wallet
|
||||
homepage: https://webinstall.dev/dashcore-utils/
|
||||
tagline: |
|
||||
Utilities for Dash Core (DASH / Digital Cash)
|
||||
---
|
||||
|
||||
To update, run `webi dashcore-utils`.
|
||||
|
||||
### Files
|
||||
|
||||
These are the files / directories that are created and/or modified with this
|
||||
install:
|
||||
|
||||
```txt
|
||||
~/.config/envman/PATH.env
|
||||
~/.local/opt/dashcore/
|
||||
|
||||
~/.local/bin/dash-qt-hd
|
||||
~/.local/bin/dashd-hd
|
||||
~/.local/bin/dashd-hd-service-install
|
||||
```
|
||||
|
||||
[`dashcore`](../dashcore/) will also be installed if not present.
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
> Convenience scripts for running the Dash Daemon or the Dash Core Desktop
|
||||
> Wallet.
|
||||
|
||||
- `dash-qt-hd`
|
||||
- `dash-qt-testnet`
|
||||
- `dashd-hd`
|
||||
- `dashd-hd-service-install`
|
||||
- `dashd-testnet`
|
||||
- `dashd-testnet-service-install`
|
||||
|
||||
For historical reasons [`dashd`](../dashd/) (System Daemon) and
|
||||
[`dash-qt`](../dashcore/) (Desktop Wallet) use _lossy_ keys (non-HD wallets) by
|
||||
default, and the storage options options are not intuitive.
|
||||
|
||||
These scripts run them with safer options that are easier to configure for
|
||||
server and desktop deployment, respectively.
|
||||
|
||||
### How to run the DASH System Daemon
|
||||
|
||||
1. Mount or otherwise designate a user-owned folder on a storage volume with
|
||||
60g+ free space, such as
|
||||
```sh
|
||||
/mnt/slc1_vol_100g/dashcore/
|
||||
```
|
||||
2. Generally you'll want to install the Dash Daemon as a system service
|
||||
```sh
|
||||
dashd-hd-install-service /mnt/vol_slc1_100g/dashcore/
|
||||
```
|
||||
|
||||
To accomplish the same manually you would:
|
||||
|
||||
1. Create `~/.dashcore/dash.conf` with reasonable defaults
|
||||
```ini
|
||||
```
|
||||
|
||||
Which is essentially the same as:
|
||||
|
||||
```sh
|
||||
my_user="$(id -u -n)"
|
||||
|
||||
sudo mkdir /mnt/slc1_vol_100g/dashcore/
|
||||
chown -R "$my_user" /mnt/slc1_vol_100g/dashcore/
|
||||
|
||||
mkdir -p ~/.dashcore/wallets/
|
||||
mkdir -p /mnt/slc1_vol_100g/dashcore/_data
|
||||
mkdir -p /mnt/slc1_vol_100g/dashcore/_caches
|
||||
|
||||
sudo env PATH="$PATH" serviceman add \
|
||||
--system --user "$my_user" --path "$PATH" --name dashd --force -- \
|
||||
dashd \
|
||||
-usehd \
|
||||
-conf="$HOME/.dashcore/dash.conf" \
|
||||
-walletdir="$HOME/.dashcore/wallets/" \
|
||||
-datadir=/mnt/slc1_vol_100g/dashcore/_data \
|
||||
-blocksdir=/mnt/slc1_vol_100g/dashcore/_caches
|
||||
```
|
||||
|
||||
See also:
|
||||
|
||||
- [The `dashd` Cheat Sheet](../dashd/).
|
||||
|
||||
### How to run the DASH Desktop Wallet
|
||||
|
||||
To open an existing (or create a new) Dash Desktop Wallet:
|
||||
|
||||
```sh
|
||||
dash-qt-hd
|
||||
```
|
||||
|
||||
Which is essentially the same as:
|
||||
|
||||
```sh
|
||||
dash-qt \
|
||||
-usehd \
|
||||
-walletdir="$HOME/.config/dashcore/wallets/" \
|
||||
-settings="$HOME/.config/dashcore/settings.json" \
|
||||
-datadir="$HOME/.dashcore/_data/" \
|
||||
-blocksdir="$HOME/.dashcore/_caches/"
|
||||
```
|
||||
|
||||
Or pass `-testnet` to use with _TestNet_.
|
||||
|
||||
See also:
|
||||
|
||||
- [The `dash-qt` Cheat Sheet](../dashcore/).
|
||||
21
dashcore-utils/dash-qt-hd
Normal file
21
dashcore-utils/dash-qt-hd
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# I don't have the gall to change the defaults (Webi values),
|
||||
# but I would *strongly* recommend that you do!
|
||||
#
|
||||
# Instance-specific data should be separate from global caches:
|
||||
#
|
||||
# -settings="$HOME/.config/dashcore/settings.json" \
|
||||
# -walletdir="$HOME/.config/dashcore/wallets/" \
|
||||
# -datadir="$HOME/.dashcore/_data/" \
|
||||
# -blocksdir="$HOME/.dashcore/_caches/" \
|
||||
|
||||
dash-qt \
|
||||
-usehd \
|
||||
-enablecoinjoin=1 \
|
||||
-coinjoinautostart=1 \
|
||||
-coinjoinrounds=16 \
|
||||
-coinjoindenomsgoal=10 \
|
||||
-coinjoindenomshardcap=25
|
||||
22
dashcore-utils/dash-qt-testnet
Normal file
22
dashcore-utils/dash-qt-testnet
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# I don't have the gall to change the defaults (Webi values),
|
||||
# but I would *strongly* recommend that you do!
|
||||
#
|
||||
# Instance-specific data should be separate from global caches:
|
||||
#
|
||||
# -settings="$HOME/.config/dashcore/settings.json" \
|
||||
# -walletdir="$HOME/.config/dashcore/wallets/" \
|
||||
# -datadir="$HOME/.dashcore/_data/" \
|
||||
# -blocksdir="$HOME/.dashcore/_caches/" \
|
||||
|
||||
dash-qt \
|
||||
-testnet \
|
||||
-usehd \
|
||||
-enablecoinjoin=1 \
|
||||
-coinjoinautostart=1 \
|
||||
-coinjoinrounds=16 \
|
||||
-coinjoindenomsgoal=10 \
|
||||
-coinjoindenomshardcap=25
|
||||
26
dashcore-utils/dash.example.conf
Normal file
26
dashcore-utils/dash.example.conf
Normal file
@@ -0,0 +1,26 @@
|
||||
[main]
|
||||
rpcuser=RPCUSER_MAIN
|
||||
rpcpassword=RPCPASS_MAIN
|
||||
bind=127.0.0.1:9999
|
||||
rpcbind=127.0.0.1:9998
|
||||
rpcallowip=127.0.0.1/16
|
||||
zmqpubrawtx=tcp://127.0.0.1:28332
|
||||
zmqpubrawtxlock=tcp://127.0.0.1:28332
|
||||
|
||||
[test]
|
||||
rpcuser=RPCUSER_TEST
|
||||
rpcpassword=RPCPASS_TEST
|
||||
bind=127.0.0.1:19999
|
||||
rpcbind=127.0.0.1:19998
|
||||
rpcallowip=127.0.0.1/16
|
||||
zmqpubrawtx=tcp://127.0.0.1:18009
|
||||
zmqpubrawtxlock=tcp://127.0.0.1:18009
|
||||
|
||||
[regtest]
|
||||
rpcuser=RPCUSER_REGTEST
|
||||
rpcpassword=RPCPASS_REGTEST
|
||||
bind=127.0.0.1:19899
|
||||
rpcbind=127.0.0.1:19898
|
||||
zmqpubrawtx=tcp://127.0.0.1:18809
|
||||
zmqpubrawtxlock=tcp://127.0.0.1:18809
|
||||
|
||||
46
dashcore-utils/dashd-hd
Normal file
46
dashcore-utils/dashd-hd
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# Unfortunately we can't know that datadir won't be used
|
||||
# for other non-cache files, but we can at least protect
|
||||
# the ones we're aware of.
|
||||
|
||||
my_netname="${1:-}"
|
||||
if test -n "${my_netname}"; then
|
||||
if test "${my_netname}" != mainnet &&
|
||||
test "${my_netname}" != testnet &&
|
||||
test "${my_netname}" != regnet &&
|
||||
test "${my_netname}" != devnet; then
|
||||
|
||||
echo ""
|
||||
echo "ERROR"
|
||||
echo " '${my_netname}' is not one of 'testnet', 'regnet', 'devnet'"
|
||||
echo ""
|
||||
echo ""
|
||||
fi
|
||||
if test "${my_netname}" != mainnet; then
|
||||
my_netname=''
|
||||
fi
|
||||
fi
|
||||
|
||||
my_net_arg=''
|
||||
if test -n "${my_netname}"; then
|
||||
my_net_arg="-${my_netname}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=2086
|
||||
dashd \
|
||||
-usehd \
|
||||
${my_net_arg} \
|
||||
-conf="$HOME/.dashcore/dash.conf" \
|
||||
-settings="$HOME/.dashcore/settings.json" \
|
||||
-walletdir="$HOME/.dashcore/wallets/" \
|
||||
-datadir="$HOME/.dashcore/_data/" \
|
||||
-blocksdir="$HOME/.dashcore/_data/"
|
||||
|
||||
# -enablecoinjoin=1 \
|
||||
# -coinjoinautostart=1 \
|
||||
# -coinjoinrounds=16 \
|
||||
# -coinjoindenomsgoal=10 \
|
||||
# -coinjoindenomshardcap=25
|
||||
176
dashcore-utils/dashd-hd-service-install
Normal file
176
dashcore-utils/dashd-hd-service-install
Normal file
@@ -0,0 +1,176 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
|
||||
fn_usage() { (
|
||||
echo >&2 ""
|
||||
echo >&2 "USAGE"
|
||||
echo >&2 " dashd-hd-service-install [datadir] ['testnet']"
|
||||
echo >&2 ""
|
||||
echo >&2 "EXAMPLE"
|
||||
echo >&2 " dashd-hd-service-install /mnt/vol_slc1_100g/dashcore/"
|
||||
echo >&2 ""
|
||||
echo >&2 "NOTE"
|
||||
echo >&2 " If a directory matching '/mnt/*/dashcore/' is found,"
|
||||
echo >&2 " it will be used automatically."
|
||||
echo >&2 ""
|
||||
); }
|
||||
|
||||
fn_datadir_help() { (
|
||||
my_vol="${1:-}"
|
||||
my_user="$(
|
||||
id -n -u
|
||||
)"
|
||||
my_group="$(
|
||||
id -n -g
|
||||
)"
|
||||
|
||||
echo >&2 ""
|
||||
echo >&2 "ERROR"
|
||||
echo >&2 " '${my_vol}' is not writable"
|
||||
echo >&2 ""
|
||||
echo >&2 "SOLUTION"
|
||||
echo >&2 " 1. Mount a large (50gb+) volume"
|
||||
echo >&2 ""
|
||||
echo >&2 " sudo mkdir -p /mnt/EXAMPLE"
|
||||
echo >&2 " sudo mount /dev/sdx1 /mnt/EXAMPLE"
|
||||
echo >&2 ""
|
||||
echo >&2 " 2. Create a 'dashcore' inside of it"
|
||||
echo >&2 ""
|
||||
echo >&2 " sudo mkdir -p '${my_vol}'"
|
||||
echo >&2 ""
|
||||
echo >&2 " 3. Make it writable to this user"
|
||||
echo >&2 ""
|
||||
echo >&2 " sudo chown -R '${my_user}':'${my_group}' '${my_vol}'"
|
||||
echo >&2 ""
|
||||
echo >&2 ""
|
||||
); }
|
||||
|
||||
fn_srv_install() { (
|
||||
my_vol="${1:-}"
|
||||
my_netname="${2:-}"
|
||||
|
||||
my_name='dashd'
|
||||
|
||||
# both of these will get '/testnet3' suffixes with -testnet
|
||||
my_datadir="${my_vol}/_data"
|
||||
my_blocksdir="${my_vol}/_caches"
|
||||
|
||||
if test -n "${my_netname}"; then
|
||||
if test "mainnet" = "${my_netname}"; then
|
||||
my_netname=""
|
||||
elif test "testnet" != "${my_netname}"; then
|
||||
fn_usage
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! test -d "${my_datadir}"; then
|
||||
mkdir "${my_datadir}"
|
||||
chmod 0700 "${my_datadir}"
|
||||
fi
|
||||
if ! test -d "${my_blocksdir}"; then
|
||||
mkdir -p "${my_blocksdir}"
|
||||
chmod 0700 "${my_blocksdir}"
|
||||
fi
|
||||
|
||||
my_net_flag=''
|
||||
if test -n "${my_netname}"; then
|
||||
# ex: -testnet
|
||||
my_net_flag="-${my_netname}"
|
||||
|
||||
# ex: dashd-testnet
|
||||
my_name="dashd-${my_netname}"
|
||||
fi
|
||||
|
||||
my_system_args=""
|
||||
my_kernel="$(
|
||||
uname -s
|
||||
)"
|
||||
if test "Darwin" != "${my_kernel}"; then
|
||||
my_user="$(
|
||||
id -u -n
|
||||
)"
|
||||
my_system_args="--system --username ${my_user}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2016,SC1090
|
||||
echo 'sudo env PATH="$PATH"' \
|
||||
"serviceman add ${my_system_args} --path \"\$PATH\" --name \"${my_name}\" --force --" \
|
||||
"dashd " \
|
||||
"${my_net_flag}" \
|
||||
-usehd \
|
||||
'-conf="$HOME/.dashcore/dash.conf"' \
|
||||
'-settings="$HOME/.dashcore/settings.json"' \
|
||||
'-walletdir="$HOME/.dashcore/wallets/"' \
|
||||
"-datadir=\"${my_datadir}\"" \
|
||||
"-blocksdir=\"${my_blocksdir}\""
|
||||
|
||||
if ! command -v serviceman > /dev/null; then
|
||||
echo ""
|
||||
echo "Installing 'serviceman'..."
|
||||
echo ""
|
||||
{
|
||||
curl -fsSL "${WEBI_HOST}/serviceman" | sh
|
||||
} > /dev/null
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. ~/.config/envman/PATH.env || true
|
||||
fi
|
||||
|
||||
mkdir -p "$HOME/.dashcore/wallets/"
|
||||
chmod 0700 "$HOME/.dashcore/wallets/"
|
||||
|
||||
mkdir -p "${my_datadir}"
|
||||
chmod 0700 "${my_datadir}"
|
||||
|
||||
mkdir -p "${my_blocksdir}"
|
||||
chmod 0700 "${my_blocksdir}"
|
||||
|
||||
cd "${my_vol}" || return 1
|
||||
# leave options unquoted so they're interpreted separately
|
||||
# shellcheck disable=SC2086
|
||||
sudo env PATH="${PATH}" \
|
||||
serviceman add ${my_system_args} --path "${PATH}" --name "${my_name}" --force -- \
|
||||
dashd \
|
||||
${my_net_flag} \
|
||||
-usehd \
|
||||
-conf="${HOME}/.dashcore/dash.conf" \
|
||||
-settings="${HOME}/.dashcore/settings.json" \
|
||||
-walletdir="${HOME}/.dashcore/wallets/" \
|
||||
-datadir="${my_datadir}" \
|
||||
-blocksdir="${my_blocksdir}"
|
||||
|
||||
); }
|
||||
|
||||
main() { (
|
||||
my_vol="${1:-}"
|
||||
my_netname="${2:-}"
|
||||
|
||||
if test -z "${my_vol}"; then
|
||||
my_vol="$(
|
||||
ls -d /mnt/*/dashcore/ 2> /dev/null || true
|
||||
)"
|
||||
fi
|
||||
|
||||
if test "help" = "${my_vol}" ||
|
||||
test "--help" = "${my_vol}"; then
|
||||
fn_usage
|
||||
return 0
|
||||
fi
|
||||
|
||||
if test -z "${my_vol}"; then
|
||||
fn_usage
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! test -d "${my_vol}" ||
|
||||
! test -w "${my_vol}"; then
|
||||
fn_datadir_help "${my_vol}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
fn_srv_install "${my_vol}" "${my_netname}"
|
||||
); }
|
||||
|
||||
main "${@:-}"
|
||||
13
dashcore-utils/dashd-testnet
Normal file
13
dashcore-utils/dashd-testnet
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# NOTE:
|
||||
# The '-testnet' flag will always cause a './testnet3/' folder
|
||||
# to be created under '-datadir' (it won't the 'datadir' directly)
|
||||
#
|
||||
# Example:
|
||||
# dashd -testnet -datadir="$HOME/.dashcore/"
|
||||
# will save to ~/.dashcore/testnet3/, NOT ~/.dashcore/
|
||||
|
||||
dashd-hd testnet
|
||||
5
dashcore-utils/dashd-testnet-service-install
Normal file
5
dashcore-utils/dashd-testnet-service-install
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
|
||||
dashd-hd-service-install "${1:-}" "testnet"
|
||||
91
dashcore-utils/install.sh
Normal file
91
dashcore-utils/install.sh
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
|
||||
__install_dashcore_utils() {
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dash-qt-hd" \
|
||||
"$HOME/.local/bin/dash-qt-hd"
|
||||
chmod a+x "$HOME/.local/bin/dash-qt-hd"
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dash-qt-testnet" \
|
||||
"$HOME/.local/bin/dash-qt-testnet"
|
||||
chmod a+x "$HOME/.local/bin/dash-qt-testnet"
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dashd-hd" \
|
||||
"$HOME/.local/bin/dashd-hd"
|
||||
chmod a+x "$HOME/.local/bin/dashd-hd"
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dashd-testnet" \
|
||||
"$HOME/.local/bin/dashd-testnet"
|
||||
chmod a+x "$HOME/.local/bin/dashd-testnet"
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dashd-hd-service-install" \
|
||||
"$HOME/.local/bin/dashd-hd-service-install"
|
||||
chmod a+x "$HOME/.local/bin/dashd-hd-service-install"
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dashd-testnet-service-install" \
|
||||
"$HOME/.local/bin/dashd-testnet-service-install"
|
||||
chmod a+x "$HOME/.local/bin/dashd-testnet-service-install"
|
||||
|
||||
if ! test -e "${HOME}/.dashcore"; then
|
||||
mkdir -p "${HOME}/.dashcore"
|
||||
chmod 0700 "${HOME}/.dashcore"
|
||||
fi
|
||||
if ! test -e "${HOME}/.dashcore/dash.conf"; then
|
||||
touch "${HOME}/.dashcore/dash.conf"
|
||||
chmod 0600 "${HOME}/.dashcore/dash.conf"
|
||||
fi
|
||||
|
||||
webi_download \
|
||||
"$WEBI_HOST/packages/dashcore-utils/dash.example.conf" \
|
||||
"$HOME/.dashcore/dash.example.conf"
|
||||
|
||||
if ! grep -q rpcuser ~/.dashcore/dash.conf; then
|
||||
cat ~/.dashcore/dash.example.conf >> ~/.dashcore/dash.conf
|
||||
|
||||
cmd_sed="sed -i -E"
|
||||
my_bsd_sed=''
|
||||
if ! sed -V 2>&1 | grep -q 'GNU'; then
|
||||
cmd_sed="sed -i .dascore-utils-bak -E"
|
||||
my_bsd_sed='true'
|
||||
fi
|
||||
|
||||
my_user="$(
|
||||
id -u -n
|
||||
)"
|
||||
my_main_pass="$(xxd -l16 -ps /dev/urandom)"
|
||||
my_test_pass="$(xxd -l16 -ps /dev/urandom)"
|
||||
my_regtest_pass="$(xxd -l16 -ps /dev/urandom)"
|
||||
|
||||
$cmd_sed "s/RPCUSER_MAIN/${my_user}/" ~/.dashcore/dash.conf
|
||||
$cmd_sed "s/RPCPASS_MAIN/${my_main_pass}/" ~/.dashcore/dash.conf
|
||||
|
||||
$cmd_sed "s/RPCUSER_TEST/${my_user}-test/" ~/.dashcore/dash.conf
|
||||
$cmd_sed "s/RPCPASS_TEST/${my_test_pass}/" ~/.dashcore/dash.conf
|
||||
|
||||
$cmd_sed "s/RPCUSER_REGTEST/${my_user}-regtest/" ~/.dashcore/dash.conf
|
||||
$cmd_sed "s/RPCPASS_REGTEST/${my_regtest_pass}/" ~/.dashcore/dash.conf
|
||||
|
||||
if test -n "${my_bsd_sed}"; then
|
||||
rm -f ~/.dashcore/dash.conf.dascore-utils-bak
|
||||
fi
|
||||
fi
|
||||
|
||||
export PATH="$HOME/.local/opt/dashcore/bin:$PATH"
|
||||
if ! command -v dashd > /dev/null ||
|
||||
! command -v dash-qt > /dev/null; then
|
||||
"$HOME/.local/bin/webi" dashcore
|
||||
fi
|
||||
|
||||
# Always try to correct the permissions due to
|
||||
# https://github.com/dashpay/dash/issues/5420
|
||||
chmod -R og-rwx "${HOME}/.dashcore/" || true
|
||||
}
|
||||
|
||||
__install_dashcore_utils
|
||||
Reference in New Issue
Block a user