From d67b14bf4c0beaf23b5170b0f985418f21aa6b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Lavayssi=C3=A8re?= Date: Sat, 30 May 2020 02:52:40 +0200 Subject: [PATCH] Custom scripts, web terminal, welcome message --- README.md | 5 ++-- assets/.bitcoin/bitcoin.conf | 3 +- assets/.cryptotux/scripts/clean.sh | 9 ++++-- assets/.cryptotux/scripts/libra.sh | 14 ++++++++++ assets/.cryptotux/scripts/lightning.sh | 14 ++++++++++ assets/.cryptotux/scripts/tendermint.sh | 12 ++++++++ assets/.cryptotux/scripts/tezos.sh | 16 +++++++++++ assets/.cryptotux/scripts/ttyd.sh | 2 ++ assets/.cryptotux/scripts/update.sh | 6 ++-- assets/.cryptotux/scripts/versions.sh | 6 ++-- assets/.cryptotux/welcome.txt | 15 ++++++++++ changelog.md | 5 +++- install-server.sh | 37 +++++++++++++++++++++---- 13 files changed, 128 insertions(+), 16 deletions(-) create mode 100644 assets/.cryptotux/scripts/libra.sh create mode 100644 assets/.cryptotux/scripts/lightning.sh create mode 100644 assets/.cryptotux/scripts/tendermint.sh create mode 100644 assets/.cryptotux/scripts/tezos.sh create mode 100644 assets/.cryptotux/scripts/ttyd.sh create mode 100644 assets/.cryptotux/welcome.txt diff --git a/README.md b/README.md index 487fa00..153cb3f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Cryptotux is a Linux image preconfigured with tools for crypto development and education. -Cryptotux is currently supplied as .ova images that can be directly imported into Virtualbox (6.X+). +Cryptotux is currently supplied as .ova images that can be directly imported into Virtualbox (6.X+) and VMWare. It is particularly suited for workshops. Username is *bobby*, password is *bricodeur*. ![screenshot](screenshot.png) @@ -24,7 +24,8 @@ To launch only nodes or tooling you can use the server version. * Install [virtualbox](https://virtualbox.org) * Download the latest "Server image" on [cryptotux.org](https://cryptotux.org) * Click on the file or on "↶ import appliance" in virtualbox -* Connect via ssh `ssh bobby@192.168.33.10 ` (add `-o IdentitiesOnly=yes` if you have many keys) + * Connect via ssh `ssh bobby@192.168.33.10 ` (add `-o IdentitiesOnly=yes` if you have many keys) + * Or open a browser at http://192.168.33.10:7681/ For ease you can also sync a local folder, let's call it 'remote', and the internal user folder of the machine with `sshfs -o IdentitiesOnly=yes bobby@192.168.33.10:/home/bobby ~/remote` diff --git a/assets/.bitcoin/bitcoin.conf b/assets/.bitcoin/bitcoin.conf index f14d175..a530985 100644 --- a/assets/.bitcoin/bitcoin.conf +++ b/assets/.bitcoin/bitcoin.conf @@ -13,4 +13,5 @@ rpcuser=bobby rpcpassword=bricodeur rpcallowip=127.0.0.1 - +zmqpubrawblock=tcp://127.0.0.1:28332 +zmqpubrawtx=tcp://127.0.0.1:28333 \ No newline at end of file diff --git a/assets/.cryptotux/scripts/clean.sh b/assets/.cryptotux/scripts/clean.sh index 4a9f968..f6ae2d0 100644 --- a/assets/.cryptotux/scripts/clean.sh +++ b/assets/.cryptotux/scripts/clean.sh @@ -4,12 +4,17 @@ echo ">> Warning : Script designed for light image release, might be harsh for u sudo apt-get autoclean -y; sudo apt-get -y clean; sudo apt-get -y --purge autoremove; -bleachbit -c --preset +# bleachbit -c --preset rm -rf ~/.cache/thumbnails/* sudo rm -rf /var/log/* sudo rm -rf /home/*/.local/share/Trash/* sudo rm -rf /root/.local/share/Trash/* +sudo find /tmp -type f -atime +1 -delete + dd if=/dev/zero of=/var/tmp/bigemptyfile bs=4096k rm /var/tmp/bigemptyfile + +rm .cryptotux/greeted rm ~/.bash_history -history -c + +echo ">>> Cleaning done <<<" \ No newline at end of file diff --git a/assets/.cryptotux/scripts/libra.sh b/assets/.cryptotux/scripts/libra.sh new file mode 100644 index 0000000..e8e89df --- /dev/null +++ b/assets/.cryptotux/scripts/libra.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +mkdir ~/Projects/ +cd ~/Projects/ +git clone https://github.com/libra/libra.git +cd libra +git checkout testnet +yes | ./scripts/dev_setup.sh +./scripts/cli/start_cli_testnet.sh +libraAlias="alias libra=~/Projects/libra//scripts/cli/start_cli_testnet.sh" +$libraAlias +echo $libraAlias >> ~/.bashrc +echo -e '\033[1mLibra installed\033[0m' +libra diff --git a/assets/.cryptotux/scripts/lightning.sh b/assets/.cryptotux/scripts/lightning.sh new file mode 100644 index 0000000..b2a4413 --- /dev/null +++ b/assets/.cryptotux/scripts/lightning.sh @@ -0,0 +1,14 @@ +#!/bin/bash +mkdir -p ~/Projects/ +cd ~/Projects/ +git clone https://github.com/bitcoin/bitcoin.git Bitcoin + +go get -u github.com/golang/dep/cmd/dep +go get -d github.com/lightningnetwork/lnd +cd $GOPATH/src/github.com/lightningnetwork/lnd +make && make install +make check +# TODO add better configuration and walktrough +echo -e '\033[1mBitcoin source and Lightning node installed\033[0m' +echo -e 'launch \033[1mbitcoind \033[0min one terminal and in another one' +echo -e '\033[1mlnd --bitcoin.active --bitcoin.testnet --debuglevel=debug --bitcoin.node=bitcoind --bitcoind.rpcuser=bobby --bitcoind.rpcpass=bricodeur --bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332 --bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333\033[0m' \ No newline at end of file diff --git a/assets/.cryptotux/scripts/tendermint.sh b/assets/.cryptotux/scripts/tendermint.sh new file mode 100644 index 0000000..fa7c88f --- /dev/null +++ b/assets/.cryptotux/scripts/tendermint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +echo export GO111MODULE=on >> ~/.bash_profile +mkdir -p $GOPATH/src/github.com/tendermint +cd $GOPATH/src/github.com/tendermint +git clone https://github.com/tendermint/tendermint.git +cd tendermint +make tools +make install +echo -e '\033[1mTendermint is ready to be used.\033[0m' +echo "Version : $(tendermint version)" + diff --git a/assets/.cryptotux/scripts/tezos.sh b/assets/.cryptotux/scripts/tezos.sh new file mode 100644 index 0000000..7b0a4f8 --- /dev/null +++ b/assets/.cryptotux/scripts/tezos.sh @@ -0,0 +1,16 @@ +#!/bin/bash +tezosHome="~/Projects/Tezos" +mkdir -p $tezosHome +cd $tezosHome +wget -O carthagenet.sh https://gitlab.com/tezos/tezos/raw/latest-release/scripts/tezos-docker-manager.sh +chmod +x carthagenet.sh +tezosAlias="alias tezos=$tezosHome/carthagenet.sh" +$tezosAlias +echo $tezosAlias >> ~/.bashrc +tezos start +cd +echo -e '\033[1mNode is launched and syncing to Tezos testnet \e[92mCarthagenet\e[39m \033[0m' +echo "Next steps:" +echo "- Claim some testnest tezzies on https://faucet.tzalpha.net/" +echo -e "- \033[1mtezos client\033[0m to connect to the node (tezos-client in the documentation)" +echo -e "- \033[1mtezos node stop \033[0mto stop the node" \ No newline at end of file diff --git a/assets/.cryptotux/scripts/ttyd.sh b/assets/.cryptotux/scripts/ttyd.sh new file mode 100644 index 0000000..fbe5d69 --- /dev/null +++ b/assets/.cryptotux/scripts/ttyd.sh @@ -0,0 +1,2 @@ +#!/bin/bash +/home/bobby/.cryptotux/ diff --git a/assets/.cryptotux/scripts/update.sh b/assets/.cryptotux/scripts/update.sh index f9bb755..caefc1b 100644 --- a/assets/.cryptotux/scripts/update.sh +++ b/assets/.cryptotux/scripts/update.sh @@ -8,8 +8,8 @@ npm update -g echo ">> Update local git repositories" cd /home/bobby/Tutorials for i in */.git; do ( echo "> $i ";cd $i/..; git pull;); done; -cd ~/Cryptotux-respository -git pull +cd ~/Projects/ +for i in */.git; do ( echo "> $i ";cd $i/..; git pull;); done; # TODO : update tooling based on the new versions in cryptotux cd -echo ">> Update done " +echo ">>> Update done <<<" diff --git a/assets/.cryptotux/scripts/versions.sh b/assets/.cryptotux/scripts/versions.sh index 226ebfc..53c159b 100644 --- a/assets/.cryptotux/scripts/versions.sh +++ b/assets/.cryptotux/scripts/versions.sh @@ -7,6 +7,7 @@ echo ${vv#"Description:"} echo -e "\n Languages" # python -V # deprecated +gcc --version | head -n 1 python3 -V go version rustc --version @@ -16,6 +17,7 @@ echo -e "\n Tooling" docker --version echo "geth" $(geth version | sed -n 2p) bitcoind --version | head -n 1 +# Optionnal installs +[ -x "$(command -v tendermint)" ] && tendermint version -echo ">> done <<" - +echo ">>> done <<<" \ No newline at end of file diff --git a/assets/.cryptotux/welcome.txt b/assets/.cryptotux/welcome.txt new file mode 100644 index 0000000..4d4bac8 --- /dev/null +++ b/assets/.cryptotux/welcome.txt @@ -0,0 +1,15 @@ + + +As this is your first run, let me introduce available commands: + Blockchain nodes: bitcoind (locally), bitcoin-cli, geth + Programming languages: go, node, rust, gcc + Text editors: vim, nano, micro + +General commands: + cryptotux-update: update everything + cryptotux-desktop: install a light desktop environment + cryptotux-versions: display the current version of the main toolings + cryptotux-help: display this help + +To install specific blockchains tools and nodes + cryptotux-lightning,cryptotux-tendermint, cryptotux-tezos, cryptotux-libra... diff --git a/changelog.md b/changelog.md index bc76ab8..65a4731 100644 --- a/changelog.md +++ b/changelog.md @@ -1,11 +1,14 @@ # Changelog -## 0.6.1 > TBR +## 0.6.1 > 30 May 2020 #### Users - [server] Addition of micro, a command line text editor +- [server] Added web terminal - [desktop] Default mimetypes for convenience +- [server] Welcome message with available commands #### Internal - install-server.sh can now be safely executed on a server independently of Vagrant - Better script portability +- Additional scripts to install lightning, tendermint, Libra and Tezos (carthagenet) ## 0.6.0 > 27 May 2020 #### Users - Extended to 40GB max sized harddrive. Allows testnets launch diff --git a/install-server.sh b/install-server.sh index 3973a00..f429570 100644 --- a/install-server.sh +++ b/install-server.sh @@ -41,8 +41,7 @@ source ~/.bashrc # snap install bitcoin # Direct download bitcoinCoreVersion=0.19.1 -if [-e "/vagrant/dataShare/bitcoin-$bitcoinCoreVersion-x86_64-linux-gnu.tar.gz"] -then +if [[ -e "/vagrant/dataShare/bitcoin-$bitcoinCoreVersion-x86_64-linux-gnu.tar.gz" ]] ; then # During development, import from a folder "dataShare" if available cp "/vagrant/dataShare/bitcoin-$bitcoinCoreVersion-x86_64-linux-gnu.tar.gz" . else @@ -120,6 +119,25 @@ sudo install -m 0755 -o root -g root -t /usr/local/bin micro-$microVersion/micro rm -rf micro-$microVersion/ rm "micro-$microVersion-linux64-static.tar.gz" +## Web terminal +ttydVersion=1.6.0 +wget https://github.com/tsl0922/ttyd/releases/download/$ttydVersion/ttyd_linux.x86_64 -O ttyd +chmod +x ttyd +sudo mv ttyd /usr/local/bin +sudo sh -c 'echo "[Unit] +Description=Web based command line + +[Service] +User=bobby +ExecStart=/usr/local/bin/ttyd -p 3310 -u bobby bash +WorkingDirectory=/home/bobby/ + +[Install] +WantedBy=multi-user.target" > /etc/systemd/system/ttyd.service' +sudo systemctl daemon-reload +sudo systemctl enable ttyd +sudo service ttyd start + ## Tutorials # Suggestions welcomed cd @@ -137,9 +155,10 @@ git clone https://github.com/cosmos/sdk-application-tutorial.git Cosmos-sdk-tuto ## Configuration Preferences cd # Retrieve configuration files from this repo -git clone https://github.com/cryptotuxorg/cryptotux ~/Cryptotux-repository +mkdir ~/Projects/ +git clone https://github.com/cryptotuxorg/cryptotux ~/Projects/Cryptotux # Use Vagrant shared folder if available for the latest version or the github imported version -[ -d "/vagrant/assets" ] && cryptopath="/vagrant" || cryptopath="/home/$USER/Cryptotux-repository" +[ -d "/vagrant/assets" ] && cryptopath="/vagrant" || cryptopath="/home/$USER/Projects/Cryptotux" cp -R "${cryptopath}/assets/.bitcoin" . cp -R "${cryptopath}/assets/.cryptotux" . cp "${cryptopath}/install-desktop.sh" .cryptotux/scripts/ @@ -152,6 +171,13 @@ echo ' alias cryptotux-update="source ~/.cryptotux/scripts/update.sh" alias cryptotux-clean="source ~/.cryptotux/scripts/clean.sh" alias cryptotux-versions="source ~/.cryptotux/scripts/versions.sh" +alias cryptotux-help="cat .cryptotux/welcome.txt" + +alias cryptotux-tezos="source ~/.cryptotux/scripts/tezos.sh" +alias cryptotux-libra="source ~/.cryptotux/scripts/libra.sh" +alias cryptotux-tendermint="source ~/.cryptotux/scripts/tendermint.sh" +alias cryptotux-lightning="source ~/.cryptotux/scripts/lightning.sh" + alias cryptotux-desktop="bash ~/.cryptotux/scripts/install-desktop.sh"' >> ~/.bashrc #Nice command line help for beginners @@ -160,8 +186,9 @@ echo 'alias tldr="tldr -t ocean"' >> ~/.bashrc /home/bobby/.npm-global/bin/tldr update sudo apt-get install -y cowsay -echo '(echo "Welcome to Cryptotux !"; )| cowsay -f turtle ' >> ~/.bashrc +echo '(echo "Welcome to Cryptotux !"; )| /usr/games/cowsay -f turtle ' >> ~/.bashrc sed -i -e 's/#force_color_prompt/force_color_prompt/g' ~/.bashrc +echo '[ ! -e ~/.cryptotux/greeted ] && cryptotux-help && touch ~/.cryptotux/greeted' >> ~/.bashrc ## Optimization attempt (potential security and dependencies issues) # Check if it is a local build, otherwise do nothign