ref!: move convenience scripts to dashcore-utils

This commit is contained in:
AJ ONeal
2023-06-21 21:54:21 +00:00
parent ce2f07ef26
commit cec86d4ebf
13 changed files with 251 additions and 55 deletions

112
dashcore-utils/README.md Normal file
View 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/).

View 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

View File

@@ -8,7 +8,7 @@ fn_usage() { (
echo >&2 " dashd-hd-service-install [datadir] ['testnet']"
echo >&2 ""
echo >&2 "EXAMPLE"
echo >&2 " dashd-hd-service-install /mnt/vol_slc1_60g/dashcore/"
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,"
@@ -153,6 +153,12 @@ main() { (
)"
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

91
dashcore-utils/install.sh Normal file
View 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

View File

@@ -38,6 +38,8 @@ install:
~/Library/Preferences/org.dash.Dash-Qt.plist
```
[`dashcore-utils`](../dashcore-utils/) will also be installed if not present.
## Cheat Sheet
> _DASH_ (portmanteau of _Digital Cash_) is an international currency. _Dash

View File

@@ -53,22 +53,15 @@ __init_dashcore() {
# chmod 0600 "${HOME}/.dashcore/settings.json" || true
# fi
if ! test -e "$HOME/.local/bin/dash-qt-hd" ||
! test -e "$HOME/.local/bin/dash-qt-testnet"; then
"$HOME/.local/bin/webi" dashcore-utils
fi
# Always try to correct the permissions due to
# https://github.com/dashpay/dash/issues/5420
chmod -R og-rwx "${HOME}/.dashcore/" || true
if ! test -e "$HOME/.local/bin/dash-qt-hd"; then
webi_download \
"$WEBI_HOST/packages/dashcore/dash-qt-hd" \
"$HOME/.local/bin/dash-qt-hd"
chmod a+x "$HOME/.local/bin/dash-qt-hd"
fi
if ! test -e "$HOME/.local/bin/dash-qt-testnet"; then
webi_download \
"$WEBI_HOST/packages/dashcore/dash-qt-testnet" \
"$HOME/.local/bin/dash-qt-testnet"
chmod a+x "$HOME/.local/bin/dash-qt-testnet"
fi
}
# pkg_get_current_version is recommended, but not required

View File

@@ -29,6 +29,8 @@ install:
/mnt/<BLK_VOL>/dashcore/
```
[`dashcore-utils`](../dashcore-utils/) will also be installed if not present.
## Cheat Sheet
> A DASH _Full Node_ syncs and indexes the DASH blockchain and can be used to

View File

@@ -32,52 +32,16 @@ __init_dashd() {
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
if ! grep -q rpcuser "${HOME}/.dashcore/dash.conf"; then
my_main_pass="$(xxd -l16 -ps /dev/urandom)"
my_test_pass="$(xxd -l16 -ps /dev/urandom)"
{
echo '[main]'
echo "rpcuser=$(id -u -n)"
echo "rpcpassword=${my_main_pass}"
echo ''
echo '[test]'
echo "rpcuser=$(id -u -n)-test"
echo "rpcpassword=${my_test_pass}"
echo ''
} >> "${HOME}/.dashcore/dash.conf"
if ! test -e "$HOME/.local/bin/dashd-hd-service-install" ||
! test -e "$HOME/.local/bin/dashd-testnet-service-install"; then
"$HOME/.local/bin/webi" dashcore-utils
fi
# Always try to correct the permissions due to
# https://github.com/dashpay/dash/issues/5420
chmod -R og-rwx "${HOME}/.dashcore/" || true
echo "WEBI_HOST: $WEBI_HOST"
if ! test -e "$HOME/.local/bin/dashd-hd"; then
webi_download \
"$WEBI_HOST/packages/dashd/dashd-hd" \
"$HOME/.local/bin/dashd-hd"
chmod a+x "$HOME/.local/bin/dashd-hd"
fi
if ! test -e "$HOME/.local/bin/dashd-testnet"; then
webi_download \
"$WEBI_HOST/packages/dashd/dashd-testnet" \
"$HOME/.local/bin/dashd-testnet"
chmod a+x "$HOME/.local/bin/dashd-testnet"
fi
webi_download \
"$WEBI_HOST/packages/dashd/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/dashd/dashd-testnet-service-install" \
"$HOME/.local/bin/dashd-testnet-service-install"
chmod a+x "$HOME/.local/bin/dashd-testnet-service-install"
}
pkg_done_message() {