diff --git a/Makefile b/Makefile index 375ac0a7..ec46cd96 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,11 @@ setup_new_raspi4: start_file_server download_base_images rootfs @cp -f setup/setup_device.sh out/setup_device.sh @/bin/bash scripts/setup_new_raspi4.sh +.PHONY: setup_new_debian +setup_new_debian: start_file_server download_base_images rootfs + @cp -f setup/setup_device.sh out/setup_device.sh + @/bin/bash scripts/setup_new_debian.sh + # Clone repo to get release tools release.sh: diff --git a/make_rootfs.sh b/make_rootfs.sh index 9678b421..8bf2275b 100755 --- a/make_rootfs.sh +++ b/make_rootfs.sh @@ -5,6 +5,7 @@ rm -rf out/rootfs* mkdir -p out/rootfs_rock64/ mkdir -p out/rootfs_raspi3/ mkdir -p out/rootfs_raspi4/ +mkdir -p out/rootfs_debian/ ### Make rock64 rootfs ### @@ -26,3 +27,10 @@ cp -rf rootfs/raspi4/* out/rootfs_raspi4/ cp -f CHANGELOG out/rootfs_raspi4/usr/share/mynode/changelog rm -f out/mynode_rootfs_raspi4.tar.gz tar -zcvf out/mynode_rootfs_raspi4.tar.gz ./out/rootfs_raspi4/* + +### Make debian rootfs ### +cp -rf rootfs/standard/* out/rootfs_debian/ +cp -rf rootfs/debian/* out/rootfs_debian/ +cp -f CHANGELOG out/rootfs_debian/usr/share/mynode/changelog +rm -f out/mynode_rootfs_debian.tar.gz +tar -zcvf out/mynode_rootfs_debian.tar.gz ./out/rootfs_debian/* diff --git a/rootfs/debian/usr/bin/electrs b/rootfs/debian/usr/bin/electrs new file mode 100755 index 00000000..a8fcff7b Binary files /dev/null and b/rootfs/debian/usr/bin/electrs differ diff --git a/rootfs/debian/usr/share/mynode/bitcoin.conf b/rootfs/debian/usr/share/mynode/bitcoin.conf new file mode 100644 index 00000000..3e58868a --- /dev/null +++ b/rootfs/debian/usr/share/mynode/bitcoin.conf @@ -0,0 +1,38 @@ +# bitcoind configuration +# /home/bitcoin/.bitcoin/bitcoin.conf + +# remove the following line to enable Bitcoin mainnet +#testnet=1 + +# Bitcoind options +server=1 +daemon=1 + +# Needed for BTC-RPC-Explorer +txindex=1 + +# Connection settings +#rpcuser=mynode +# This password was randomly generated by your device. Changing it may cause problems. +#rpcpassword=bolt + +rpcauth=mynode:7b7e11c032ddd3fc3835e4e463afd305$6c6a32bbd08cb1b67b5ea89b66865c5ca2bf6fd8a91a19d6a4d58157fe0882b4 + +rpcport=8332 +rpcbind=127.0.0.1 +rpcallowip=127.0.0.1 + +zmqpubrawblock=tcp://127.0.0.1:28332 +zmqpubrawtx=tcp://127.0.0.1:28333 + +# myNode Optimizations +dbcache=1000 +maxorphantx=10 +maxmempool=200 +maxconnections=40 +maxuploadtarget=1000 + +# Tor config +proxy=127.0.0.1:9050 +listen=1 +bind=127.0.0.1 \ No newline at end of file diff --git a/rootfs/debian/usr/share/mynode/mynode_config_debian.sh b/rootfs/debian/usr/share/mynode/mynode_config_debian.sh new file mode 100644 index 00000000..69acdd56 --- /dev/null +++ b/rootfs/debian/usr/share/mynode/mynode_config_debian.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Device info +# Now calculated in main config file... + +# Other Info +UPGRADE_DOWNLOAD_URL="http://www.mynodebtc.com/device_api/download_latest_standard.php?type=${DEVICE_TYPE}&product_key=${PRODUCT_KEY}&serial=${SERIAL_NUM}" +UPGRADE_DOWNLOAD_SIGNATURE_URL="http://www.mynodebtc.com/device/hashes/mynode_release_latest_${DEVICE_TYPE}.sha256" \ No newline at end of file diff --git a/rootfs/debian/var/www/mynode/config.py b/rootfs/debian/var/www/mynode/config.py new file mode 100644 index 00000000..6e4d8422 --- /dev/null +++ b/rootfs/debian/var/www/mynode/config.py @@ -0,0 +1,30 @@ + +CONFIG = {} + +# Device Config +CONFIG["device_type"] = "debian" + +# Enabled Features +CONFIG["rtl_enabled"] = True +CONFIG["lndhub_enabled"] = True +CONFIG["electrs_enabled"] = True +CONFIG["explorer_enabled"] = True +CONFIG["btcrpcexplorer_enabled"] = True + +# myNode variables +LATEST_VERSION_URL = "http://www.mynodebtc.com/device/latest_version" +CHECKIN_URL = "http://www.mynodebtc.com/device_api/check_in.php" + +# Bitcoin Variables +BITCOIN_ENV_FILE = "/mnt/hdd/mynode/bitcoin/env" +BITCOIN_SYNCED_FILE = "/mnt/hdd/mynode/.mynode_bitcoind_synced" + +# LND Variables +LND_WALLET_FILE = "/mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/wallet.db" +LND_DATA_FOLDER = "/mnt/hdd/mynode/lnd/data/" + +# Other Variables +ELECTRS_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_electrs_enabled" +LNDHUB_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_lndhub_enabled" +BTCRPCEXPLORER_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_btcrpceplorer_enabled" +VPN_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_vpn_enabled" diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index 0c5245c5..98d2b287 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -26,6 +26,9 @@ uname -a | grep aarch64 if [ $? = 0 ]; then ARCH="aarch64-linux-gnu" fi +if [ $IS_X86 = 1 ]; then + ARCH="x86_64-linux-gnu" +fi BTC_UPGRADE_URL=https://bitcoin.org/bin/bitcoin-core-0.18.1/bitcoin-0.18.1-$ARCH.tar.gz BTC_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.btc_url CURRENT="" @@ -46,7 +49,11 @@ if [ "$CURRENT" != "$BTC_UPGRADE_URL" ]; then fi # Upgrade LND -LND_UPGRADE_URL=https://github.com/lightningnetwork/lnd/releases/download/v0.7.1-beta/lnd-linux-armv7-v0.7.1-beta.tar.gz +LNDARCH="lnd-linux-armv7" +if [ $IS_X86 = 1 ]; then + LNDARCH="lnd-linux-amd64" +fi +LND_UPGRADE_URL=https://github.com/lightningnetwork/lnd/releases/download/v0.7.1-beta/$LNDARCH-v0.7.1-beta.tar.gz LND_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.lnd_url CURRENT="" if [ -f $LND_UPGRADE_URL_FILE ]; then diff --git a/rootfs/standard/usr/share/mynode/mynode_config.sh b/rootfs/standard/usr/share/mynode/mynode_config.sh index 5c275484..e80e6b96 100644 --- a/rootfs/standard/usr/share/mynode/mynode_config.sh +++ b/rootfs/standard/usr/share/mynode/mynode_config.sh @@ -5,11 +5,19 @@ IS_ROCK64=0 IS_RASPI=0 IS_RASPI3=0 IS_RASPI4=0 +IS_X86=0 DEVICE_TYPE="unknown" uname -a | grep aarch64 && IS_ROCK64=1 || IS_RASPI=1 if [ $IS_RASPI -eq 1 ]; then cat /proc/cpuinfo | grep 03111 && IS_RASPI4=1 || IS_RASPI3=1 fi +uname -a | grep amd64 && IS_X86=1 || true +if [ $IS_X86 -eq 1 ]; then + IS_RASPI=0 + IS_ROCK64=0 + IS_RASPI3=0 + IS_RASPI4=0 +fi if [ $IS_RASPI3 -eq 1 ]; then DEVICE_TYPE="raspi3" @@ -17,6 +25,8 @@ elif [ $IS_RASPI4 -eq 1 ]; then DEVICE_TYPE="raspi4" elif [ $IS_ROCK64 -eq 1 ]; then DEVICE_TYPE="rock64" +elif [ $IS_X86 -eq 1 ]; then + DEVICE_TYPE="debian" fi @@ -59,4 +69,7 @@ UPGRADE_PUBKEY_URL="https://raw.githubusercontent.com/mynodebtc/pubkey/master/my # Update settings for other devices if [ -f /usr/share/mynode/mynode_config_raspi.sh ]; then source /usr/share/mynode/mynode_config_raspi.sh +fi +if [ -f /usr/share/mynode/mynode_config_debian.sh ]; then + source /usr/share/mynode/mynode_config_debian.sh fi \ No newline at end of file diff --git a/scripts/setup_new_debian.sh b/scripts/setup_new_debian.sh new file mode 100755 index 00000000..117d770c --- /dev/null +++ b/scripts/setup_new_debian.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +LOCAL_IP=$(python ./scripts/get_local_ip.py) + +echo "" +echo "Finished updating rootfs and other files!" +echo "" + +clear +echo "Step 1: " +echo " Install your a Debian Image:" +echo " Setup image for use with myNode:" +echo " See manual instructions in setup/setup_base_image_debian.txt" +echo "" +echo "Press a key when complete..." +read -n 1 + +clear +echo "Step 2: " +echo " Reboot Device" +echo "" +echo "Press a key when complete..." +read -n 1 + +clear +echo "Step 3: " +echo " Login to device with username 'admin' and password 'bolt'" +echo " Run the following commands. Use bolt at password prompts." +echo " wget http://${LOCAL_IP}:8000/setup_device.sh -O setup_device.sh" +echo " chmod +x setup_device.sh" +echo " sudo ./setup_device.sh ${LOCAL_IP}" +echo "" +echo "Press a key when complete..." +read -n 1 + +clear +echo "Step 4:" +echo " Reboot your device." +echo "" +echo "Press a key when complete..." +read -n 1 + +clear +echo "Congratulations! Your device is now ready!" +echo " Access it via a web browser at http://mynode.local/ or http:///" +echo " Access it via SSH using the default credentials: admin / bolt" +echo " You should change your password on the settings page in the web GUI" +echo "" \ No newline at end of file diff --git a/setup/setup_base_image_debian.txt b/setup/setup_base_image_debian.txt new file mode 100644 index 00000000..b1fc6cac --- /dev/null +++ b/setup/setup_base_image_debian.txt @@ -0,0 +1,46 @@ +### +### Setup Base OS +### + +# Install Debian 10.1.0 Net-install via CD +# - Graphical Install +# - English, US, American English +# - Hostname: myNode +# - Domain Name: +# - Root Password: bolt +# - Full Name: myNode +# - Username: mynode +# - Password: bolt +# - Timezone: Central +# - Partition: Guided Use Entire Disk, Continue, Continue, Continue, Yes +# - CDs and Packages: No, Next, Next +# - Software Selection: No GUI, No Print Server, Add SSH Server +# - Install Grub: Yes, /dev/sda +# - Install Complete: Continue + +# Login as root / bolt + +# Install basic Software +apt-get -y install sudo +useradd -p $(openssl passwd -1 bolt) -m -s /bin/bash admin +adduser admin sudo + +# Delete mynode user +deluser mynode +rm -rf /home/mynode + +# Login as admin / bolt + +# Delete root password +sudo passwd -d root + +# Update packages +sudo apt-get update +sudo apt-get -y upgrade + +# Sync +sync + +###################### +### MAKE IMAGE NOW ### +###################### \ No newline at end of file diff --git a/setup/setup_base_image_other.txt b/setup/setup_base_image_other.txt index 0ac6439f..810b89c4 100644 --- a/setup/setup_base_image_other.txt +++ b/setup/setup_base_image_other.txt @@ -6,7 +6,7 @@ # Set hostname hostname myNode - + # Add admin user sudo useradd -p $(openssl passwd -1 bolt) -m -s /bin/bash admin diff --git a/setup/setup_base_image_rock64.txt b/setup/setup_base_image_rock64.txt index 43814a3a..91a7e860 100644 --- a/setup/setup_base_image_rock64.txt +++ b/setup/setup_base_image_rock64.txt @@ -25,6 +25,18 @@ sudo systemctl restart cpufrequtils sudo apt-get update sudo apt-get -y upgrade +# Install some necessary tools +apt-get -y install network-manager + +# Regenerate MAC Address for Rock64 +. /usr/lib/armbian/armbian-common +CONNECTION="$(nmcli -f UUID,ACTIVE,DEVICE,TYPE connection show --active | tail -n1)" +UUID=$(awk -F" " '/ethernet/ {print $1}' <<< "${CONNECTION}") +get_random_mac +nmcli connection modify $UUID ethernet.cloned-mac-address $MACADDR +nmcli connection modify $UUID -ethernet.mac-address "" + + # Sync sync diff --git a/setup/setup_device.sh b/setup/setup_device.sh index c2137d1a..9a9dd15e 100755 --- a/setup/setup_device.sh +++ b/setup/setup_device.sh @@ -18,10 +18,17 @@ SERVER_IP=$1 IS_ROCK64=0 IS_RASPI3=0 IS_RASPI4=0 +IS_X86=0 uname -a | grep aarch64 && IS_ROCK64=1 || IS_RASPI3=1 if [ $IS_RASPI3 -eq 1 ]; then cat /proc/cpuinfo | grep 03111 && IS_RASPI4=1 && IS_RASPI3=0 || IS_RASPI3=1 fi +uname -a | grep amd64 && IS_X86=1 || true +if [ $IS_X86 -eq 1 ]; then + IS_ROCK64=0 + IS_RASPI3=0 + IS_RASPI4=0 +fi # Make sure FS is expanded for Rock64 if [ $IS_ROCK64 = 1 ]; then @@ -45,7 +52,7 @@ apt-get -y install clang hitch zlib1g-dev libffi-dev file toilet ncdu apt-get -y install toilet-fonts avahi-daemon figlet libsecp256k1-dev apt-get -y install inotify-tools libssl-dev tor tmux screen apt-get -y install python-grpcio python3-grpcio -apt-get -y install pv sysstat network-manager +apt-get -y install pv sysstat network-manager rsync # Install other things without recommendation @@ -120,6 +127,9 @@ ARCH="arm-linux-gnueabihf" if [ $IS_ROCK64 = 1 ]; then ARCH="aarch64-linux-gnu" fi +if [ $IS_X86 = 1 ]; then + ARCH="x86_64-linux-gnu" +fi BTC_UPGRADE_URL=https://bitcoin.org/bin/bitcoin-core-0.18.1/bitcoin-0.18.1-$ARCH.tar.gz BTC_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.btc_url CURRENT="" @@ -135,10 +145,13 @@ if [ "$CURRENT" != "$BTC_UPGRADE_URL" ]; then tar -xvf bitcoin.tar.gz mv bitcoin-* bitcoin install -m 0755 -o root -g root -t /usr/local/bin bitcoin/bin/* - - sudo -u bitcoin ln -s /mnt/hdd/mynode/bitcoin /home/bitcoin/.bitcoin - sudo -u bitcoin ln -s /mnt/hdd/mynode/lnd /home/bitcoin/.lnd - mkdir /home/admin/.bitcoin + if [ ! -L /home/bitcoin/.bitcoin ]; then + sudo -u bitcoin ln -s /mnt/hdd/mynode/bitcoin /home/bitcoin/.bitcoin + fi + if [ ! -L /home/bitcoin/.lnd ]; then + sudo -u bitcoin ln -s /mnt/hdd/mynode/lnd /home/bitcoin/.lnd + fi + mkdir -p /home/admin/.bitcoin mkdir -p /home/bitcoin/.mynode/ chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $BTC_UPGRADE_URL > $BTC_UPGRADE_URL_FILE @@ -146,7 +159,11 @@ fi cd ~ # Install Lightning -LND_UPGRADE_URL=https://github.com/lightningnetwork/lnd/releases/download/v0.7.1-beta/lnd-linux-armv7-v0.7.1-beta.tar.gz +LNDARCH="lnd-linux-armv7" +if [ $IS_X86 = 1 ]; then + LNDARCH="lnd-linux-amd64" +fi +LND_UPGRADE_URL=https://github.com/lightningnetwork/lnd/releases/download/v0.7.1-beta/$LNDARCH-v0.7.1-beta.tar.gz LND_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.lnd_url CURRENT="" if [ -f $LND_UPGRADE_URL_FILE ]; then @@ -161,7 +178,7 @@ if [ "$CURRENT" != "$LND_UPGRADE_URL" ]; then tar -xzf lnd.tar.gz mv lnd-* lnd install -m 0755 -o root -g root -t /usr/local/bin lnd/* - ln -s /bin/ip /usr/bin/ip + ln -s /bin/ip /usr/bin/ip || true mkdir -p /home/bitcoin/.mynode/ chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ @@ -266,7 +283,11 @@ fi # Install LND Connect -LNDCONNECT_UPGRADE_URL=https://github.com/LN-Zap/lndconnect/releases/download/v0.1.0/lndconnect-linux-armv7-v0.1.0.tar.gz +LNDCONNECTARCH="lndconnect-linux-armv7" +if [ $IS_X86 = 1 ]; then + LNDCONNECTARCH="lndconnect-linux-amd64" +fi +LNDCONNECT_UPGRADE_URL=https://github.com/LN-Zap/lndconnect/releases/download/v0.1.0/$LNDCONNECTARCH-v0.1.0.tar.gz LNDCONNECT_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.lndconnect_url CURRENT="" if [ -f $LNDCONNECT_UPGRADE_URL_FILE ]; then @@ -302,13 +323,19 @@ elif [ $IS_RASPI3 = 1 ]; then TARBALL="mynode_rootfs_raspi3.tar.gz" elif [ $IS_RASPI4 = 1 ]; then TARBALL="mynode_rootfs_raspi4.tar.gz" +elif [ $IS_X86 = 1 ]; then + TARBALL="mynode_rootfs_debian.tar.gz" fi wget http://${SERVER_IP}:8000/${TARBALL} -O /tmp/rootfs.tar.gz tar -xvf /tmp/rootfs.tar.gz -C /tmp/upgrade/ # Install files -cp -rf /tmp/upgrade/out/rootfs_*/* / +if [ $IS_X86 = 1 ]; then + rsync -r -K /tmp/upgrade/out/rootfs_*/* / +else + cp -rf /tmp/upgrade/out/rootfs_*/* / +fi sleep 1 sync sleep 1