├── LICENSE ├── QR └── install.png ├── README.md ├── ccminer ├── config.json ├── install.sh └── monitoring ├── MONITORING.md ├── api.pl └── check-all /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Oink 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /QR/install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Oink70/Android-Mining/f020d65d07178a7fabbc1d11b199a43a309c278d/QR/install.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-Mining 2 | Quick installation of mining on Android Phones 3 | 4 | ## Github cloning and customizing 5 | 1. clone this repo to your own github account. 6 | 2. change the URL on line 35 of the README.md to reflect your own account. 7 | 3. replace `QR/install.png` with your own. 8 | 4. **Important**: change the SSH key on line 13 of `install.sh` to reflect your own SSH key. 9 | 5. change lines 50 to reflect your own github link. 10 | 6. adjust the `config.json` to your address and mining details. 11 | 7. optional: change line 20 of your `config.json` to your own LAN IP range. 12 | 8. optional: change line 21 of your `config.json` to the LAN IP your phone uses. 13 | 14 | ## No support 15 | - Although the installation procedure is considered doable for people that have zero to little Linux knowledge, I do **not** provide any support to users that that mess up as a result of lack of knowledge. 16 | - Reading is an dying art. There's no instruction video for people that can't follow instructions step-by-step. 17 | 18 | ## Prerequisites 19 | - Some fundamental Linux knowledge is *required*. (do an online coarse!) 20 | - Knowledge about how to operate Linux *screen* is a must. 21 | - Knowledge on *ssh* and *scp* is highly recommended. 22 | - Stable network (WiFi/cellular) is a must for proper installation/operation. Be prepared to troubleshoot and fix them yourself. 23 | 24 | ## Installation instructions 25 | - install Userland app (preferably version `2.8.3` from appstore or a downloaded apk) on your Android 26 | - select Ubuntu in Userland and supply your login details. 27 | - choose SSH 28 | - wait for it to install, enter Ubuntu and log into your account 29 | ```bash 30 | lscpu 31 | ``` 32 | If the output doesn't show `Architecture: aarch64` or `CPU op-mode(s): 32-bit, 64-bit`, then do not bother to continue. Your phone is not running a 64-bit OS. 33 | 34 | ```bash 35 | curl -o- -k https://raw.githubusercontent.com/Oink70/Android-Mining/main/install.sh | bash 36 | ``` 37 | For easy access on phones: 38 | ![install.sh](QR/install.png) 39 | 40 | Now adjust pools, mineraddress+workername, and network settings for the API. 41 | exit with `-X` followed by `y` and an `` 42 | ```bash 43 | nano config.json 44 | ``` 45 | 46 | ## Usage: 47 | start mining with `~/ccminer/start.sh` 48 | 49 | Standard SSH port for Userland is port `2022`. 50 | Optional: create an entry in your SSH config file for each phone: 51 | ``` 52 | Host Pixel2XL01 53 | Hostname 192.168.25.81 54 | Port 2022 55 | User Pixel2XL01 56 | IdentityFile ~\.ssh\id-rsa_oink-private 57 | ``` 58 | 59 | Starting the miner: 60 | `~/ccminer/start.sh` 61 | 62 | Monitoring the miner: 63 | - `screen -x CCminer` 64 | - exit with `CTRL-a` key combination followed by `d`. 65 | 66 | Terminating the miner: 67 | `screen -X -S CCminer quit` 68 | 69 | ## Monitoring your miners (on a linux host) 70 | check [MONITORING](/monitoring/MONITORING.md). 71 | 72 | WARNING: The scripts installs my own public SSH key. You may want to remove that from your `~/.ssh/authorized_keys` file and replace it with your own for passwordless access. 73 | 74 | ### I accept no warranties or liabilities on this repo. It is supplied as a service. 75 | ### Use at your own risk!!! 76 | -------------------------------------------------------------------------------- /ccminer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Oink70/Android-Mining/f020d65d07178a7fabbc1d11b199a43a309c278d/ccminer -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "pools":[ 3 | { 4 | "name": "pool.verus.io", 5 | "url": "stratum+tcp://pool.verus.io:9998", 6 | "timeout": 150, 7 | "disabled": 0 8 | }, 9 | { 10 | "name": "verus.farm (Quipacorn)", 11 | "url": "stratum+tcp://verus.farm:9999", 12 | "timeout": 60, 13 | "time-limit": 600, 14 | "disabled": 0 15 | }], 16 | 17 | "user": "i81XL8ZpuCo9jmWLv5L5ikdxrGuHrrpQLz.Donator##", 18 | "algo": "verus", 19 | "threads": 8, 20 | "cpu-priority": 1, 21 | "retry-pause": 5, 22 | "api-allow": "192.168.0.0/16", 23 | "api-bind": "0.0.0.0:4068" 24 | } 25 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sudo apt-get -y update 3 | sudo apt-get -y upgrade 4 | sudo apt-get -y install libcurl4-openssl-dev libjansson-dev libomp-dev git screen nano jq wget 5 | wget http://ports.ubuntu.com/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_arm64.deb 6 | sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_arm64.deb 7 | rm libssl1.1_1.1.0g-2ubuntu4_arm64.deb 8 | if [ ! -d ~/.ssh ] 9 | then 10 | mkdir ~/.ssh 11 | chmod 0700 ~/.ssh 12 | cat << EOF > ~/.ssh/authorized_keys 13 | ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQBy6kORm+ECh2Vp1j3j+3F1Yg+EXNWY07HbP7dLZd/rqtdvPz8uxqWdgKBtyeM7R9AC1MW87zuCmss8GiSp2ZBIcpnr8kdMvYuI/qvEzwfY8pjvi2k3b/EwSP2R6/NqgbHctfVv1c7wL0M7myP9Zj7ZQPx+QV9DscogEEfc968RcV9jc+AgphUXC4blBf3MykzqjCP/SmaNhESr2F/mSxYiD8Eg7tTQ64phQ1oeOMzIzjWkW+P+vLGz+zk32RwmzX5V> 14 | EOF 15 | chmod 0600 ~/.ssh/authorized_keys 16 | fi 17 | 18 | if [ ! -d ~/ccminer ] 19 | then 20 | mkdir ~/ccminer 21 | fi 22 | cd ~/ccminer 23 | 24 | GITHUB_RELEASE_JSON=$(curl --silent "https://api.github.com/repos/Oink70/CCminer-ARM-optimized/releases?per_page=1" | jq -c '[.[] | del (.body)]') 25 | GITHUB_DOWNLOAD_URL=$(echo $GITHUB_RELEASE_JSON | jq -r ".[0].assets[0].browser_download_url") 26 | GITHUB_DOWNLOAD_NAME=$(echo $GITHUB_RELEASE_JSON | jq -r ".[0].assets[0].name") 27 | 28 | echo "Downloading latest release: $GITHUB_DOWNLOAD_NAME" 29 | 30 | wget ${GITHUB_DOWNLOAD_URL} -P ~/ccminer 31 | 32 | if [ -f ~/ccminer/config.json ] 33 | then 34 | INPUT= 35 | COUNTER=0 36 | while [ "$INPUT" != "y" ] && [ "$INPUT" != "n" ] && [ "$COUNTER" <= "10" ] 37 | do 38 | printf '"~/ccminer/config.json" already exists. Do you want to overwrite? (y/n) ' 39 | read INPUT 40 | if [ "$INPUT" = "y" ] 41 | then 42 | echo "\noverwriting current \"~/ccminer/config.json\"\n" 43 | rm ~/ccminer/config.json 44 | elif [ "$INPUT" = "n" ] && [ "$COUNTER" = "10" ] 45 | then 46 | echo "saving as \"~/ccminer/config.json.#\"" 47 | else 48 | echo 'Invalid input. Please answer with "y" or "n".\n' 49 | ((COUNTER++)) 50 | fi 51 | done 52 | fi 53 | wget https://raw.githubusercontent.com/Oink70/Android-Mining/main/config.json -P ~/ccminer 54 | 55 | if [ -f ~/ccminer/ccminer ] 56 | then 57 | mv ~/ccminer/ccminer ~/ccminer/ccminer_old 58 | fi 59 | mv ~/ccminer/${GITHUB_DOWNLOAD_NAME} ~/ccminer/ccminer 60 | chmod +x ~/ccminer/ccminer 61 | 62 | cat << EOF > ~/ccminer/start.sh 63 | #!/bin/sh 64 | #exit existing screens with the name CCminer 65 | screen -S CCminer -X quit 1>/dev/null 2>&1 66 | #wipe any existing (dead) screens) 67 | screen -wipe 1>/dev/null 2>&1 68 | #create new disconnected session CCminer 69 | screen -dmS CCminer 1>/dev/null 2>&1 70 | #run the miner 71 | screen -S CCminer -X stuff "~/ccminer/ccminer -c ~/ccminer/config.json\n" 1>/dev/null 2>&1 72 | printf '\nMining started.\n' 73 | printf '===============\n' 74 | printf '\nManual:\n' 75 | printf 'start: ~/.ccminer/start.sh\n' 76 | printf 'stop: screen -X -S CCminer quit\n' 77 | printf '\nmonitor mining: screen -x CCminer\n' 78 | printf "exit monitor: 'CTRL-a' followed by 'd'\n\n" 79 | EOF 80 | chmod +x start.sh 81 | 82 | echo "setup nearly complete." 83 | echo "Edit the config with \"nano ~/ccminer/config.json\"" 84 | 85 | echo "go to line 15 and change your worker name" 86 | echo "use \"-x\" to exit and respond with" 87 | echo "\"y\" on the question to save and \"enter\"" 88 | echo "on the name" 89 | 90 | echo "start the miner with \"cd ~/ccminer; ./start.sh\"." 91 | -------------------------------------------------------------------------------- /monitoring/MONITORING.md: -------------------------------------------------------------------------------- 1 | # Monitoring CCminer 2 | 3 | ## Enabling the API on CCminer. 4 | Monitoring requires CCMINER to have the API enabled, which it is by default not the case. By default it only accepts connections from localhost (127.0.0.1) 5 | In the `config.json` you'll find the required lines needed to enable the API: 6 | ```json 7 | "api-allow": "192.168.1.0/24", # allows access for this IP range. Adjust to your own situation. 8 | "api-bind": "0.0.0.0:4068" # enables the API by making it listen on the specified IP address and port. 0.0.0.0 signifies all adapters and IPs. 9 | ``` 10 | 11 | If desired you can restrict the `api-allow` range to a single IP: `"api-allow": "192.168.1.25/32"`. 12 | 13 | ## talking to the CCminer API port. 14 | In order to talk to CCminer remotely you can use `api.pl` (which is a perl script). 15 | Usage: 16 | ```bash 17 | ./api.pl --cmd COMMAND --address ADDRESS --port PORT 18 | ``` 19 | The `--cmd`, `--address` and `--port` can be abbreviated to `-c`, `-a` and `-p` 20 | Available commands: 21 | ``` 22 | summary 23 | threads 24 | pool 25 | histo 26 | hwinfo 27 | meminfo 28 | scanlog 29 | switchpool 30 | quit 31 | ``` 32 | 33 | `summary` and `pool` are the must usable commands for monitoring. 34 | The `api.pl` returns values separated by `;`s and can already be used to check key data, although they are meant to be machine processed and are not very human friendly. 35 | Keep in mind that most APIs are originally meant to be used in GPU mining operations and are of little value for CPU mining. 36 | 37 | In order to give the key info in a more human friendly manner (but still machine processable) you can use the included `check-all` script. 38 | On line 4 of the script you can supply a space-separated list of IP addresses to check. 39 | The script converts the output of all checked miner IPs and converts that into a single json and prints the key data of that json on line 18. 40 | 41 | That will give us a list of data, which is already human readable, but still not in a human friendly format. The advantage is that it is now in json format, so `jq` can be used to select fields to display. 42 | An example for this would be: 43 | ```bash 44 | ./check-all | jq -c '.[] | [.HOST,.POOL,.KHS]' 45 | ``` 46 | Which shows us which host (IP) is connected to which pool (as defined in the `config.json` of the miner) and the hashrate it produces in kHs, one line per miner. 47 | 48 | I personally use `watch --color -n 60 "/root/api/check-all | jq -c '.[] | [.HOST,.POOL,.KHS]' | sed '/pool.verus.io/s/.*/\x1B[32m&\x1B[0m/g; /pool.verus.io/!s/.*/\x1B[31m&\x1B[0m/g' | column"` in a screen session, to monitor the status of my miners: when on the defined pool (pool.verus.io) it colors the line green, any other status is colored red. 49 | 50 | Of course you can select other keys to monitor. The available keys for the data gathered by `check-all` is: 51 | ``` 52 | HOST # Host that is queried. 53 | POOL # Th pool name the host is using 54 | USER # The username the host is using (mining address + workername) 55 | KHS # The local hashrate in KHS of the host 56 | DIFF # The difficulty of the ob the host is mining 57 | ACC # Number of accepted work jobs submitted to the pool 58 | REJ # Number of rejected work jobs submitted to the pool 59 | WAIT # time the miner is currently waiting for the pool to respond (usually 0 when working on a job) 60 | UPTIME # amount of seconds the miner is running since last start 61 | TS # current time in linux EPOCH format 62 | ``` 63 | 64 | ### I accept no warranties or liabilities on this repo. It is supplied as a service. 65 | ### Use at your own risk!!! -------------------------------------------------------------------------------- /monitoring/api.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # sample script to query ccminer API 3 | use strict; 4 | use warnings; 5 | use Getopt::Long qw(GetOptions); 6 | my $command = "summary"; 7 | my $address = "127.0.0.1"; 8 | my $port = "4086"; 9 | GetOptions('cmd=s' => \$command, 10 | 'address=s' => \$address, 11 | 'port=s' => \$port, 12 | ) or die "Usage: $0 --cmd COMMAND --address ADDRESS --port PORT\n"; 13 | use Socket; 14 | use IO::Socket::INET; 15 | my $sock = new IO::Socket::INET ( 16 | PeerAddr => $address, 17 | PeerPort => $port, 18 | Proto => 'tcp', 19 | ReuseAddr => 1, 20 | Timeout => 2, 21 | ); 22 | if ($sock) { 23 | print $sock $command; 24 | my $res = ""; 25 | while(<$sock>) { 26 | $res .= $_; 27 | } 28 | close($sock); 29 | print("$res\n"); 30 | } else { 31 | print("No Connection\n"); 32 | } 33 | -------------------------------------------------------------------------------- /monitoring/check-all: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | SCRIPTPATH=$(dirname $(realpath $0)) 3 | 4 | LIST="10.0.0.101 10.0.0.102 10.0.0.103 10.0.0.104 10.0.0.105 10.0.0.106 10.0.0.107 10.0.0.108 10.0.0.109 10.0.0.110" 5 | 6 | BUILD=$(printf "[") 7 | for i in $LIST 8 | do 9 | RESPONSE=$(printf "{\"HOST\":\"$i\",\""; $SCRIPTPATH/api.pl -c summary -a $i -p 4068 | tr -d '\0' | sed -r 's/=/":"/g; s/;/\",\"/g' | sed 's/|/",/g')$(printf "\""; $SCRIPTPATH/api.pl -c pool -a $i -p 4068 | tr -d '\0' | sed -r 's/=/":"/g' | sed -r 's/;/\",\"/g' | sed 's/|/"},/g') 10 | if [[ "$RESPONSE" == *"No Connect"* ]] 11 | then 12 | BUILD=$BUILD"{\"HOST\":\"$i\"}," 13 | else 14 | BUILD=$BUILD$RESPONSE 15 | fi 16 | done 17 | JSON=$(echo $BUILD | tr -d '\r\n' | sed "s/.\{0,2\}$//; /^$/d"; printf "}]") 18 | echo $JSON | jq '[.[] | {HOST,POOL,USER,KHS,DIFF,ACC,REJ,WAIT,UPTIME,TS}]' 19 | --------------------------------------------------------------------------------