git.iko.soy/xmrig-bash-scripts
on master help sign in
Enhance script
commit807931db2310d4cbf15cde7a520ae8faf180c865 authorSean Wheller <sean@prepaidmeters.com> dateSat 27 Jul 2019, 12:00 (7 years ago) parent3cfa2d1
10 files changed+142−43
CONTRIBUTORS README.md+54−1 build.sh−34 depends.sh+18 functions.sh+37 install.sh+9 maintenance.sh+18 settings.sh+6 start.sh−4 stop.sh−4
CONTRIBUTORSnew file

No changes to the content.

README.md+54−1
@@ -1,2 +1,55 @@
11# xmrig-bash-scripts
2−Simple collection of bash shell scripts I use to manage xmrig cpu
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.
3+
4+
5+## Download
6+* https://github.com/seanwhe/xmrig-bash-scripts
7+* Git clone with `git clone https://github.com/seanwhe/xmrig-bash-scripts`
8+
9+### Prerequisites
10+
11+* Ubuntu Linux (or other Debian-based distribution)
12+* User account with sudo privileges
13+
14+### Installion
15+
16+1. Change in to the cloned directory
17+ `cd xmrig-bash-scripts`
18+
19+2. Edit the settings file to your preference.
20+ `vim settings.sh`
21+
22+3. Run the install script
23+ `./install.sh`
24+
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
33+
34+## Viewing mining process
35+`screen -r xmrig-cpu`
36+
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.
38+
39+## Versioning
40+
41+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).
42+
43+## Authors
44+
45+* **Sean Wheller** - *Initial work* - [seanwhe](https://github.com/seanwhe)
46+
47+See also the list of [contributors](https://github.com/seanwhe/xmrig-bash-scripts/CONTRIBUTORS
48+
49+## License
50+
51+This project is licensed under the GNU General Public License v3.0 - see the [LICENSE.md](LICENSE.md) file for details
52+
53+## Acknowledgments
54+
55+* Thanks to [fireice-uk](https://github.com/fireice-uk) for developing and maintaining xmrig
build.sh−34
@@ -1,43 +1,9 @@
11#!/bin/bash
22
3−build_xmrig () {
4− if [ -d $_XMRIG_BUILD_LOCATION ]; then
5− # Remove existing build directory
6− echo "Found old build directory. Removing"
7− rm -rf $_XMRIG_BUILD_LOCATION
8−
9− # Make new build directory
10− echo "Creating a build directory"
11− mkdir $_XMRIG_BUILD_LOCATION
12− else
13− # Make new build directory
14− echo "Creating a build directory"
15− mkdir $_XMRIG_BUILD_LOCATION
16− fi
17−
18− # Change to build directory
19− echo "Changing to build directory"
20− cd $_XMRIG_BUILD_LOCATION
21−
22− # Configure cmake scafolding
23− echo "Configuring cmake scafolding"
24− cmake .. -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
25−
26− # Compile the software
27− echo "Starting build"
28− make
29−}
30−
313echo "#################################"
324echo " BUILD STARTING"
335echo "#################################"
346
35−# Update system
36−sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean
37−
38−# Install the software requirements
39−sudo apt install -y screen software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev gcc g++
40−
417# Clone source
428if [ -d "$_XMRIG_CLONE_LOCATION" ]; then
439 echo "Clone already exists"
depends.shnew file+18
@@ -0,0 +1,18 @@
1+#!/bin/bash
2+echo "#################################"
3+echo " INSTALLING DEPENDENCIES "
4+echo "#################################"
5+
6+# Install the software requirements
7+
8+if [ $_APT_DEPENDS = 1 ]; then
9+
10+ sudo apt install -y screen software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev gcc g++
11+
12+else
13+ echo "Depend install is set to NO ($_APT_DEPENDS) Skipping"
14+fi
15+
16+echo "#################################"
17+echo " DEPENDENCIES INSTALLED "
18+echo "#################################"
functions.shnew file+37
@@ -0,0 +1,37 @@
1+build_xmrig () {
2+ if [ -d $_XMRIG_BUILD_LOCATION ]; then
3+ # Remove existing build directory
4+ echo "Found old build directory. Removing"
5+ rm -rf $_XMRIG_BUILD_LOCATION
6+
7+ # Make new build directory
8+ echo "Creating a build directory"
9+ mkdir $_XMRIG_BUILD_LOCATION
10+ else
11+ # Make new build directory
12+ echo "Creating a build directory"
13+ mkdir $_XMRIG_BUILD_LOCATION
14+ fi
15+
16+ # Change to build directory
17+ echo "Changing to build directory"
18+ cd $_XMRIG_BUILD_LOCATION
19+
20+ # Configure cmake scafolding
21+ echo "Configuring cmake scafolding"
22+ cmake .. -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
23+
24+ # Compile the software
25+ echo "Starting build"
26+ make
27+}
28+
29+
30+start_xmrig () {
31+ screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION
32+}
33+
34+
35+stop_xmrig () {
36+ screen -S $_XMRIG_SCREEN -X kill
37+}
install.sh+9
@@ -2,11 +2,20 @@
22
33# Get settings
44. settings.sh
5+. functions.sh
56sleep 5
67
78# Stop running instance
89. stop.sh
910
11+# Update system
12+. maintenance.sh
13+sleep 5
14+
15+# Install dependencies
16+. depends.sh
17+sleep 5
18+
1019# Get source and build by sourcing our build file
1120. build.sh
1221sleep 5
maintenance.shnew file+18
@@ -0,0 +1,18 @@
1+#!/bin/bash
2+
3+echo "####################################"
4+echo "# STARTING SYSTEM MAINTENANCE #"
5+echo "####################################"
6+
7+if [ $_APT_MAINETANCE = 1 ]; then
8+
9+ sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean
10+
11+else
12+ echo "Apt maintenance is set to NO ($_APT_MAINETANCE) Skipping"
13+fi
14+
15+echo "####################################"
16+echo "# SYSTEM MAINTENANCE COMPLETE #"
17+echo "####################################"
18+
settings.sh+6
@@ -87,6 +87,12 @@ else
8787 echo "vm.nr_hugepages=$_ENV_CORE" | sudo tee -a /etc/sysctl.conf
8888fi
8989
90+# Run apt maintenance
91+_APT_MAINETANCE="0"
92+
93+# Run install of depends
94+_APT_DEPENDS="0"
95+
9096echo "#################################"
9197echo " SETTINGS LOADED"
9298echo "#################################"
start.sh−4
@@ -4,10 +4,6 @@
44# * run by crontab, load the settings
55# * run by install, do not load settings
66
7−start_xmrig () {
8− screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION
9−}
10−
117echo "####################################"
128echo " STARTING "
139echo "####################################"
stop.sh−4
@@ -4,10 +4,6 @@
44# * run by crontab, load the settings
55# * run by install, do not load settings
66
7−stop_xmrig () {
8− screen -S $_XMRIG_SCREEN -X kill
9−}
10−
117echo "#################################"
128echo " KILLING SCREEN"
139echo "#################################"