From 807931db2310d4cbf15cde7a520ae8faf180c865 Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Sat, 27 Jul 2019 12:00:13 +0200 Subject: [PATCH] Enhance script --- CONTRIBUTORS | 0 README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++- build.sh | 34 ------------------------------- depends.sh | 18 +++++++++++++++++ functions.sh | 37 +++++++++++++++++++++++++++++++++ install.sh | 9 +++++++++ maintenance.sh | 18 +++++++++++++++++ settings.sh | 6 ++++++ start.sh | 4 ---- stop.sh | 4 ---- 10 files changed, 142 insertions(+), 43 deletions(-) create mode 100644 CONTRIBUTORS create mode 100755 depends.sh create mode 100755 functions.sh create mode 100755 maintenance.sh diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 9bcc1c7..9238a99 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,55 @@ # xmrig-bash-scripts -Simple collection of bash shell scripts I use to manage xmrig cpu +A simple collection of bash shell scripts to manage installation, update and configuration of [xmrig cpu](https://github.com/xmrig/xmrig) across multiple hosts. + + +## Download +* https://github.com/seanwhe/xmrig-bash-scripts +* Git clone with `git clone https://github.com/seanwhe/xmrig-bash-scripts` + +### Prerequisites + +* Ubuntu Linux (or other Debian-based distribution) +* User account with sudo privileges + +### Installion + +1. Change in to the cloned directory + `cd xmrig-bash-scripts` + +2. Edit the settings file to your preference. + `vim settings.sh` + +3. 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 + +## Viewing mining process +`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. + +## 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). + +## Authors + +* **Sean Wheller** - *Initial work* - [seanwhe](https://github.com/seanwhe) + +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 diff --git a/build.sh b/build.sh index 96cbf9a..16dc2c8 100755 --- a/build.sh +++ b/build.sh @@ -1,43 +1,9 @@ #!/bin/bash -build_xmrig () { - if [ -d $_XMRIG_BUILD_LOCATION ]; then - # Remove existing build directory - echo "Found old build directory. Removing" - rm -rf $_XMRIG_BUILD_LOCATION - - # Make new build directory - echo "Creating a build directory" - mkdir $_XMRIG_BUILD_LOCATION - else - # Make new build directory - echo "Creating a build directory" - mkdir $_XMRIG_BUILD_LOCATION - fi - - # Change to build directory - echo "Changing to build directory" - cd $_XMRIG_BUILD_LOCATION - - # Configure cmake scafolding - echo "Configuring cmake scafolding" - cmake .. -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 - - # Compile the software - echo "Starting build" - make -} - echo "#################################" echo " BUILD STARTING" echo "#################################" -# Update system -sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean - -# Install the software requirements -sudo apt install -y screen software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev gcc g++ - # Clone source if [ -d "$_XMRIG_CLONE_LOCATION" ]; then echo "Clone already exists" diff --git a/depends.sh b/depends.sh new file mode 100755 index 0000000..8491648 --- /dev/null +++ b/depends.sh @@ -0,0 +1,18 @@ +#!/bin/bash +echo "#################################" +echo " INSTALLING DEPENDENCIES " +echo "#################################" + +# Install the software requirements + +if [ $_APT_DEPENDS = 1 ]; then + + sudo apt install -y screen software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev gcc g++ + +else + echo "Depend install is set to NO ($_APT_DEPENDS) Skipping" +fi + +echo "#################################" +echo " DEPENDENCIES INSTALLED " +echo "#################################" diff --git a/functions.sh b/functions.sh new file mode 100755 index 0000000..b492e9a --- /dev/null +++ b/functions.sh @@ -0,0 +1,37 @@ +build_xmrig () { + if [ -d $_XMRIG_BUILD_LOCATION ]; then + # Remove existing build directory + echo "Found old build directory. Removing" + rm -rf $_XMRIG_BUILD_LOCATION + + # Make new build directory + echo "Creating a build directory" + mkdir $_XMRIG_BUILD_LOCATION + else + # Make new build directory + echo "Creating a build directory" + mkdir $_XMRIG_BUILD_LOCATION + fi + + # Change to build directory + echo "Changing to build directory" + cd $_XMRIG_BUILD_LOCATION + + # Configure cmake scafolding + echo "Configuring cmake scafolding" + cmake .. -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 + + # Compile the software + echo "Starting build" + make +} + + +start_xmrig () { + screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION +} + + +stop_xmrig () { + screen -S $_XMRIG_SCREEN -X kill +} diff --git a/install.sh b/install.sh index a8443d6..3d6e6f3 100755 --- a/install.sh +++ b/install.sh @@ -2,11 +2,20 @@ # Get settings . settings.sh +. functions.sh sleep 5 # Stop running instance . stop.sh +# Update system +. maintenance.sh +sleep 5 + +# Install dependencies +. depends.sh +sleep 5 + # Get source and build by sourcing our build file . build.sh sleep 5 diff --git a/maintenance.sh b/maintenance.sh new file mode 100755 index 0000000..98cbc69 --- /dev/null +++ b/maintenance.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +echo "####################################" +echo "# STARTING SYSTEM MAINTENANCE #" +echo "####################################" + +if [ $_APT_MAINETANCE = 1 ]; then + + sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean + +else + echo "Apt maintenance is set to NO ($_APT_MAINETANCE) Skipping" +fi + +echo "####################################" +echo "# SYSTEM MAINTENANCE COMPLETE #" +echo "####################################" + diff --git a/settings.sh b/settings.sh index 7e50abd..7b665f7 100755 --- a/settings.sh +++ b/settings.sh @@ -87,6 +87,12 @@ else echo "vm.nr_hugepages=$_ENV_CORE" | sudo tee -a /etc/sysctl.conf fi +# Run apt maintenance +_APT_MAINETANCE="0" + +# Run install of depends +_APT_DEPENDS="0" + echo "#################################" echo " SETTINGS LOADED" echo "#################################" diff --git a/start.sh b/start.sh index 924cd45..03dda99 100755 --- a/start.sh +++ b/start.sh @@ -4,10 +4,6 @@ # * run by crontab, load the settings # * run by install, do not load settings -start_xmrig () { - screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION -} - echo "####################################" echo " STARTING " echo "####################################" diff --git a/stop.sh b/stop.sh index 35c1fc4..3b9eb57 100755 --- a/stop.sh +++ b/stop.sh @@ -4,10 +4,6 @@ # * run by crontab, load the settings # * run by install, do not load settings -stop_xmrig () { - screen -S $_XMRIG_SCREEN -X kill -} - echo "#################################" echo " KILLING SCREEN" echo "#################################"