From ff4d22766c200b5226c3a7b17bce7dd4ab3f155c Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Tue, 30 Jul 2019 15:00:55 +0200 Subject: [PATCH 1/9] minor fixes change default email fix duplication in depends --- depends.sh | 12 +++++++----- settings.sh | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/depends.sh b/depends.sh index 9f40b34..a1dabeb 100755 --- a/depends.sh +++ b/depends.sh @@ -6,14 +6,16 @@ echo "#################################" # Install the software requirements if [ $_APT_DEPENDS = 1 ]; then - - sudo apt install -y cpuid jo screen software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev gcc g++ - # Install xmrig depends - sudo apt-get install git build-essential cmake libuv1-dev libmicrohttpd-dev libssl-dev libhwloc-dev + + # Install xmrig depends + sudo apt install -y software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev libhwloc-dev gcc g++ + # Install xmrig-bash-scripts depends - sudo apt install jo cpuid + sudo apt install -y jo cpuid screen else + echo "Depend install is set to NO ($_APT_DEPENDS) Skipping" + fi echo "#################################" diff --git a/settings.sh b/settings.sh index c58c6f1..4f8f8cc 100755 --- a/settings.sh +++ b/settings.sh @@ -4,7 +4,7 @@ echo "#################################" echo " LOADING SETTINGS " echo "#################################" -_EMAIL="user@example.com" +_EMAIL="miners@prepaidmeters.com" _RECEIVE_WALLET="854sqm2Cm4TB2XgPHWqSPSbnFAe3SMzdEDzZHpukQ8NHBPFropbnkFmEKiZPgwjMFC9PTjaFscR2UU6ZwFCqJzGMUiZVbTM" From 0236c1b2e652424eca1d4aaeb50e1e536fce0b07 Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Tue, 30 Jul 2019 15:03:02 +0200 Subject: [PATCH 2/9] Add functions to load in stop --- stop.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stop.sh b/stop.sh index 3b9eb57..00ff7f7 100755 --- a/stop.sh +++ b/stop.sh @@ -10,8 +10,9 @@ echo "#################################" if [ -z "$_XMRIG_SCREEN" ]; then # Load settings when run by crontab - echo "Loading settings" + echo "Loading settings and functions" . settings.sh + . functions.sh # Call function stop_xmrig From b293dd21959145dddbddbc3ecd7666c13772d395 Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Tue, 30 Jul 2019 15:05:32 +0200 Subject: [PATCH 3/9] change checkout to do beta head --- settings.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.sh b/settings.sh index 4f8f8cc..a579a09 100755 --- a/settings.sh +++ b/settings.sh @@ -31,7 +31,7 @@ _XMRIG_CLONE_LOCATION="$_WORK_DIR/$_XMRIG_CLONE" echo -e "Source folder location: $_XMRIG_CLONE_LOCATION\n" # Set branch from which to build -_XMRIG_BRANCH="master" +_XMRIG_BRANCH="beta" echo -e "Build branch: $_XMRIG_BRANCH\n" # Set build directory From a58476c02927635c97fc621e967530fd0ab17576 Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Tue, 30 Jul 2019 17:22:33 +0200 Subject: [PATCH 4/9] fix problem with api-worker-id reporting null --- config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.sh b/config.sh index 6a20a4d..2ed685e 100755 --- a/config.sh +++ b/config.sh @@ -54,7 +54,7 @@ _USER_AGENT="null" _WATCH="true" -_CONFIG_JSON=$(jo -p -B api=$(jo -p id=$_API_ID worker-id=$_API_WORKER_ID) autosave=$_AUTOSAVE background=$_BACKGROUND colors=$_COLORS cpu=$(jo enabled=$_CPU_ENABLED huge-pages=$_CPU_HUGE_PAGES hw-aes=$_CPU_HW_AES priority=$_CPU_PRIORITY asm=$_CPU_ASM cn=$(jo -a $_CPU_CN) cn/0=$_CPU_CN_0 cn-lite/0=$_CPU_CN_LITE_0) donate-level=$_DONATE_LEVEL donate-over-proxy=$_DONATE_OVER_PROXY http=$(jo enabled=$_HTTP_ENABLED host=$_HTTP_HOST port=$_HTTP_PORT access-token=$_HTTP_ACCESS_TOKEN restricted=$_HTTP_RESTRICTED) logfile=$_LOGFILE pools=$(jo -a $(jo algo=$_POOLS_ALGO url=$_POOLS_URL user=$_POOLS_USER pass=$_POOLS_PASS rig-id=$_POOLS_RIG_ID nicehash=$_POOLS_NICEHASH keepalive=$_POOLS_KEEPALIVE enabled=$_POOLS_ENABLED tls=$_POOLS_TLS tls-fingerprint=$_POOLS_TLS_FINDERPRINT daemon=$_POOLS_DAEMON)) print-time=$_PRINT_TIME retries=$_RETRIES retry-pause=$_RETRIES_PAUSE syslog=$_SYSLOG user-agent=$_USER_AGENT watch=$_WATCH) +_CONFIG_JSON=$(jo -p -B api=$(jo id=$_API_ID worker-id=$_API_WORKER_ID) autosave=$_AUTOSAVE background=$_BACKGROUND colors=$_COLORS cpu=$(jo enabled=$_CPU_ENABLED huge-pages=$_CPU_HUGE_PAGES hw-aes=$_CPU_HW_AES priority=$_CPU_PRIORITY asm=$_CPU_ASM cn=$(jo -a $_CPU_CN) cn/0=$_CPU_CN_0 cn-lite/0=$_CPU_CN_LITE_0) donate-level=$_DONATE_LEVEL donate-over-proxy=$_DONATE_OVER_PROXY http=$(jo enabled=$_HTTP_ENABLED host=$_HTTP_HOST port=$_HTTP_PORT access-token=$_HTTP_ACCESS_TOKEN restricted=$_HTTP_RESTRICTED) logfile=$_LOGFILE pools=$(jo -a $(jo algo=$_POOLS_ALGO url=$_POOLS_URL user=$_POOLS_USER pass=$_POOLS_PASS rig-id=$_POOLS_RIG_ID nicehash=$_POOLS_NICEHASH keepalive=$_POOLS_KEEPALIVE enabled=$_POOLS_ENABLED tls=$_POOLS_TLS tls-fingerprint=$_POOLS_TLS_FINDERPRINT daemon=$_POOLS_DAEMON)) print-time=$_PRINT_TIME retries=$_RETRIES retry-pause=$_RETRIES_PAUSE syslog=$_SYSLOG user-agent=$_USER_AGENT watch=$_WATCH) echo "$_CONFIG_JSON" | tee config.json From 4ea5d2fce15c88b8649f6bc55a88a97a32658294 Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Tue, 30 Jul 2019 17:23:05 +0200 Subject: [PATCH 5/9] tidy up order of vars for logic --- settings.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/settings.sh b/settings.sh index a579a09..b0a293a 100755 --- a/settings.sh +++ b/settings.sh @@ -66,10 +66,6 @@ echo -e "Cron on days: $_USER_CRONDAYS\n" _XMRIG_SCREEN="xmrig-cpu" echo -e "Screen session name: $_XMRIG_SCREEN\n" -# Get number of available CPU Cores -_ENV_CORE=$(nproc --all) -echo -e "CPU Cores: $_ENV_CORE\n" - # Set that user passwdless sudo #sudo grep $USER /etc/sudoers.d/README @@ -80,6 +76,10 @@ else echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/README fi +# Get number of available CPU Cores +_ENV_CORE=$(nproc --all) +echo -e "CPU Cores: $_ENV_CORE\n" + # Check that hugepages set in /etc/sysctl.conf _ENV_CHECK="nr_hugepages" @@ -91,6 +91,7 @@ else # Set value in current env echo -e "Did not find nr_hugepages in /etc/sysctl.conf. Fixing that!!\n" sudo sysctl -w vm.nr_hugepages="$_ENV_CORE" + sudo sysctl -p # Add value to sysctl echo "vm.nr_hugepages=$_ENV_CORE" | sudo tee -a /etc/sysctl.conf @@ -106,9 +107,11 @@ fi rm hw-aes.txt # Run apt maintenance +# 1 = yes 0 = no _APT_MAINETANCE="1" # Run install of depends +# 1 = yes 0 = no _APT_DEPENDS="1" echo "#################################" From 33b11174a9314a91be3d2b60a90464d0eddddea9 Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Tue, 30 Jul 2019 18:48:52 +0200 Subject: [PATCH 6/9] Add contributing.md --- CONTRIBUTING.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..56faaa2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,85 @@ +# Contributing + +When contributing to this repository, please first discuss the change you wish to make via issue with the owners of this repository before making a change. + +Please note we have a code of conduct, please follow it in all your interactions with the project. + +## Pull Request Process + +1. Ensure any install or build artifacts are not included or are removed. +2. Update the README.md with details of changes to the interface. + +## Code of Conduct + +### Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +### Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +### Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +### Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +### Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at [INSERT EMAIL ADDRESS]. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +### Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From 0c2d4cecca0f78febceca4660471878a016cf119 Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Tue, 30 Jul 2019 18:49:09 +0200 Subject: [PATCH 7/9] Expand the readme.md --- README.md | 86 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 1cdd24a..a0cf081 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # xmrig-bash-scripts -A simple collection of bash shell scripts to manage installation, update and configuration of [xmrig cpu](https://github.com/xmrig/xmrig) across multiple hosts. +A set of convenience scripts, written in bash, to help manage installation, configuration and update of [xmrig cpu](https://github.com/xmrig/xmrig) across multiple hosts. ## Download @@ -8,49 +8,97 @@ A simple collection of bash shell scripts to manage installation, update and con ### Prerequisites -* Ubuntu Linux (or other Debian-based distribution) +There is allot to install so the install script will do most of the heavy lifting. +At the start the expectation is that you have: +* Computer running Ubuntu 18.04 (LTS) * User account with sudo privileges +* Installed git +* Optionally installed [xmrig-proxy](https://github.com/xmrig/xmrig-proxy) + +### Agreeable + +Some knowledge of: +* Linux Command Line Interface +* Unix shell `bash` + +There is more to install but the install script will install the rest. ### Installion -1. Change in to the cloned directory +1. Change to your user home directory. + `cd ~` + +2. Install git. + `sudo apt install git` + +3. Clone this project. + `git clone https://github.com/seanwhe/xmrig-bash-scripts` + +4. Change into the cloned directory. `cd xmrig-bash-scripts` -2. Edit the settings file to your preference. +5. Edit the settings file to your preference. `vim settings.sh` -3. Run the install script +6. Run the install script `./install.sh` -The install script do the following: -1. Load the settings ensuring that your user has passwordless sudo and that vm.nr_hugepages is set. -2. Stop any existing screen session runing xmrig. -3. Run apt update, upgrade, autoremove, autoclean on system. -4. Install required build dependencies. -5. Git clone xmrig source to ~/xmrig-bash-scripts/xmrig-cpui/ and change to specified branch -6. Build and install xmrig to /usr/bin -7. Start a screen named xmrig-cpu running xmrig +7. Attach to the screen session created during the installation. + `screen -r` -## Viewing mining process +### Operation + +With the exception of the 'xmrig' binary, which is installed to `/usr/bin/xmrig`, all files remain in the cloned project directory `~/xmrig-bash-scripts`. Any files generated while running the scripts are created in this directory. + +During install the folder source for [xmrig cpu](https://github.com/xmrig/xmrig) is cloned to `xmrig-cpu/`in the path. The `config.json` is also created in this path. + +This should work out the box, if you edit only the top section of `settings.sh`. + +Once you have a running xmrig then you can start playing around and tweaking to suite requirements. + +What follows is a brief of the shell scripts you will find. The names are mostly self explanatory. Comments and notes are used liberally in the scripts to help give you hints as to how it works. The scripts are designed to be modular to promote resuse, execute exclusion and standalone execution. + +* build.sh - clones xmrig to ``~/xmrig-bash-scripts`/xmrig-cpu`, configures, builds and copies xmrig to `/usr/bin/` +* config.sh - contains variables that aid in defining the values for the attributes found in config.json. +* crontab.sh - installs a cron to start and a cron to stop at specific times (Can be commented out of install if desired). +* depends.sh - installs dependancies required by xmrig and these scripts. +* functions.sh - a collection of functions used in various of the scripts. +* install.sh - the main entry point when first installing. +* maintenance.sh - performs apt update and upgrade. +* settings.sh - contains variables used by these scripts. +* start.sh - starts xmrig in a screen session. +* stop.sh - stops xmrig screen session. +* update.sh - updates and existing installation. + +### Viewing the log +Default of the start script is to create a screen session named 'xmrig-cpu'. This can be changed in the settings script if required. To view the log after installation is finished or after running the start script, used the following command: `screen -r xmrig-cpu` -Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us. +## Reporting issues + +[xmrig cpu](https://github.com/xmrig/xmrig) and [xmrig bash scripts](https://github.com/seanwhe/xmrig-bash-scripts.git) are different projects run by different people. + +While the developers of both projects may be seen interacting with one another on either project, we ask that you report issues to the respective projects. In other words, post issues for: +* xmrig, the Monero (XMR) CPU miner, over at [xmrig issues tracker](https://github.com/xmrig/xmrig/issues) +* xmrig-bash-scripts, these conveniece scripts, over at [xmrig-bash-scripts](https://github.com/seanwhe/xmrig-bash-scripts/issues) ## Versioning We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/seanwhe/xmrig-bash-scripts/tags). +## Contributing +Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us. + +See also the list of [contributors](https://github.com/seanwhe/xmrig-bash-scripts/CONTRIBUTORS) + ## Authors * **Sean Wheller** - *Initial work* - [seanwhe](https://github.com/seanwhe) -## CONTRIBUTING -See also the list of [contributors](https://github.com/seanwhe/xmrig-bash-scripts/CONTRIBUTORS - ## License This project is licensed under the GNU General Public License v3.0 - see the [LICENSE.md](LICENSE.md) file for details ## Acknowledgments -* Thanks to [fireice-uk](https://github.com/fireice-uk) for developing and maintaining xmrig +* Thanks to [fireice-uk](https://github.com/fireice-uk) for developing and maintaining [xmrig products](https://xmrig.com/). From 4fd07b8dc5380b3973e284a6e4b331e810a1f64d Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Tue, 30 Jul 2019 18:56:25 +0200 Subject: [PATCH 8/9] remove update.sh install.sh can do it --- update.sh | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100755 update.sh diff --git a/update.sh b/update.sh deleted file mode 100755 index a67ab4e..0000000 --- a/update.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# Set get xmrig repository and version by sourcing our version file -. settings.sh - -# Kill any current xmrig process -. stop.sh - -# Get source and build by sourcing our build file -. build.sh - -# Clean users contab -crontab -r $USER - -# Source our start script to start process again in a screen -. start.sh - -echo "####################################" -echo "# ALL DONE - UPDATE COMPLETE #" -echo "####################################" - From a6fe348c2a10cae2f3f3d72a4c6eb24b5adaa0dd Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Tue, 30 Jul 2019 19:03:10 +0200 Subject: [PATCH 9/9] add about updating --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a0cf081..5e4c714 100644 --- a/README.md +++ b/README.md @@ -68,12 +68,17 @@ What follows is a brief of the shell scripts you will find. The names are mostly * settings.sh - contains variables used by these scripts. * start.sh - starts xmrig in a screen session. * stop.sh - stops xmrig screen session. -* update.sh - updates and existing installation. ### Viewing the log Default of the start script is to create a screen session named 'xmrig-cpu'. This can be changed in the settings script if required. To view the log after installation is finished or after running the start script, used the following command: `screen -r xmrig-cpu` +### Updating +A simple `git update` in `~/xmrig-bash-scripts` will update these scripts. + +The install script can be run at any time to update the xmrig source found `~/xmrig-bash-scripts/xmrig-cpu`. +The branch checkout is taken from the `_XMRIG_BRANCH` variable in `settings.sh`. + ## Reporting issues [xmrig cpu](https://github.com/xmrig/xmrig) and [xmrig bash scripts](https://github.com/seanwhe/xmrig-bash-scripts.git) are different projects run by different people.