git.iko.soy/xmrig-bash-scripts
on master help sign in
Merge branch 'release/1.0.2'
commitcc0f9157bee0670b5c4837b75c72cbb70b6246a7 authorSean Wheller <sean@prepaidmeters.com> dateTue 30 Jul 2019, 19:09 (7 years ago) parentc263081a6fe348
7 files changed+176−53
CONTRIBUTING.md+85 README.md+72−19 config.sh+1−1 depends.sh+7−5 settings.sh+9−6 stop.sh+2−1 update.sh−21
CONTRIBUTING.mdnew file+85
@@ -0,0 +1,85 @@
1+# Contributing
2+
3+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.
4+
5+Please note we have a code of conduct, please follow it in all your interactions with the project.
6+
7+## Pull Request Process
8+
9+1. Ensure any install or build artifacts are not included or are removed.
10+2. Update the README.md with details of changes to the interface.
11+
12+## Code of Conduct
13+
14+### Our Pledge
15+
16+In the interest of fostering an open and welcoming environment, we as
17+contributors and maintainers pledge to making participation in our project and
18+our community a harassment-free experience for everyone, regardless of age, body
19+size, disability, ethnicity, gender identity and expression, level of experience,
20+nationality, personal appearance, race, religion, or sexual identity and
21+orientation.
22+
23+### Our Standards
24+
25+Examples of behavior that contributes to creating a positive environment
26+include:
27+
28+* Using welcoming and inclusive language
29+* Being respectful of differing viewpoints and experiences
30+* Gracefully accepting constructive criticism
31+* Focusing on what is best for the community
32+* Showing empathy towards other community members
33+
34+Examples of unacceptable behavior by participants include:
35+
36+* The use of sexualized language or imagery and unwelcome sexual attention or
37+advances
38+* Trolling, insulting/derogatory comments, and personal or political attacks
39+* Public or private harassment
40+* Publishing others' private information, such as a physical or electronic
41+ address, without explicit permission
42+* Other conduct which could reasonably be considered inappropriate in a
43+ professional setting
44+
45+### Our Responsibilities
46+
47+Project maintainers are responsible for clarifying the standards of acceptable
48+behavior and are expected to take appropriate and fair corrective action in
49+response to any instances of unacceptable behavior.
50+
51+Project maintainers have the right and responsibility to remove, edit, or
52+reject comments, commits, code, wiki edits, issues, and other contributions
53+that are not aligned to this Code of Conduct, or to ban temporarily or
54+permanently any contributor for other behaviors that they deem inappropriate,
55+threatening, offensive, or harmful.
56+
57+### Scope
58+
59+This Code of Conduct applies both within project spaces and in public spaces
60+when an individual is representing the project or its community. Examples of
61+representing a project or community include using an official project e-mail
62+address, posting via an official social media account, or acting as an appointed
63+representative at an online or offline event. Representation of a project may be
64+further defined and clarified by project maintainers.
65+
66+### Enforcement
67+
68+Instances of abusive, harassing, or otherwise unacceptable behavior may be
69+reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
70+complaints will be reviewed and investigated and will result in a response that
71+is deemed necessary and appropriate to the circumstances. The project team is
72+obligated to maintain confidentiality with regard to the reporter of an incident.
73+Further details of specific enforcement policies may be posted separately.
74+
75+Project maintainers who do not follow or enforce the Code of Conduct in good
76+faith may face temporary or permanent repercussions as determined by other
77+members of the project's leadership.
78+
79+### Attribution
80+
81+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
82+available at [http://contributor-covenant.org/version/1/4][version]
83+
84+[homepage]: http://contributor-covenant.org
85+[version]: http://contributor-covenant.org/version/1/4/
README.md+72−19
@@ -1,5 +1,5 @@
11# xmrig-bash-scripts
2−A simple collection of bash shell scripts to manage installation, update and configuration of [xmrig cpu](https://github.com/xmrig/xmrig) across multiple hosts.
2+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.
33
44
55## Download
@@ -8,49 +8,102 @@ A simple collection of bash shell scripts to manage installation, update and con
88
99### Prerequisites
1010
11−* Ubuntu Linux (or other Debian-based distribution)
11+There is allot to install so the install script will do most of the heavy lifting.
12+At the start the expectation is that you have:
13+* Computer running Ubuntu 18.04 (LTS)
1214* User account with sudo privileges
15+* Installed git
16+* Optionally installed [xmrig-proxy](https://github.com/xmrig/xmrig-proxy)
17+
18+### Agreeable
19+
20+Some knowledge of:
21+* Linux Command Line Interface
22+* Unix shell `bash`
23+
24+There is more to install but the install script will install the rest.
1325
1426### Installion
1527
16−1. Change in to the cloned directory
28+1. Change to your user home directory.
29+ `cd ~`
30+
31+2. Install git.
32+ `sudo apt install git`
33+
34+3. Clone this project.
35+ `git clone https://github.com/seanwhe/xmrig-bash-scripts`
36+
37+4. Change into the cloned directory.
1738 `cd xmrig-bash-scripts`
1839
19−2. Edit the settings file to your preference.
40+5. Edit the settings file to your preference.
2041 `vim settings.sh`
2142
22−3. Run the install script
43+6. Run the install script
2344 `./install.sh`
2445
25−The install script do the following:
26−1. Load the settings ensuring that your user has passwordless sudo and that vm.nr_hugepages is set.
27−2. Stop any existing screen session runing xmrig.
28−3. Run apt update, upgrade, autoremove, autoclean on system.
29−4. Install required build dependencies.
30−5. Git clone xmrig source to ~/xmrig-bash-scripts/xmrig-cpui/ and change to specified branch
31−6. Build and install xmrig to /usr/bin
32−7. Start a screen named xmrig-cpu running xmrig
46+7. Attach to the screen session created during the installation.
47+ `screen -r`
48+
49+### Operation
50+
51+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.
52+
53+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.
54+
55+This should work out the box, if you edit only the top section of `settings.sh`.
56+
57+Once you have a running xmrig then you can start playing around and tweaking to suite requirements.
3358
34−## Viewing mining process
59+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.
60+
61+* build.sh - clones xmrig to ``~/xmrig-bash-scripts`/xmrig-cpu`, configures, builds and copies xmrig to `/usr/bin/`
62+* config.sh - contains variables that aid in defining the values for the attributes found in config.json.
63+* crontab.sh - installs a cron to start and a cron to stop at specific times (Can be commented out of install if desired).
64+* depends.sh - installs dependancies required by xmrig and these scripts.
65+* functions.sh - a collection of functions used in various of the scripts.
66+* install.sh - the main entry point when first installing.
67+* maintenance.sh - performs apt update and upgrade.
68+* settings.sh - contains variables used by these scripts.
69+* start.sh - starts xmrig in a screen session.
70+* stop.sh - stops xmrig screen session.
71+
72+### Viewing the log
73+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:
3574`screen -r xmrig-cpu`
3675
37−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.
76+### Updating
77+A simple `git update` in `~/xmrig-bash-scripts` will update these scripts.
78+
79+The install script can be run at any time to update the xmrig source found `~/xmrig-bash-scripts/xmrig-cpu`.
80+The branch checkout is taken from the `_XMRIG_BRANCH` variable in `settings.sh`.
81+
82+## Reporting issues
83+
84+[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.
85+
86+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:
87+* xmrig, the Monero (XMR) CPU miner, over at [xmrig issues tracker](https://github.com/xmrig/xmrig/issues)
88+* xmrig-bash-scripts, these conveniece scripts, over at [xmrig-bash-scripts](https://github.com/seanwhe/xmrig-bash-scripts/issues)
3889
3990## Versioning
4091
4192We 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).
4293
94+## Contributing
95+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.
96+
97+See also the list of [contributors](https://github.com/seanwhe/xmrig-bash-scripts/CONTRIBUTORS)
98+
4399## Authors
44100
45101* **Sean Wheller** - *Initial work* - [seanwhe](https://github.com/seanwhe)
46102
47−## CONTRIBUTING
48−See also the list of [contributors](https://github.com/seanwhe/xmrig-bash-scripts/CONTRIBUTORS
49−
50103## License
51104
52105This project is licensed under the GNU General Public License v3.0 - see the [LICENSE.md](LICENSE.md) file for details
53106
54107## Acknowledgments
55108
56−* Thanks to [fireice-uk](https://github.com/fireice-uk) for developing and maintaining xmrig
109+* Thanks to [fireice-uk](https://github.com/fireice-uk) for developing and maintaining [xmrig products](https://xmrig.com/).
config.sh+1−1
@@ -54,7 +54,7 @@ _USER_AGENT="null"
5454
5555_WATCH="true"
5656
57−_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)
57+_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)
5858
5959echo "$_CONFIG_JSON" | tee config.json
6060
depends.sh+7−5
@@ -6,14 +6,16 @@ echo "#################################"
66# Install the software requirements
77
88if [ $_APT_DEPENDS = 1 ]; then
9−
10− sudo apt install -y cpuid jo screen software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev gcc g++
11− # Install xmrig depends
12− sudo apt-get install git build-essential cmake libuv1-dev libmicrohttpd-dev libssl-dev libhwloc-dev
9+
10+ # Install xmrig depends
11+ sudo apt install -y software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev libhwloc-dev gcc g++
12+
1313 # Install xmrig-bash-scripts depends
14− sudo apt install jo cpuid
14+ sudo apt install -y jo cpuid screen
1515else
16+
1617 echo "Depend install is set to NO ($_APT_DEPENDS) Skipping"
18+
1719fi
1820
1921echo "#################################"
settings.sh+9−6
@@ -4,7 +4,7 @@ echo "#################################"
44echo " LOADING SETTINGS "
55echo "#################################"
66
7−_EMAIL="user@example.com"
7+_EMAIL="miners@prepaidmeters.com"
88
99_RECEIVE_WALLET="854sqm2Cm4TB2XgPHWqSPSbnFAe3SMzdEDzZHpukQ8NHBPFropbnkFmEKiZPgwjMFC9PTjaFscR2UU6ZwFCqJzGMUiZVbTM"
1010
@@ -31,7 +31,7 @@ _XMRIG_CLONE_LOCATION="$_WORK_DIR/$_XMRIG_CLONE"
3131echo -e "Source folder location: $_XMRIG_CLONE_LOCATION\n"
3232
3333# Set branch from which to build
34−_XMRIG_BRANCH="master"
34+_XMRIG_BRANCH="beta"
3535echo -e "Build branch: $_XMRIG_BRANCH\n"
3636
3737# Set build directory
@@ -66,10 +66,6 @@ echo -e "Cron on days: $_USER_CRONDAYS\n"
6666_XMRIG_SCREEN="xmrig-cpu"
6767echo -e "Screen session name: $_XMRIG_SCREEN\n"
6868
69−# Get number of available CPU Cores
70−_ENV_CORE=$(nproc --all)
71−echo -e "CPU Cores: $_ENV_CORE\n"
72−
7369# Set that user passwdless sudo
7470#sudo grep $USER /etc/sudoers.d/README
7571
@@ -80,6 +76,10 @@ else
8076 echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/README
8177fi
8278
79+# Get number of available CPU Cores
80+_ENV_CORE=$(nproc --all)
81+echo -e "CPU Cores: $_ENV_CORE\n"
82+
8383# Check that hugepages set in /etc/sysctl.conf
8484_ENV_CHECK="nr_hugepages"
8585
@@ -91,6 +91,7 @@ else
9191 # Set value in current env
9292 echo -e "Did not find nr_hugepages in /etc/sysctl.conf. Fixing that!!\n"
9393 sudo sysctl -w vm.nr_hugepages="$_ENV_CORE"
94+ sudo sysctl -p
9495
9596 # Add value to sysctl
9697 echo "vm.nr_hugepages=$_ENV_CORE" | sudo tee -a /etc/sysctl.conf
@@ -106,9 +107,11 @@ fi
106107rm hw-aes.txt
107108
108109# Run apt maintenance
110+# 1 = yes 0 = no
109111_APT_MAINETANCE="1"
110112
111113# Run install of depends
114+# 1 = yes 0 = no
112115_APT_DEPENDS="1"
113116
114117echo "#################################"
stop.sh+2−1
@@ -10,8 +10,9 @@ echo "#################################"
1010
1111if [ -z "$_XMRIG_SCREEN" ]; then
1212 # Load settings when run by crontab
13− echo "Loading settings"
13+ echo "Loading settings and functions"
1414 . settings.sh
15+ . functions.sh
1516
1617 # Call function
1718 stop_xmrig
update.shdeleted−21
@@ -1,21 +0,0 @@
1−#!/bin/bash
2−
3−# Set get xmrig repository and version by sourcing our version file
4−. settings.sh
5−
6−# Kill any current xmrig process
7−. stop.sh
8−
9−# Get source and build by sourcing our build file
10−. build.sh
11−
12−# Clean users contab
13−crontab -r $USER
14−
15−# Source our start script to start process again in a screen
16−. start.sh
17−
18−echo "####################################"
19−echo "# ALL DONE - UPDATE COMPLETE #"
20−echo "####################################"
21−