From 912e138155a818418bef48eaf8fa85fd4812823b Mon Sep 17 00:00:00 2001 From: nahuhh <50635951+nahuhh@users.noreply.github.com> Date: Wed, 2 Mar 2022 09:58:17 -0500 Subject: [PATCH] v4.1.1 (#15) * Condense and reorganize * Small tweaks * Acquire/release wakelock * Fix DuckDuckGo link * Updates - force RPC SSL - notification updates * Spelling error * SSL fix * Undo forced RPC SSL Rpc forced SSL has issues Should be fixed with https://github.com/monero-project/monero/pull/7760 --- README.md | 280 +++++++++++++++++-------------- src/install-monerod-in-termux.sh | 84 +++++++--- 2 files changed, 208 insertions(+), 156 deletions(-) diff --git a/README.md b/README.md index 4260306..4b0df07 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# android-termux-monero-node -Run a Full or Pruned Monero Node on Android using Termux +# Monerod-in-Termux +Run a Monero Node on Android using Termux
@@ -9,38 +9,99 @@ Run a Full or Pruned Monero Node on Android using Termux
## Table of Contents -- [android-termux-monero-node](#android-termux-monero-node) - - [Table of Contents](#table-of-contents) -- [Why](#why) -- [Contributing to the Monero Network](#contributing-to-the-monero-network) -- [WARNING...](#warning) -- [Install](#install) -- [Controls Overview](#controls-overview) -- [Connecting to your Node / Seeding the Network](#connecting-to-your-node--seeding-the-network) - - [Wallet Connections](#wallet-connections) - - [P2P Seeding](#p2p-seeding) -- [Updates](#updates) -- [TODO's:](#todos) -- [Donate:](#donate) - -# Why - -The goal of this project is to give newbs a stupid-easy way to run an energy-efficient, full or pruned Monero node with decent defaults on an Android device.... ideally, this is a few year old device that's currently sitting in a drawer doing nothing. Why not set it up as a Monero node that sits at your house all day or you toss in a bag for making ultra-secure Monero transactions on the go? This code and install process isn't meant for power users, people with extreme use cases, etc. If you're already that smart, you should just hack up my code and use it however you like. - -Battery Life- -I'm running this on a phone that's plugged in most of the time, so I can't speak for battery life; I would assume that once you're fully synced, the battery usage will drop quite a bit. +- [Background](#background) +- [TLDR / Install](#tldr--install) +- [Table of Contents](#table-of-contents) + - [⚠️ Warnings](#warnings) + - [Controls Overview](#controls-overview) + - [Connecting to your Node / Seeding the Network](#connecting-to-your-node--seeding-the-network) + - [Wallet Connections](#wallet-connections) + - [P2P Seeding](#p2p-seeding) + - [Updates](#updates) + - [TODO's](#todos) + - [Donate](#donate) + +# Background + +The goal of this project is to give newbs a stupid-easy way to run an energy-efficient, full or pruned Monero node on Android. + +Ideally, this is an older device that's currently sitting in a drawer, doing nothing. +Why not set it up as a Monero node? + +Battery Life +- Recommend leaving charger connected during initial sync, which can take a couple days. +- Battery usage after sync completion is quite low, but not 0 due to wake-lock being applied. +- While the node can be run on your main device, it is recommended to keep the device plugged in when running 24/7 or better, to run on a spare/old device. + +Data Usage +- Over 100 gb initial download. +- After fully synced, and using config settings of: 1gb max up/down speeds; 32/100 out/in peers; averaging 25kb/s up/down: + - Approx 2gb/day (dl) as of Sunday, January 02, 2022. + - Slightly more than 4gb if P2P seeding is enabled. +- You can check your data usage using the **XMR Node Status** shortcut from the widget. It will show in the terminal that pops up. + +Running a Monero node allows you to connect your wallet (Feather, CakeWallet, Monerujo etc) to your node. +While Monero is private, using a _remote_ node (one operated by a 3rd party) involves some level of trust. +A remote node receives certain information from you, such as the date, time of a tx and the IP that sent it to the node. +Running a node on Android is an easy and more decentralized way to both use and improve Monero and the Monero network. + + +# TLDR / Install + +Prerequisites: + + - Android 7.0+ with ARMv8/v7 architecture + - The script will check the architecture before running + - 50GB min free space (64GB+ Recommended) for Pruned node + - 150GB min free space (256GB+ Preferred) for Full Node + - External Storage is recommended. + +Steps: + +1. Install the [F-Droid App Store](https://f-droid.org/) + +2. Install these Apps from F-Droid: + + (Do **NOT** install from Play store. If any of these are already installed from gplay, uninstall them) + - [Termux](https://f-droid.org/packages/com.termux) + - [Termux:Widget](https://f-droid.org/packages/com.termux.widget) + - [Termux:API](https://f-droid.org/packages/com.termux.api) + - [Termux:Boot](https://f-droid.org/packages/com.termux.boot) + +2. Set app permissions: + + Go to: + 1. Android Settings > search for ”Special Access" + 2. Select "Battery Optimization" > All Apps + Then disable battery optimization for + - Termux + - Termux:Boot + 3. Return to "Special Access" screen + 4. Select "Draw over other apps" + Enable draw over apps aka draw on top for: + - Termux + +3. In termux, issue the command +```bash +sh -c "$(curl -fsSL https://github.com/CryptoGrampy/android-termux-monero-node/raw/main/src/install-monerod-in-termux.sh)" +``` +4. Follow the prompts. -Data Usage- -No idea how much data Monero uses- you'll almost certainly want to be on WiFi while it's initially syncing, and turn off the node while out and about. My node sits on a shelf next to my wifi router. + _**All Users:**_ -Running a Monero node allows you to connect CakeWallet or Monerujo to the node running in the device itself, rather than connecting to a remote node; this is a safer way of using Monero, and it alleviates network strain on the remote nodes. You should also be able to connect from other devices in your LAN + Press Y when/if asked to use package maintainers version of sources.list +5. Add the 2x2 Termux widget to your home screen. -# Contributing to the Monero Network +6. SUCCESS -If you simply install and run this software without making any updates in your router, you are actually LEECHING from the rest of the users of the network. To truly contribute back to the network, open port 18080 in your router to seed (distribute) the Monero blockchain to the rest. To verify you're helping seed the network and that you've set up your router correctly, you will see 🌱 P2P: 5 (some number larger than 0) in your Android notifications. +NOTE: YOU WILL NOT BE ABLE TO TRANSACT UNTIL YOUR NODE IS 100% SYNCED. -While I DO recommend connecting to your Android node from within your local network using RPC, I DON'T recommend opening the RPC port in your router (yet). +**Extras** + 1. Run on Boot: Open the "Termux:Boot" app (once). + 2. Run in Fore/Background: "Stop" then "Start" the node from widget. + 3. Connect to your Node: [Wallet Connections](#wallet-connections). + 4. Enable P2P seeding (distributing) of the Blockchain [Forwarding P2P (seeding) port](#p2p-seeding). More info on running a Monero Node: @@ -48,115 +109,59 @@ https://www.reddit.com/r/Monero/comments/kkr04n/infographic_running_a_node_which https://www.reddit.com/r/Monero/comments/kkgly6/message_to_all_monero_users_we_need_more_public/ https://www.reddit.com/r/Monero/comments/ko0xd1/i_put_together_a_new_guide_for_running_a_monero/ -# WARNING... - -1. DO NOT RUN THIS ON INTERNAL ANDROID STORAGE (use microSD ONLY) OR YOU IT WILL EVENTUALLY BURN OUT (Per Howard Chu) and Run this code AT YOUR OWN RISK and READ THE CODE (and feel free to reach out if you have any improvements 😜). - -2. MicroSD cards have a limited lifespan in general, and it's possible the card will burn out after a couple years, though I don't have solid metrics on this. Monero is mostly writes and reads- not rewrites which are what kill storage the fastest. - -3. You WILL (likely) lose data saved on your microSD card. Backup before running this code. - -4. If things go awry, delete all of the Termux apps you're about to install, and all will be back to normal. - - -# Install - -Video Install Guide (Use the code linked in this repo down below rather than the Pastebin shown in the video): - -[![Monero Full Node Install](https://img.youtube.com/vi/z46zAy-LoHE/0.jpg)](https://www.youtube.com/watch?v=z46zAy-LoHE) - -1. Hardware Prep: - - Android 7.0+ with ARMv8 CPU (Nearly all made in the last few years are fine) - - [Check your Android CPU 'Instruction Set' here](https://www.devicespecifications.com/en/model/f6cb274f) - - Freshly wiped 128GB (256GB+ Preferred) microSD set up in Android AS EXTERNAL STORAGE - -
-
- -
Example ARMv8 CPU Instruction Set
-
-
- - -1. Install Necessary Apps - - Install the Fdroid App Store (https://f-droid.org/) - - Install these Apps from Fdroid (Do NOT install from Play store. If any of these are already installed, uninstall them) - - Termux - - Termux:Boot - - Termux:Widget - - Termux:API - -
-
- -
Apps to Install from F-Droid Store
-
-
- -3. Set Android Permissions (Go into Android settings and search for the permission names if you're having trouble locating them) - - Battery Optimization: Don't Optimize: Termux and Termux:Boot - - Display Over Other Apps: Termux - -
- - -
- -4. Add the 'Termux Widget 2x2' Widget to your Android home screen (press the refresh button after you've finished the install process) +# WARNINGS... -
- -
+1. Ideally you should store the blockchain on external storage (MicroSD etc). + Regardless of whether the blockchain is stored on SD or Internal.. + You should run this AT YOUR OWN RISK and READ THE CODE. Feel free to make or suggest improvements. -5. Install +2. Monero is mostly writes and reads - not rewrites - which are what kill storage the fastest. - Quick Install- Copy and paste this into Termux, and press Enter - ```bash - sh -c "$(curl -fsSL https://raw.githubusercontent.com/CryptoGrampy/android-termux-monero-node/main/src/install-monerod-in-termux.sh)" - ``` +3. You may risk your data or the lifespan of your microSD / Internal storage may be shortened. - Elaborate Install: - - Copy the code (INCLUDING the parenthesis) from the links below based on the node type/storage available on your device. + It is recommended to backup before running, and preferably to run on a dedicated / spare / old device. - Make sure your screen stays 'on' throughout the install- give the screen a tap if necessary. +4. **Do _NOT_ forward port 18081 (the UNRESTRICTED RPC port)** - Open Termux, and paste the copied code into the terminal. Press the return button on the on-screen keyboard. You will likely need to give Termux permission to do various things (add repos, etc) during the install. Read what it's asking, type y and then press return. +# Controls Overview -6. SUCCESS! +Using the Termux Widget, you can 'Start XMR Node', 'Stop XMR Node', 'Update XMR Node', and check the 'XMR Node Status'. -# Controls Overview +The notification will be automatically be updated every 15 minutes. The first notification after starting your node may not appear until after 30 seconds have passed. -Using the Termux Widget, you can 'Start XMR Node', 'Stop XMR Node', 'Update XMR Node', and check the 'XMR Node Status'. Try them all- you're not going to break anything. Tap the arrow in the Android Termux notification in your swipe-down Android notifications to see detailed info on your Node. If a Monero update is available, it will be present in this notification. +The notification might not be 100% accurate on slower devices. You can force a refresh of the notification from notification itself, or by using the 'XMR Node Status' shortcut in the Termux widget. -The notifications will be automatically be updated every 15 minutes. The first notification after restarting your device or starting turning your node on might not be 100% accurate as the Monero node can take a while to start up. If you press the 'XMR Node Status' button in the Termux widget, you will briefly see the actual command line status of Monerod pop up in a Termux shell, and the Android notification will also update with the most recent node information (useful if you don't want to wait 15 minutes for an update) +Alternatively, you can "Stop" the node, and "Start" it in the foreground. # Connecting to your Node / Seeding the Network -There are a few ip addresses and ports you need to know when running a wallet on the Android device itself, when you're pointing ANOTHER device in your LOCAL network at your new full or pruned node, or when you're opening up your router to seed the network. +Following are a few ip addresses and ports to make note of. ## Wallet Connections -NOTE: YOU WILL NOT BE ABLE TO TRANSACT UNTIL YOUR NODE IS 100% SYNCED. Continue using remote nodes/whatever you were using before in Cake or Monerujo until you're fully synced. +NOTE: YOU WILL NOT BE ABLE TO TRANSACT UNTIL YOUR NODE IS 100% SYNCED. -| Wallet Connection | IP (Why?) | Port (Why?) | -| ---------------------------- | ----------- | --------| -| Point CakeWallet/Monerujo Running on my Android at my XMR Node | 127.0.0.1 (This is Localhost!) | 18081 (Non-Remote RPC Port) | -| Point an XMR wallet on another device on my local network at my XMR node | VARIES (check router for your local Android device IP) | 18089 (REMOTE RPC Port) | -| Point an XMR wallet on another device OUTSIDE my local network at my node | Feature Not Available | Feature Not Available | +| Wallet relationship to node: | IP: | Port: (Why?) | Forward? | +| ---------------------------- | ------ | ------ | --- | +| The same device | 127.0.0.1 | 18081 (Unrestricted RPC Port) | Yes | +| Different devices on the same local network | Check Notification | 18089 (Restricted RPC Port) | No | +| Different devices on seperate networks | Public / Internet facing IP. [Search DuckDuckGo for ”my ip"](https://ddg.gg/?q=my+ip&ia=answer)| 18089 (Restricted RPC Port) | Yes | - -If you're looking to go a little deeper, and understand why the above ip addresses/ports in the table are the way they are, this is the Monero startup command used in the script you ran. You can look up what each of these items means in [this nice Monerod reference guide]([src/full-monero-node-install](https://monerodocs.org/interacting/monerod-reference/)) - -```bash -./monerod --data-dir $NODE_DATA --db-sync-mode safe:sync --enable-dns-blocklist --in-peers 10 --rpc-restricted-bind-ip 0.0.0.0 --rpc-restricted-bind-port 18089 --rpc-bind-ip 127.0.0.1 --rpc-bind-port 18081 --no-igd --no-zmq --detach -``` +These are the default ports set in the config file. +You can edit the config file (located at crypto/monero-cli). +[Here is a nice Monerod reference guide]([src/full-monero-node-install](https://monerodocs.org/interacting/monerod-reference/)) ## P2P Seeding -If you want to seed the Monero network in the same way you would seed a torrent, and YES, I do encourage this, in your router, you need to forward port 18080 (NOT 18081 and NOT 18089) to your Android device. This process varies by router, but if you google 'port forwarding netgear (whatever your router brand is), you will find a guide. +If you want to seed (help distribute) the Monero network (Recommended) +| Port: (Why?) | Forward? | +| -------------- | --- | +| 18080 (P2P Port) | Yes | + +The process for port forwarding may vary slightly depending on the router used. +If you [DuckDuckGo "port forwarding"](https://ddg.gg/port-forwarding) and add the name / brand of your router, you should find a guide. -For instance, this is how mine is setup: +Example:
@@ -166,32 +171,47 @@ For instance, this is how mine is setup:
- -Once you've enabled port forwarding of 18080, like magic, the P2P value in the Monero node notifications on your Android device will begin to tick up in value. You're helping the network. - If you decide, for whatever reason, that you want to stop seeding the network, simply stop forwarding port 18080 in your router/remove the port forwarding rule. Troubleshooting: - - If P2P suddenly stops working for you, it's possible your router changed the port of your Android device (this is normal behavior for a router). You will likely need to set up your Android device to use a 'static ip'... For this, Google 'static ip address android phone' or 'static ip address Netgear router' and figure out how to make your router always use the same ip internal ip address for your phone (Perhaps I'll add these instructions in the future) + - If P2P stops working for you, it's possible your router changed the IP of your Android device (this is normal behavior for a router). + + You will likely need to set up your Android device to use a 'static ip'... For this.. + + Open Android Setting, and go to: wifi > tap & hold on current network > edit/modify > [show advanced] > ip settings + + Change DHCP from "auto/dynamic" to "manual/static". # Updates -- Termux Node Code: If you find out that I've added an amazing new feature, and you want to update your code, simply copy the newly updated install script from Github and paste it into a Termux shell- it's the same process as the initial install. I will do my best to take care of any cleanup activities that need to happen. +- (Stable) CryptoGrampy/main Install script: + Run +```bash +sh -c "$(curl -fsSL https://github.com/CryptoGrampy/android-termux-monero-node/raw/main/src/install-monerod-in-termux.sh)" + ``` + and follow the prompts. -- Monero: If you receive a notification that there is a new Monero version out (or perhaps you find out on Reddit, Twitter, etc), simply run the 'Update XMR Node' Termux shortcut through the Termux Widget. +- Updates to Monerod (node SW): Run the 'Update XMR Node' shortcut to install the new version. # TODO's: -- [x] Turn off notifications and boot wake locks when user turns node off/add them back when node is turned on -- [x] Create Uninstaller -- [x] Custom Configs -- [x] Run as pruned -- [x] Check for external SD, if doesn't exist use different/symlinked install dir, check space before installing? -- [ ] Secure RPC defaults +- TBD # Donate: -- If you enjoy this software, please feel free to send $XMR tips to [CryptoGrampy](https://twitter.com/CryptoGrampy)! +If you enjoy this software, please feel free to send a tip to: -- $XMR : 85HmFCiEvjg7eysKExQyqh5WgAbExUw6gF8osaE2pFrvUhQdf1HdD6XSTgAr4ECYMre6HjWutPJSdJftQcYEz3m2PYYTE6Y - +- **[CryptoGrampy](https://twitter.com/CryptoGrampy)!** $XMR: +``` +85HmFCiEvjg7eysKExQyqh5WgAbExUw6gF8osaE2pFrvUhQdf1HdD6XSTgAr4ECYMre6HjWutPJSdJftQcYEz3m2PYYTE6Y +``` + + - **[plowsof](https://github.com/plowsof)** $XMR: +``` +86aSNJwDYC2AshDDvbGgtQ17RWspmKNwNXAqdFiFF2Db91v9PC26uDxffD9ZYfcMjvJpuKJepsQtELAdmXVk85E1DsuL6rG +``` + + - **[nahuhh](https://github.com/nahuhh)** ☠️ $XMR: +``` +8343hzpypz2BR5ybAMNvvhaLtbXSMgCT7KqYSTfLBk3DF8Yayi5b7JGRWZc2GdqNu1EkALEFv1FHkCgeQ1zzkUFVMqtcTBy +``` diff --git a/src/install-monerod-in-termux.sh b/src/install-monerod-in-termux.sh index 0a525ee..6a731a7 100644 --- a/src/install-monerod-in-termux.sh +++ b/src/install-monerod-in-termux.sh @@ -42,6 +42,7 @@ then fi termux-wake-lock +sleep 1 pkg update -y pkg install nano wget termux-api jq -y @@ -192,6 +193,9 @@ cd $NODE_CONFIG rpc-bind-port=18081 # Default = 18081 #confirm-external-bind=1 # Open node (confirm). Required if binding outside of localhost #restricted-rpc=1 # Prevent unsafe RPC calls. + +# Services + rpc-ssl=autodetect no-zmq=1 no-igd=1 # Disable UPnP port mapping db-sync-mode=safe # Slow but reliable db writes @@ -205,7 +209,7 @@ cd $NODE_CONFIG # Connection Limits out-peers=32 # This will enable much faster sync and tx awareness; the default 8 is suboptimal nowadays - in-peers=100 # The default is unlimited; we prefer to put a cap on this + in-peers=32 # The default is unlimited; we prefer to put a cap on this limit-rate-up=1048576 # 1048576 kB/s == 1GB/s; a raise from default 2048 kB/s; contribute more to p2p network limit-rate-down=1048576 # 1048576 kB/s == 1GB/s; a raise from default 8192 kB/s; allow for faster initial sync EOF @@ -283,22 +287,20 @@ RESP=\$(termux-dialog radio -t "Run Node in:" -v "Background,Foreground" | jq '. termux-wake-lock cd $MONERO_CLI ./monerod --config-file $NODE_CONFIG/config.txt --detach - sleep 1 + sleep 15 cp $TERMUX_SHORTCUTS/.Boot\ XMR\ Node $TERMUX_BOOT/Boot\ XMR\ Node - termux-job-scheduler --job-id 1 -s $TERMUX_SCHEDULED/xmr_notifications --period-ms 900000 + termux-job-scheduler --job-id 1 -s $TERMUX_SCHEDULED/xmr_notifications termux-job-scheduler --job-id 2 -s $TERMUX_SCHEDULED/Update\ XMR\ Node --period-ms 86400000 sleep 1 - termux-toast -g middle "Node Running in Background" fi if [ \$RESP = '"Foreground"' ] then termux-wake-lock cp $TERMUX_SHORTCUTS/.Boot\ XMR\ Node $TERMUX_BOOT/Boot\ XMR\ Node - termux-job-scheduler --job-id 1 -s $TERMUX_SCHEDULED/xmr_notifications --period-ms 900000 + termux-job-scheduler --job-id 1 -s $TERMUX_SCHEDULED/xmr_notifications termux-job-scheduler --job-id 2 -s $TERMUX_SCHEDULED/Update\ XMR\ Node --period-ms 86400000 cd $MONERO_CLI - termux-toast -g middle "Started XMR Node" sleep 1 ./monerod --config-file $NODE_CONFIG/config.txt fi @@ -312,12 +314,11 @@ EOF termux-wake-lock cd $MONERO_CLI ./monerod --config-file $NODE_CONFIG/config.txt --detach -sleep 5 +sleep 15 cp $TERMUX_SHORTCUTS/.Boot\ XMR\ Node $TERMUX_BOOT/Boot\ XMR\ Node -termux-job-scheduler --job-id 1 -s $TERMUX_SCHEDULED/xmr_notifications --period-ms 900000 +termux-job-scheduler --job-id 1 -s $TERMUX_SCHEDULED/xmr_notifications termux-job-scheduler --job-id 2 -s $TERMUX_SCHEDULED/Update\ XMR\ Node --period-ms 86400000 sleep 1 -termux-toast -g middle "Node Running in Background" EOF cat << EOF > Stop\ XMR\ Node @@ -327,7 +328,7 @@ cd $MONERO_CLI rm -f $TERMUX_BOOT/Boot\ XMR\ Node termux-wake-unlock -termux-notification -i monero -c "πŸ”΄ XMR Node Offline" --priority low --alert-once +termux-notification -i monero -c "πŸ”΄ XMR Node Shutdown" --priority low --alert-once termux-job-scheduler --cancel --job-id 1 termux-job-scheduler --cancel --job-id 2 sleep 1 @@ -340,22 +341,39 @@ EOF cd $MONERO_CLI ./monerod print_net_stats ./monerod status -sleep 5 -cd $TERMUX_SCHEDULED -./xmr_notifications +sleep 10 EOF - cat << "EOF" > xmr_notifications + cat << 'EOF' > xmr_notifications #!/data/data/com.termux/files/usr/bin/sh -sleep 5 -REQ=$(curl -s http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}' -H 'Content-Type: application/json') - +sleep 7 +REQ=$(curl -sk https://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}' -H 'Content-Type: application/json') +LAST=$(date +%r) if [ "$REQ" ] then - DATA=$(echo $REQ | jq '.result') + +EOF + +# Refresh Notification handling (not ideal method) + +cp xmr_notifications xmr_notifications_released + +cat << 'EOF' >> xmr_notifications +termux-job-scheduler --job-id 1 -s ~/termux-scheduled/xmr_notifications_acquired --period-ms 900000 +termux-toast -g middle -b black -c green Node Running! Check Notification. +else +NOTIFICATION="🟑 Connecting...Please wait 30s($LAST)" +termux-notification -i monero -t "$NOTIFICATION" --ongoing --priority max --alert-once --button1 "SHUTDOWN NODE" --button1-action 'monero-cli/monero-cli/monerod exit | termux-wake-unlock | termux-job-scheduler --cancel --job-id 1 | termux-job-scheduler --cancel --job-id 2 | termux-toast -g middle "Stopped XMR Node" | rm .termux/boot/Boot\ XMR\ Node | termux-notification -i monero -c "πŸ”΄ XMR Node Shutdown" --priority low' --button2 "REFRESH STATUS" --button2-action 'bash -l -c termux-scheduled/xmr_notifications' +sleep 23 +termux-job-scheduler --job-id 1 -s ~/termux-scheduled/xmr_notifications_acquired --period-ms 900000 +fi +EOF + +cat << 'EOF' >> xmr_notifications_released +DATA=$(echo $REQ | jq '.result') DATE=$(date -d @$(echo "$DATA" | jq '.start_time' )) VERSION=$(echo "$DATA" | jq -r '.version' ) - NODE_ONLINE=$(echo "$DATA" | jq -r 'if .offline == false then "🟒 XMR Node Online" else "πŸ”΄ XMR Node Offline" end') + STATUS=$(echo "$DATA" | jq -r 'if .offline == false then "🟒 XMR Node Online" else "πŸ”΄ XMR Node Offline" end') OUTGOING_CONNECTIONS=$(echo "$DATA" | jq '.outgoing_connections_count' ) P2P_CONNECTIONS=$(echo "$DATA" | jq '.incoming_connections_count' ) RPC_CONNECTIONS=$(echo "$DATA" | jq '.rpc_connections_count' ) @@ -365,14 +383,28 @@ then LOCAL_IP=$(echo $(termux-wifi-connectioninfo | jq '.ip') | tr -d '"') NOTIFICATION=$(printf '%s\n' "⛓️ XMR-$VERSION" "πŸ•οΈ Running Since: $DATE" "πŸ”„ Sync Progress: $SYNC_STATUS %" "πŸ“€οΈ OUT: $OUTGOING_CONNECTIONS / 🌱 P2P: $P2P_CONNECTIONS / πŸ“² RPC: $RPC_CONNECTIONS" "πŸ’Ύ Free Space: $STORAGE_REMAINING GB" "πŸ”Œ Local IP: ${LOCAL_IP}:18089" "$UPDATE_AVAILABLE" ) + else - NODE_ONLINE="πŸ”΄ XMR Node Offline!" - NOTIFICATION="RPC Error: Turn on your Node!" + STATUS="πŸ”΄ ERROR: Is your node running? ($LAST)" + NOTIFICATION="Refresh the notification. +Otherwise, restart the node" fi -termux-notification -i monero -c "$NOTIFICATION" -t "$NODE_ONLINE" --ongoing --priority low --alert-once --button1 DISCONNECT --button1-action 'monero-cli/monero-cli/monerod exit | termux-wake-unlock | termux-job-scheduler --cancel --job-id 1 | termux-job-scheduler --cancel --job-id 2 | termux-toast -g middle "Stopped XMR Node" | rm .termux/boot/Boot\ XMR\ Node | termux-notification -i monero -c "πŸ”΄ XMR Node Offline" --priority low' --button2 "REFRESH NODE STATUS" --button2-action 'bash -l -c termux-scheduled/xmr_notifications' +termux-notification -i monero -c "$NOTIFICATION" -t "$STATUS ($LAST)" --ongoing --priority low --alert-once --button1 "SHUTDOWN NODE" --button1-action 'monero-cli/monero-cli/monerod exit | termux-wake-unlock | termux-job-scheduler --cancel --job-id 1 | termux-job-scheduler --cancel --job-id 2 | termux-toast -g middle "Stopped XMR Node" | rm .termux/boot/Boot\ XMR\ Node | termux-notification -i monero -c "πŸ”΄ XMR Node Shutdown" --priority low' --button2 "ACQUIRE WAKELOCK" --button2-action 'termux-wake-lock | termux-job-scheduler --job-id 1 -s ~/termux-scheduled/xmr_notifications_acquired --period-ms 900000' --button3 "REFRESH STATUS" --button3-action 'bash -l -c termux-scheduled/GET_REFRESH' EOF +# Fill notification variables + +sed -i -z "s|sleep 7\n|sleep 7\ntermux-toast -g middle -b black Node Starting Up.. Please Wait 10s.\n|g" xmr_notifications +sed -i -z "s|sleep 7\n| \n|g" xmr_notifications_released +cp xmr_notifications_released xmr_notifications_acquired +sed -i -z "s|ACQUIRE |RELEASE |g" xmr_notifications_acquired +sed -i -z "s|acquired|released|g" xmr_notifications_acquired +sed -i -z "s|termux-wake-lock|termux-wake-unlock|g" xmr_notifications_acquired +sed -i -z "s|GET_REFRESH|xmr_notifications_acquired|g" xmr_notifications_acquired +sed -i -z "s|GET_REFRESH|xmr_notifications_released|g" xmr_notifications_released + + cat << EOF > Update\ XMR\ Node #!/data/data/com.termux/files/usr/bin/sh sleep 5 @@ -401,7 +433,7 @@ func_xmrnode_install_prompt(){ fi } -REQ=\$(curl -s http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}' -H 'Content-Type: application/json') +REQ=\$(curl -sk https://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}' -H 'Content-Type: application/json') if [ "\$REQ" ] then DATA=\$(echo \$REQ | jq '.result') @@ -447,7 +479,7 @@ then rm -f .Boot\ XMR\ Node rm -f $TERMUX_BOOT/*XMR\ Node* cd $TERMUX_SCHEDULED - rm -f xmr_notifications + rm -f xmr_notifications* rm -f Update\ XMR\ Node cd $TERMUX_SHORTCUTS @@ -480,11 +512,11 @@ chmod +x Stop\ XMR\ Node chmod +x Update\ XMR\ Node chmod +x XMR\ Node\ Status chmod +x .Boot\ XMR\ Node -chmod +x xmr_notifications +chmod +x xmr_notifications* chmod +x Uninstall\ XMR\ Node cp .Boot\ XMR\ Node $TERMUX_BOOT/Boot\ XMR\ Node -mv xmr_notifications $TERMUX_SCHEDULED +mv xmr_notifications* $TERMUX_SCHEDULED cp Update\ XMR\ Node $TERMUX_SCHEDULED