Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working standup scripts #15

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

jodobear
Copy link

Installs:

  1. Bitcoin core using Tor - specify external data dir
  2. C-lightning
  3. LND
  4. Esplora - specify external data dir
  5. BTCPay Server needs blockchain data corruption issue resolved.

@ChristopherA
Copy link
Contributor

@Fonta1n3 @shannona Can you review this PR early next week?

Copy link
Contributor

@shannona shannona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scripts are looking very nice. I like the organization and the use of the config file.

I did a medium-level dive, reading the README, reading the config file, and trying out an install on a fairly fresh Debian 9 system with c-lightning. Generally looks great, but there seem to be a few discrepancies in the script and more notably c-lightning didn't install.

# if you are going to access it locally then you can just use your hostname and add .local like so: hostname.local
FQDN=
# the region in which the server is hosted. Required for timezone settings
REGION=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to give an example of this, or tell users where to go to get the right format.

Copy link
Author

@jodobear jodobear Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the following:

FQDN : e.g. myawesomedomain.com

REGION : e.g. UCT, GMT, Pacific, America/New_York, Europe/Madrid, Asia/Kolkata

Copy link

@matthiasdebernardini matthiasdebernardini Dec 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debian comes with curl, so the commands below might be useful if you don't know the codes by heart

curl https://ipinfo.io/ip

curl https://json.geoiplookup.io/<Public_IP>

Although this would probably only work with a VPS (unless they have a static IP)

###########################
# The bitcoin network you want bitcoind to start with. Valid choices:
# mainnet, testnet or regtest
NETWORK=mainnet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest we default this to testnet, to force someone to purposefully change it to choose to engage with real funds.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


3. Edit config for your node setup using your favourite text editor:
# nano ss.conf

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be helpful to say. "You must change [A], and you will probably want to change [B] and [C], but look at the whole file.

Copy link
Author

@jodobear jodobear Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the following:

You must modify USERPASS else, your server will be unprotected and provide values for all the variables under VPS if installing on a VPS and set to true. Do note that the script defaults to testnet full node. Make appropriate changes.

# c-lightning options
###########################
# http-plugin
# CLN_HTTP_PLUGIN=flase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hasn't been implemented, hence set to false


5. Display help:
# source ss_00_main.sh -h

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be an extra step. (This implies that you need to source the script, then get the help.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to source ss_01_help.sh

# prompt user before continuing with installation
if ! "$NOPROMPT"; then
read -rp "Continue with installation? (Y/n): " confirm
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ("Y/n") implies that "Y"es is the default, but when I just hit return, it said "Entered . Exiting.." and quit.

Either this should be set to "Y" as a default (e.g., $confirm = "Y") or it should requery if you fail to enter an answer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

cp -r $SCRIPTS_DIR ~standup/
chown standup ~standup/scripts-conf
cd ~standup/scripts-conf
rm -r $SCRIPTS_DIR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the first use of ~standup/scripts-conf:

chown: cannot access '/home/standup/scripts-conf': No such file or directory
-bash: cd: /home/standup/scripts-conf: No such file or directory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably tell people that if they want to review the scripts they're in ~standup/scripts

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Added following to README:

  • Move the standup-scripts directory to /home/standup/standup-scripts. If you want to review the scripts later, you can find them at this location.

sudo -u standup git clone https://github.com/Start9Labs/c-lightning-http-plugin.git "$LIGHTNING_DIR"/plugings/
cd "$LIGHTNING_DIR"/plugings/c-lightning-http-plugin/
cargo build --release
chmod a+x /home/you/.lightning/plugins/c-lightning-http-plugin/target/release/c-lightning-http-plugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/home/you ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP

#!/bin/bash

# standup script - install c-lightning

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some type of fatal error here:

-------Standup - downloading & Installing c-lightning

fatal: Could not change back to '/root/Bitcoin-Standup-Scripts/Scripts/scripts': Permission denied
-bash: cd: /home/standup/lightning: No such file or directory
error: pathspec 'v0.9.1' did not match any file(s) known to git.
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
-bash: ./configure: No such file or directory
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target 'install'. Stop.
-bash: : command not found

Debian 9. Fresh Linode (with a bit of security added). Run as root.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's strange. If run as root, it should be able to cd. I haven't had issues with this. What security measures might have caused this?

Did you initiate c-lightning installation after completing the installation of bitcoind?


QR Code:
--------
Upon completion of the script there will be a QR code saved to /qrcode.png which you can open and scan:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything that installs a qrcode.png right now.

ls -lagh /qrcode.png

ls: cannot access '/qrcode.png': No such file or directory

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I definitely missed that one

@shannona
Copy link
Contributor

shannona commented Oct 6, 2020

After this settles, my next question is going to be: how can we merge this into the StackScript for Linode, since that's our preferred methodology for the Learning Bitcoin course (and at the least we'd like the automatic c-lightning install.)

@jodobear
Copy link
Author

After this settles, my next question is going to be: how can we merge this into the StackScript for Linode, since that's our preferred methodology for the Learning Bitcoin course (and at the least we'd like the automatic c-lightning install.)

I can just merge relevant parts into a single script with c-lightning for the StackScript. Does that work?

@shannona
Copy link
Contributor

shannona commented Nov 3, 2020

After this settles, my next question is going to be: how can we merge this into the StackScript for Linode, since that's our preferred methodology for the Learning Bitcoin course (and at the least we'd like the automatic c-lightning install.)

I can just merge relevant parts into a single script with c-lightning for the StackScript. Does that work?

Definitely!

@ChristopherA
Copy link
Contributor

@jodobear wrote

I can just merge relevant parts into a single script with c-lightning for the StackScript. Does that work?

Did this happen? Should this PR be closed, or is there still useful code for the future here?

@ChristopherA
Copy link
Contributor

@icculp @nochiel — any desire to pick up this PR, test it, and see if we can't merged into master?

@nochiel
Copy link
Contributor

nochiel commented Jul 21, 2021

@icculp @nochiel — any desire to pick up this PR, test it, and see if we can't merged into master?

I've begun reviewing the PR.

@icculp
Copy link
Contributor

icculp commented Jul 21, 2021

Funny timing Nick, I started looking at it just a little while ago as well

Copy link
Contributor

@nochiel nochiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I've annotated some scripts with a few comments/questions.

@@ -0,0 +1,60 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming availability of coreutils, shouldn't the shebang be#!/usr/bin/env bash instead of hardcoding the location of bash?

Comment on lines +17 to +19
bold=$(tput bold)
normal=$(tput sgr0)
underline=$(tput smul)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the script check for ncurses before using tput? (Or can we assume that it is always install wtih the debian base system.)

Update: No need to check for ncurses because the Debian base system install contains:

# aptitude search ~pimportant ~prequired ~pimportant -F%p
adduser
apt
apt-utils
base-files
base-passwd
bash
bsdmainutils
bsdutils
coreutils
cpio
cron
dash
debconf
debconf-i18n
debian-archive-keyring
debianutils
diffutils
dmidecode
dpkg
e2fslibs
e2fsprogs
fdisk
findutils
gdbm-l10n
gpgv
grep
gzip
hostname
ifupdown
init
init-system-helpers
iproute2
iptables
iputils-ping
isc-dhcp-client
isc-dhcp-common
kmod
less
libapt-inst2.0
libapt-pkg5.0
libc-bin
libcomerr2
libpam-modules
libpam-modules-bin
libpam-runtime
libss2
libudev1
login
logrotate
mawk
mount
nano
ncurses-base
ncurses-bin
netbase
passwd
perl-base
procps
readline-common
rsyslog
sed
sensible-utils
systemd
systemd-sysv
sysvinit-utils
tar
tasksel
tasksel-data
tzdata
udev
util-linux
vim-common
vim-tiny
whiptail

5. Display help:
# source ss_00_main.sh -h

This script can be installed on any Debian based system. By default this script will:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This script can be installed on any Debian based system. By default this script will:
This script can be installed on any Debian based system. The [Debian base system](https://www.debian.org/doc/debian-policy/ch-binary.html#base-system) installs the following packages which this script assumes are [standard](https://wiki.debian.org/tasksel#A.22standard.22_task):
<pre>
$ aptitude search ~pimportant ~prequired ~pimportant -F%p
adduser
apt
apt-utils
base-files
base-passwd
bash
bsdmainutils
bsdutils
coreutils
cpio
cron
dash
debconf
debconf-i18n
debian-archive-keyring
debianutils
diffutils
dmidecode
dpkg
e2fslibs
e2fsprogs
fdisk
findutils
gdbm-l10n
gpgv
grep
gzip
hostname
ifupdown
init
init-system-helpers
iproute2
iptables
iputils-ping
isc-dhcp-client
isc-dhcp-common
kmod
less
libapt-inst2.0
libapt-pkg5.0
libc-bin
libcomerr2
libpam-modules
libpam-modules-bin
libpam-runtime
libss2
libudev1
login
logrotate
mawk
mount
nano
ncurses-base
ncurses-bin
netbase
passwd
perl-base
procps
readline-common
rsyslog
sed
sensible-utils
systemd
systemd-sysv
sysvinit-utils
tar
tasksel
tasksel-data
tzdata
udev
util-linux
vim-common
vim-tiny
whiptail
</pre>
By default this script will:

@@ -0,0 +1,60 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#!/bin/bash
#!/usr/bin/env bash

@@ -0,0 +1,320 @@
#!bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#!bin/bash
#!/usr/bin/env bash

if [ -n "$SSH_KEY" ] && [[ "$SSH_KEY" != "__UNDEFINED__" ]]; then
mkdir ~standup/.ssh
echo "$SSH_KEY" >> ~standup/.ssh/authorized_keys
chown -R standup ~standup/.ssh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
chown -R standup ~standup/.ssh
chown -R standup ~standup/.ssh
chmod 0400 ~standup/.ssh/authorized_keys

"
# To use source lines with https:// in /etc/apt/sources.list the apt-transport-https package is required. Install it with:
if [ -z "$(which apt-transport-https)" ]; then
apt-get install apt-transport-https -y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
apt-get install apt-transport-https -y
apt-get install apt-transport-https -y
apt-get install lsb-release apt-transport-https -y

Make sure the user has lsb-release so that setting '/etc/apt/sources.list has a valid distribution.

fi

# We need to set up our package repository before you can fetch Tor. First, you need to figure out the name of your distribution:
DEBIAN_VERSION=$(lsb_release -c | awk '{ print $2 }')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DEBIAN_VERSION=$(lsb_release -c | awk '{ print $2 }')
DEBIAN_VERSION=$(lsb_release -c | awk '{ print $2 }')
if [[ -z "$DEBIAN_VERSION" ]]; then
DEBIAN_VERSION="stable"
fi

$MESSAGE_PREFIX downloading & Installing c-lightning
"
# get & compile clightning from github
sudo -u standup git clone https://github.com/ElementsProject/lightning.git ~standup/lightning
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it preferable to compile from source instead of using pre-compiled binaries?

echo "
$MESSAGE_PREFIX getting lnd... depending on your network it can take more than an hour. With good network it usually takes about 5-10 mins.
"
go get -d github.com/lightningnetwork/lnd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it preferable to compile from source instead of using pre-compiled binaries?

@ChristopherA
Copy link
Contributor

@shannona is your review at #15 now resolved?

apt-get install nodejs -y

# get esplora & set electrs api url
sudo -u standup git clone https://github.com/Blockstream/esplora "$ESPLORA_REPO"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to change this repo to link to the new esplora fork at BlockchainCommons/esplora

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants