diff --git a/rootfs/standard/etc/systemd/system/ckbunker.service b/rootfs/standard/etc/systemd/system/ckbunker.service new file mode 100644 index 00000000..32718c9a --- /dev/null +++ b/rootfs/standard/etc/systemd/system/ckbunker.service @@ -0,0 +1,26 @@ +# CKBunker service +# /etc/systemd/system/ckbunker.service + +[Unit] +Description=CKBunker +Wants=bitcoind.service +After=bitcoind.service + +[Service] +ExecStartPre=/usr/bin/is_not_shutting_down.sh +ExecStartPre=/usr/bin/wait_on_bitcoin.sh +WorkingDirectory=/opt/mynode/ckbunker +ExecStart=/bin/bash -c 'source env/bin/activate && ck-bunker run -c /mnt/hdd/mynode/ckbunker/settings.yaml' + +User=bitcoin +Group=bitcoin +Type=simple +TimeoutSec=120 +Restart=always +RestartSec=30 +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=specter + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/rootfs/standard/etc/systemd/system/sphinx-relay.service b/rootfs/standard/etc/systemd/system/sphinx-relay.service new file mode 100644 index 00000000..70db3519 --- /dev/null +++ b/rootfs/standard/etc/systemd/system/sphinx-relay.service @@ -0,0 +1,27 @@ +# sphinx-relay service +# /etc/systemd/system/sphinx-relay.service + +[Unit] +Description=Sphinx Relay +Wants=lnd.service +After=lnd.service + +[Service] +ExecStartPre=/usr/bin/is_not_shutting_down.sh +ExecStartPre=/usr/bin/wait_on_lnd.sh +WorkingDirectory=/opt/mynode/sphinx-relay +ExecStart=npm run prod + +User=bitcoin +Group=bitcoin +Type=simple +KillMode=control-group +TimeoutSec=240 +Restart=always +RestartSec=60 +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=sphinx-relay + +[Install] +WantedBy=multi-user.target diff --git a/rootfs/standard/usr/bin/mynode_firewall.sh b/rootfs/standard/usr/bin/mynode_firewall.sh index bb079b6d..f29b51cc 100755 --- a/rootfs/standard/usr/bin/mynode_firewall.sh +++ b/rootfs/standard/usr/bin/mynode_firewall.sh @@ -46,8 +46,11 @@ ufw allow 5000 comment 'allow LNBits' ufw allow 5001 comment 'allow LNBits HTTPS' ufw allow 5353 comment 'allow Avahi' ufw allow 8899 comment 'allow Whirlpool' +ufw allow 9823 comment 'allow CKBunker' +ufw allow 9824 comment 'allow CKBunker HTTPS' ufw allow 50001 comment 'allow Electrum Server' ufw allow 50002 comment 'allow Electrum Server' +ufw allow 53001 comment 'allow Sphinx Relay' ufw allow 56881 comment 'allow myNode QuickSync' ufw allow 51413 comment 'allow myNode QuickSync' ufw allow 6771 comment 'allow myNode QuickSync (LPD)' diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index 7b0b10e0..9064f830 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -94,7 +94,7 @@ $TORIFY apt-get -y install libatlas-base-dev libffi-dev libssl-dev glances pytho $TORIFY apt-get -y -qq install apt-transport-https ca-certificates $TORIFY apt-get -y install libgmp-dev automake libtool libltdl-dev libltdl7 $TORIFY apt-get -y install xorg chromium openbox lightdm openjdk-11-jre libevent-dev ncurses-dev -$TORIFY apt-get -y install libudev-dev libusb-1.0-0-dev python3-venv gunicorn libsqlite3-dev +$TORIFY apt-get -y install libudev-dev libusb-1.0-0-dev python3-venv gunicorn sqlite3 libsqlite3-dev $TORIFY apt-get -y install torsocks python3-requests libsystemd-dev # Make sure some software is removed @@ -670,6 +670,54 @@ if [ ! -f /usr/bin/ngrok ]; then fi +# Upgrade CKbunker +CKBUNKER_UPGRADE_URL=https://github.com/Coldcard/ckbunker/archive/$CKBUNKER_VERSION.tar.gz +CURRENT="" +if [ -f $CKBUNKER_VERSION_FILE ]; then + CURRENT=$(cat $CKBUNKER_VERSION_FILE) +fi +if [ "$CURRENT" != "$CKBUNKER_VERSION" ]; then + cd /opt/mynode + sudo -u bitcoin wget $CKBUNKER_UPGRADE_URL -O ckbunker.tar.gz + sudo -u bitcoin tar -xvf ckbunker.tar.gz + sudo -u bitcoin rm ckbunker.tar.gz + sudo -u bitcoin mv ckbunker-* ckbunker + cd ckbunker + + # Make venv + if [ ! -d env ]; then + sudo -u bitcoin python3 -m venv env + fi + source env/bin/activate + pip3 install -r requirements.txt + pip3 install --editable . + deactivate + + echo $CKBUNKER_VERSION > $CKBUNKER_VERSION_FILE +fi + + +# Upgrade Sphinx Relay +SPHINX_RELAY_UPGRADE_URL=https://github.com/stakwork/sphinx-relay/archive/$SPHINX_RELAY_VERSION.tar.gz +CURRENT="" +if [ -f $SPHINX_RELAY_VERSION_FILE ]; then + CURRENT=$(cat $SPHINX_RELAY_VERSION_FILE) +fi +if [ "$CURRENT" != "$SPHINX_RELAY_VERSION" ]; then + cd /opt/mynode + rm -rf sphinx-relay + sudo -u bitcoin wget $SPHINX_RELAY_UPGRADE_URL -O sphinx-relay.tar.gz + sudo -u bitcoin tar -xvf sphinx-relay.tar.gz + sudo -u bitcoin rm sphinx-relay.tar.gz + sudo -u bitcoin mv sphinx-relay-* sphinx-relay + cd sphinx-relay + + sudo -u bitcoin npm install + + echo $SPHINX_RELAY_VERSION > $SPHINX_RELAY_VERSION_FILE +fi + + # Upgrade Tor rm -f /usr/local/bin/tor || true TOR_VERSION=$(tor --version) diff --git a/rootfs/standard/usr/bin/mynode_reinstall_app.sh b/rootfs/standard/usr/bin/mynode_reinstall_app.sh index ed5379c8..d67454af 100755 --- a/rootfs/standard/usr/bin/mynode_reinstall_app.sh +++ b/rootfs/standard/usr/bin/mynode_reinstall_app.sh @@ -55,6 +55,10 @@ elif [ "$APP" = "specter" ]; then rm -f $SPECTER_VERSION_FILE elif [ "$APP" = "thunderhub" ]; then rm -f $THUNDERHUB_VERSION_FILE +elif [ "$APP" = "ckbunker" ]; then + rm -f $CKBUNKER_VERSION_FILE +elif [ "$APP" = "sphinx-relay" ]; then + rm -f $SPHINX_RELAY_VERSION_FILE elif [ "$APP" = "tor" ]; then apt-get remove -y tor apt-get install -y tor diff --git a/rootfs/standard/usr/bin/mynode_startup.sh b/rootfs/standard/usr/bin/mynode_startup.sh index 6fbcdd88..97c854d7 100755 --- a/rootfs/standard/usr/bin/mynode_startup.sh +++ b/rootfs/standard/usr/bin/mynode_startup.sh @@ -77,14 +77,7 @@ fi umount /mnt/hdd || true -# If multiple drives detected, start clone tool -drive_count=0 -drives=$(ls /sys/block/ | egrep "hd.*|vd.*|sd.*|nvme.*") -for d in $drives; do - grep -qs "/dev/$d" /proc/mounts || drive_count=$((drive_count+1)) -done -echo "External Drives Found: $drive_count" -#if [ "$drive_count" -gt 1 ] || [ -f /home/bitcoin/open_clone_tool ]; then +# Clone tool was opened if [ -f /home/bitcoin/open_clone_tool ]; then rm -f /home/bitcoin/open_clone_tool echo "drive_clone" > $MYNODE_STATUS_FILE @@ -98,7 +91,7 @@ fi # Check drive (only if exactly 1 is found) set +e -if [ $IS_X86 = 0 ] && [ "$drive_count" -eq 1 ]; then +if [ $IS_X86 = 0 ]; then touch /tmp/repairing_drive for d in /dev/sd*1 /dev/hd*1 /dev/vd*1 /dev/nvme*p1; do echo "Repairing drive $d ..."; @@ -361,6 +354,35 @@ if [ -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then fi chown -R bitcoin:bitcoin /mnt/hdd/mynode/thunderhub +# Setup CKBunker +CKBUNKER_CONFIG_UPDATE_NUM=1 +if [ ! -f /mnt/hdd/mynode/ckbunker/update_settings_$CKBUNKER_CONFIG_UPDATE_NUM ]; then + cp -f /usr/share/mynode/ckbunker_settings.yaml /mnt/hdd/mynode/ckbunker/settings.yaml + chown -R bitcoin:bitcoin /mnt/hdd/mynode/ckbunker/settings.yaml + + touch /mnt/hdd/mynode/ckbunker/update_settings_$CKBUNKER_CONFIG_UPDATE_NUM +fi + +# Setup Sphinx Relay +SPHINX_RELAY_CONFIG_UPDATE_NUM=1 +if [ ! -f /mnt/hdd/mynode/sphinx-relay/update_settings_$SPHINX_RELAY_CONFIG_UPDATE_NUM ]; then + cp -f /usr/share/mynode/sphinx_app.json /mnt/hdd/mynode/sphinx-relay/app.json + cp -f /usr/share/mynode/sphinx_config.json /mnt/hdd/mynode/sphinx-relay/config.json + chown -R bitcoin:bitcoin /opt/mynode/sphinx-relay/config/* + chown -R bitcoin:bitcoin /mnt/hdd/mynode/sphinx-relay + + touch /mnt/hdd/mynode/sphinx-relay/update_settings_$SPHINX_RELAY_CONFIG_UPDATE_NUM +fi +if [ -d /opt/mynode/sphinx-relay/config ]; then + if [ ! -L /opt/mynode/sphinx-relay/config/app.json ] || [ ! -L /opt/mynode/sphinx-relay/config/config.json ]; then + rm -f /opt/mynode/sphinx-relay/config/app.json + rm -f /opt/mynode/sphinx-relay/config/config.json + sudo -u bitcoin ln -s /mnt/hdd/mynode/sphinx-relay/app.json /opt/mynode/sphinx-relay/config/app.json + sudo -u bitcoin ln -s /mnt/hdd/mynode/sphinx-relay/config.json /opt/mynode/sphinx-relay/config/config.json + chown -R bitcoin:bitcoin /opt/mynode/sphinx-relay/config/* + fi +fi + # Setup udev chown root:root /etc/udev/rules.d/* || true udevadm trigger diff --git a/rootfs/standard/usr/share/mynode/ckbunker_settings.yaml b/rootfs/standard/usr/share/mynode/ckbunker_settings.yaml new file mode 100644 index 00000000..7c4a6334 --- /dev/null +++ b/rootfs/standard/usr/share/mynode/ckbunker_settings.yaml @@ -0,0 +1,15 @@ +ALLOW_REBOOTS: true +DATA_FILES: /mnt/hdd/mynode/ckbunker +EASY_CAPTCHA: false +#EXPLORA: http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion +MASTER_PW: bolt +MAX_IDLE_TIME: 600 +MAX_LOGIN_WAIT_TIME: 300 +PING_RATE: 15 +PLACEHOLDER_KEY: !!binary | + YWJhYmFiYWJhYmFiYWJhYmFiYWJhYmFiYWJhYmFiYWI= +PORT_NUMBER: 9823 +RECONNECT_DELAY: 10 +SIMULATOR_SOCK: /tmp/ckcc-simulator.sock +TORD_PORT: default +TOR_SOCKS: socks5h://127.0.0.1:9150 \ No newline at end of file diff --git a/rootfs/standard/usr/share/mynode/sphinx_app.json b/rootfs/standard/usr/share/mynode/sphinx_app.json new file mode 100644 index 00000000..6c153c70 --- /dev/null +++ b/rootfs/standard/usr/share/mynode/sphinx_app.json @@ -0,0 +1,49 @@ +{ + "development": { + "senza_url": "http://localhost:3000/api/v2", + "macaroon_location": "/Users/evanfeenstra/code/lnd-dev/alice/data/chain/bitcoin/simnet/admin.macaroon", + "tls_location": "/Users/evanfeenstra/Library/Application Support/Lnd/tls.cert", + "node_ip": "127.0.0.1", + "lnd_ip": "127.0.0.1", + "lnd_port": "10001", + "node_http_protocol": "http", + "node_http_port": "3001", + "hub_api_url": "http://lvh.me/api/v1", + "hub_url": "http://lvh.me/ping", + "hub_invite_url": "http://lvh.me/invites", + "hub_check_invite_url": "http://lvh.me/check_invite", + "media_host": "localhost:5000", + "tribes_host": "tribes.sphinx.chat", + "public_url": "", + "connection_string_path": "connection_string.txt", + "ssl": { + "enabled": false, + "save": true, + "port": "80" + } + }, + "production": { + "senza_url": "https://staging.senza.us/api/v2/", + "macaroon_location": "/home/bitcoin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon", + "tls_location": "/home/bitcoin/.lnd/tls.cert", + "lnd_log_location": "/home/bitcoin/.lnd/logs/bitcoin/mainnet/lnd.log", + "node_ip": "localhost", + "lnd_ip": "localhost", + "node_http_protocol": "http", + "node_http_port": "53001", + "lnd_port": "10009", + "hub_api_url": "https://hub.sphinx.chat/api/v1", + "hub_url": "https://hub.sphinx.chat/ping", + "hub_invite_url": "https://hub.sphinx.chat/invites", + "hub_check_invite_url": "https://hub.sphinx.chat/check_invite", + "media_host": "memes.sphinx.chat", + "tribes_host": "tribes.sphinx.chat", + "public_url": "", + "connection_string_path": "connection_string.txt", + "ssl": { + "enabled": false, + "save": true, + "port": "80" + } + } + } \ No newline at end of file diff --git a/rootfs/standard/usr/share/mynode/sphinx_config.json b/rootfs/standard/usr/share/mynode/sphinx_config.json new file mode 100644 index 00000000..62448ff6 --- /dev/null +++ b/rootfs/standard/usr/share/mynode/sphinx_config.json @@ -0,0 +1,18 @@ +{ + "development": { + "dialect": "sqlite", + "storage": "/Users/Shared/sphinx.db" + }, + "docker_development": { + "dialect": "sqlite", + "storage": "./sphinx.db" + }, + "test": { + "dialect": "sqlite", + "storage": "/home/ubuntu/sphinx.db" + }, + "production": { + "dialect": "sqlite", + "storage": "/mnt/hdd/mynode/sphinx-relay/sphinx.db" + } + } \ No newline at end of file diff --git a/rootfs/standard/var/www/mynode/mynode.py b/rootfs/standard/var/www/mynode/mynode.py index ed9079a6..a9950740 100644 --- a/rootfs/standard/var/www/mynode/mynode.py +++ b/rootfs/standard/var/www/mynode/mynode.py @@ -240,10 +240,15 @@ def index(): return render_template('state.html', **templateData) elif clone_state == CLONE_STATE_ERROR: error = get_clone_error() + msg = "" + msg += "Clone Error

" + msg += error + msg += "


Retrying in one minute.


" + msg += "Exit Clone Tool" templateData = { "title": "myNode Clone Tool", "header_text": "Cloning Tool", - "subheader_text": Markup("Clone Error

" + error + "


Retrying in one minute."), + "subheader_text": Markup(msg), "ui_settings": read_ui_settings(), "refresh_rate": 10 } @@ -254,6 +259,10 @@ def index(): os.system("touch /tmp/.clone_confirm") time.sleep(3) return redirect("/") + if request.args.get('clone_rescan'): + os.system("touch /tmp/.clone_rescan") + time.sleep(3) + return redirect("/") source_drive = get_clone_source_drive() target_drive = get_clone_target_drive() diff --git a/setup/setup_device.sh b/setup/setup_device.sh index c87e3c58..3f3883a2 100755 --- a/setup/setup_device.sh +++ b/setup/setup_device.sh @@ -160,7 +160,7 @@ apt-get -y install libffi-dev libssl-dev glances python3-bottle automake libtool apt -y -qq install apt-transport-https ca-certificates apt-get -y install xorg chromium openbox lightdm openjdk-11-jre libevent-dev ncurses-dev apt-get -y install zlib1g-dev libudev-dev libusb-1.0-0-dev python3-venv gunicorn -apt-get -y install libsqlite3-dev torsocks python3-requests libsystemd-dev +apt-get -y install sqlite3 libsqlite3-dev torsocks python3-requests libsystemd-dev # Make sure some software is removed @@ -757,6 +757,55 @@ if [ ! -f /usr/bin/ngrok ]; then cp ngrok /usr/bin/ fi + +# Upgrade CKbunker +CKBUNKER_UPGRADE_URL=https://github.com/Coldcard/ckbunker/archive/$CKBUNKER_VERSION.tar.gz +CURRENT="" +if [ -f $CKBUNKER_VERSION_FILE ]; then + CURRENT=$(cat $CKBUNKER_VERSION_FILE) +fi +if [ "$CURRENT" != "$CKBUNKER_VERSION" ]; then + cd /opt/mynode + sudo -u bitcoin wget $CKBUNKER_UPGRADE_URL -O ckbunker.tar.gz + sudo -u bitcoin tar -xvf ckbunker.tar.gz + sudo -u bitcoin rm ckbunker.tar.gz + sudo -u bitcoin mv ckbunker-* ckbunker + cd ckbunker + + # Make venv + if [ ! -d env ]; then + sudo -u bitcoin python3 -m venv env + fi + source env/bin/activate + pip3 install -r requirements.txt + pip3 install --editable . + deactivate + + echo $CKBUNKER_VERSION > $CKBUNKER_VERSION_FILE +fi + + +# Upgrade Sphinx Relay +SPHINX_RELAY_UPGRADE_URL=https://github.com/stakwork/sphinx-relay/archive/$SPHINX_RELAY_VERSION.tar.gz +CURRENT="" +if [ -f $SPHINX_RELAY_VERSION_FILE ]; then + CURRENT=$(cat $SPHINX_RELAY_VERSION_FILE) +fi +if [ "$CURRENT" != "$SPHINX_RELAY_VERSION" ]; then + cd /opt/mynode + rm -rf sphinx-relay + sudo -u bitcoin wget $SPHINX_RELAY_UPGRADE_URL -O sphinx-relay.tar.gz + sudo -u bitcoin tar -xvf sphinx-relay.tar.gz + sudo -u bitcoin rm sphinx-relay.tar.gz + sudo -u bitcoin mv sphinx-relay-* sphinx-relay + cd sphinx-relay + + sudo -u bitcoin npm install + + echo $SPHINX_RELAY_VERSION > $SPHINX_RELAY_VERSION_FILE +fi + + # Make sure we are using legacy iptables update-alternatives --set iptables /usr/sbin/iptables-legacy || true update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy || true