git.iko.soy/xmrig-bash-scripts
on master help sign in
11 files changed+102−94
since splitsnapshots
unifiedsplit
.gitignore+1 README.md+18−17 crontab.sh+1−1 depends.sh+1−1 functions.sh+10−13 input.sh+9−21 install.sh+6−17 maintenance.sh+1−1 settings.sh+20−15 start.sh+32−7 update.sh+3−1
.gitignore+1
@@ -1,6 +1,7 @@
11xmrig-cpu/
22*.swp
33crontab
4+null
45config.json
56myconfig.json
67mysettings.sh
README.md+18−17
@@ -11,6 +11,7 @@ A set of convenience scripts, written in bash, to help manage installation, conf
1111There is allot to install so the install script will do most of the heavy lifting.
1212At the start the expectation is that you have:
1313* Computer running Ubuntu 18.04 (LTS)
14+* Bash shell
1415* User account with sudo privileges
1516* Installed git
1617* Optionally installed [xmrig-proxy](https://github.com/xmrig/xmrig-proxy)
@@ -21,38 +22,37 @@ Some knowledge of:
2122* Linux Command Line Interface
2223* Linux shell `bash`
2324
24−There is more to install but the install script will install the rest.
25−
2625### Installation
2726
28271. Change to your user home directory.
2928 `cd ~`
30−
31−2. Install git.
29+1. Install git.
3230 `sudo apt install git`
33−
34−3. Clone this project.
31+1. Clone this project.
3532 `git clone https://github.com/seanwhe/xmrig-bash-scripts`
36−
37−4. Change into the cloned directory.
33+1. Change into the cloned directory.
3834 `cd xmrig-bash-scripts`
39−
40−5. Edit the settings file to your preference.
41− `vim settings.sh`
42−
43−6. Run the install script
35+1. Run the install script
4436 `./install.sh`
45−
46−7. After install is complete. Attach to the screen session created during the installation.
37+1. When prompted: "Enter your own settings?" enter 'y'es.
38+1. Enter values for your:
39+ 1. Pool server URL
40+ 1. Pool server TCP port
41+ 1. Receive wallet address
42+ 1. Email address
43+ 1. Miner identifier name
44+1. After install is complete. Attach to the screen session created during the installation.
4745 `screen -r`
4846
4947### Operation
5048
5149Defaults - The settings.sh contains a number of variables. 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 also created in this directory.
5250
53−During install the folder source for [xmrig cpu](https://github.com/xmrig/xmrig) is cloned to `~/xmrig-bash-scripts/xmrig-cpu/`. The `config.json` is also created in this path.
51+During install the folder source for [xmrig cpu](https://github.com/xmrig/xmrig) is cloned to `~/xmrig-bash-scripts/xmrig-cpu/`. The file `config.json`, used to configure xmrig, is also created in this path and is passed to xmrig at startup.
52+
53+During installation it is recomended to enter your own settings. This creates a file named 'mysettings.sh' which will not be overwritten during future installs or upgrades. Values for variables found in 'mysettings.sh' are used to create 'config.json'.
5454
55−This should work out the box, if you edit only the top section of `settings.sh` and followed the steps here.
55+This should work out the box, if you follow the installation steps and enter your own values for 'mysettings.sh.
5656
5757Once you have a running xmrig then you can start playing around and tweaking to suite requirements.
5858
@@ -67,6 +67,7 @@ The scripts are designed to be modular to promote resuse, execute exclusion and
6767* crontab-on.sh - redefines the users crontab as created during install.
6868* depends.sh - installs dependancies required by xmrig and these scripts.
6969* functions.sh - a collection of functions used in various of the scripts.
70+* input.sh - prompts to enter values for creating 'mysettings.sh'
7071* install.sh - the main entry point when first installing.
7172* maintenance.sh - performs apt update, upgrade, autoremove and autoclean operations.
7273* settings.sh - contains variables used by these scripts.
crontab.sh+1−1
@@ -12,7 +12,7 @@ crontab -r
1212
1313# Setup users contab
1414
15−crontab -l | { cat; echo "#Start at $_USER_TIMESTART on days $_USER_CRONDAYS
15+crontab -l | { cat; echo "#Start at $_USER_CRONSTART on days $_USER_CRONDAYS
16160 $_USER_CRONSTART * * $_USER_CRONDAYS screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION"; } | crontab -
1717
1818crontab -l | { cat; echo "#Stop at $_USER_TIMESTOP on days $_USER_CRONDAYS
depends.sh+1−1
@@ -4,7 +4,7 @@
44
55echo "${_GREEN}INSTALL DEPENDS STARTED${_RESET}"
66
7−if [ $_APT_DEPENDS = 1 ]; then
7+if [ "$_APT_DEPENDS" -eq "1" ]; then
88
99 # Install xmrig depends
1010 sudo apt install -y software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev libhwloc-dev gcc g++
functions.sh+10−13
@@ -15,23 +15,18 @@ function prompt_confirm() {
1515
1616function show_settings () {
1717 echo "${_CYAN}Settings from loaded environment:${_RESET}"
18− echo "${_GREEN}Pool URL:${_RESET}: $_POOL_SERVER_URL"
19− echo "${_GREEN}Pool Port:${_RESET}: $_POOL_SERVER_PORT"
20− echo "${_GREEN}Recieve Wallet:${_RESET}: $_RECEIVE_WALLET"
21− echo "${_GREEN}Email Address:${_RESET}: $_EMAIL"
22− echo "${_GREEN}Worker Identity:${_RESET}: $_API_WORKER_ID"
18+ echo "${_GREEN}Pool URL:${_RESET}: $_POOLS_URL"
19+ echo "${_GREEN}Recieve Wallet:${_RESET}: $_POOLS_USER"
20+ echo "${_GREEN}Email Address:${_RESET}: $_POOLS_PASS"
2321}
2422
2523function show_mysettings () {
2624 if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
2725 load_mysettings
2826 echo "${_CYAN}Settings from mysettings.sh:${_RESET}"
29− echo "${_CYAN}Settings loaded:${_RESET}"
30− echo "${_GREEN}Pool URL:${_RESET}: $_POOL_SERVER_URL"
31− echo "${_GREEN}Pool Port:${_RESET}: $_POOL_SERVER_PORT"
32− echo "${_GREEN}Recieve Wallet:${_RESET}: $_RECEIVE_WALLET"
33− echo "${_GREEN}Email Address:${_RESET}: $_EMAIL"
34− echo "${_GREEN}Worker Identity:${_RESET}: $_API_WORKER_ID"
27+ echo "${_GREEN}Pool URL:${_RESET}: $_POOLS_URL"
28+ echo "${_GREEN}Recieve Wallet:${_RESET}: $_POOLS_USER"
29+ echo "${_GREEN}Email Address:${_RESET}: $_POOLS_PASS"
3530 fi
3631}
3732
@@ -42,7 +37,9 @@ function load_mysettings () {
4237}
4338
4439function my_config_json () {
45− _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)
40+
41+ _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) opencl=$(jo enabled=$_OPENCL_ENABLED cache=$_OPENCL_CACHE loader=$_OPENCL_LOADER platform=$_OPENCL_PLATFORM) 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) log-file=$_LOG_FILE 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)
42+
4643}
4744
4845function build_xmrig () {
@@ -61,7 +58,7 @@ function build_xmrig () {
6158 cd $_XMRIG_BUILD_LOCATION
6259
6360 # Configure cmake scafolding
64− cmake .. -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
61+ cmake ..
6562
6663 # Compile the software
6764 make
input.sh+9−21
@@ -36,29 +36,17 @@ else
3636
3737 # Prompt user input
3838
39− echo "Current pool URL: $_POOL_SERVER_URL"
40− read -p "Enter new pool URL: " _POOL_SERVER_URL
39+ echo "Current pool URL: $_POOLS_URL"
40+ read -p "Enter new pool URL: " _POOLS_URL
41+ echo "_POOLS_URL=\"$_POOLS_URL\"" >> $_MYSETTINGS_FILE_LOCATION
4142
42− echo "Current pool TCP Port: $_POOL_SERVER_PORT"
43− read -p "Enter new pool TCP Port: " _POOL_SERVER_PORT
43+ echo "Current Receive Wallet address: $_POOLS_USER"
44+ read -p "Enter new Receive Wallet address: " _POOLS_USER
45+ echo "_POOLS_USER=\"$_POOLS_USER\"" >> $_MYSETTINGS_FILE_LOCATION
4446
45− echo "Current Receive Wallet address: $_RECEIVE_WALLET"
46− read -p "Enter new Receive Wallet address: " _RECEIVE_WALLET
47−
48− echo "Current email address: $_EMAIL"
49− read -p "Enter new email address: " _EMAIL
50−
51− echo "Current Miner Identifier: $_API_WORKER_ID"
52− read -p "Enter Miner Identifier: " _API_WORKER_ID
53−
54− # Write user input to file
55−
56− echo "_POOL_SERVER_URL=\"$_POOL_SERVER_URL\"" >> $_MYSETTINGS_FILE_LOCATION
57− echo "_POOL_SERVER_PORT=\"$_POOL_SERVER_PORT\"" >> $_MYSETTINGS_FILE_LOCATION
58− echo "_RECEIVE_WALLET=\"$_RECEIVE_WALLET\"" >> $_MYSETTINGS_FILE_LOCATION
59− echo "_EMAIL=\"$_EMAIL\"" >> $_MYSETTINGS_FILE_LOCATION
60− echo "_API_WORKER_ID=\"$_API_WORKER_ID\"" >> $_MYSETTINGS_FILE_LOCATION
61− echo "_POOLS_URL=\"$_POOL_SERVER_URL:$_POOL_SERVER_PORT\"" >> $_MYSETTINGS_FILE_LOCATION
47+ echo "Current email address: $_POOLS_PASS"
48+ read -p "Enter new email address: " _POOLS_PASS
49+ echo "_POOLS_PASS=\"$_POOLS_PASS\"" >> $_MYSETTINGS_FILE_LOCATION
6250
6351 fi
6452
install.sh+6−17
@@ -30,38 +30,27 @@ fi
3030
3131# Load functions
3232. functions.sh
33−sleep 5
3433
3534# Get settings
3635. settings.sh
37−sleep 5
38−
39−# User input
40−. input.sh
41−sleep 5
42−
43−# Stop running instance
44−. stop.sh
4536
4637# Update system
4738. maintenance.sh
48−sleep 5
4939
5040# Install dependencies
5141. depends.sh
52−sleep 5
42+
43+# User input
44+. input.sh
45+
46+# Stop running instance
47+. stop.sh
5348
5449# Get source and build by sourcing our build file
5550. build.sh
56−sleep 5
5751
5852# Create a config.json
5953. config.sh
60−sleep 5
61−
62−# Setup crontab for user
63−. crontab.sh
64−sleep 5
6554
6655# Unset REPO variable so start script will execute program
6756SCREEN=""
maintenance.sh+1−1
@@ -2,7 +2,7 @@
22
33echo "${_GREEN}MAINTENANCE STARTED${_RESET}"
44
5−if [ $_APT_MAINETANCE = 1 ]; then
5+if [ "$_APT_MAINETANCE" -eq "1" ]; then
66
77 sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean
88
settings.sh+20−15
@@ -2,12 +2,12 @@
22
33echo -e "${_GREEN}LOADING DEFAULT SETTINGS${_RESET}"
44
5−_EMAIL="miners@prepaidmeters.com"
5+_EMAIL="spam@iko.soy"
66
7−_RECEIVE_WALLET="854sqm2Cm4TB2XgPHWqSPSbnFAe3SMzdEDzZHpukQ8NHBPFropbnkFmEKiZPgwjMFC9PTjaFscR2UU6ZwFCqJzGMUiZVbTM"
7+_RECEIVE_WALLET="44FADBDhNRvjJszF5mLS4VCwZ71mY7ftfUErEisPoT724hb5eYuvuFqWthniY8dGPBTcWuBoeLrLJVkxLHCb1Lsd4DdbZzZ"
88
9−_POOL_SERVER_URL="pool.supportxmr.com"
10−_POOL_SERVER_PORT="3333"
9+_POOL_SERVER_URL="xmrpool.eu"
10+_POOL_SERVER_PORT="5555"
1111
1212# Call function
1313show_settings
@@ -16,7 +16,7 @@ show_settings
1616# DO NOT CHANGE AFTER THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING #
1717#######################################################################
1818
19−_API_ID="null"
19+_API_ID='null'
2020_API_WORKER_ID="$HOSTNAME"
2121
2222_AUTOSAVE="true"
@@ -34,24 +34,29 @@ calc_threads
3434_CPU_ENABLED="true"
3535_CPU_HUGE_PAGES="true"
3636_CPU_HW_AES="$_AES_NI"
37−_CPU_PRIORITY="null"
37+_CPU_PRIORITY='null'
3838_CPU_ASM="true"
3939_CPU_CN="$_ENV_CPU_THREAD_AFFINITY"
4040
4141_CPU_CN_0="false"
4242_CPU_CN_LITE_0="false"
4343
44−_DONATE_LEVEL="5"
44+_OPENCL_ENABLED="false"
45+_OPENCL_CACHE="true"
46+_OPENCL_LOADER='null'
47+_OPENCL_PLATFORM="AMD"
48+
49+_DONATE_LEVEL="0"
4550
4651_DONATE_OVER_PROXY="1"
4752
4853_HTTP_ENABLED="true"
4954_HTTP_HOST=$(hostname --all-ip-addresses | awk '{print $1}')
5055_HTTP_PORT="8080"
51−_HTTP_ACCESS_TOKEN="null"
56+_HTTP_ACCESS_TOKEN='null'
5257_HTTP_RESTRICTED="false"
5358
54−_LOG_FILE="null"
59+_LOG_FILE='null'
5560
5661_POOLS_ALGO="cn/r"
5762_POOLS_URL="$_POOL_SERVER_URL:$_POOL_SERVER_PORT"
@@ -61,8 +66,8 @@ _POOLS_RIG_ID="$HOSTNAME"
6166_POOLS_NICEHASH="true"
6267_POOLS_KEEPALIVE="true"
6368_POOLS_ENABLED="true"
64−_POOLS_TLS="null"
65−_POOLS_TLS_FINDERPRINT="null"
69+_POOLS_TLS='null'
70+_POOLS_TLS_FINDERPRINT='null'
6671_POOLS_DAEMON="false"
6772
6873_PRINT_TIME="30"
@@ -72,7 +77,7 @@ _RETRIES_PAUSE="5"
7277
7378_SYSLOG="false"
7479
75−_USER_AGENT="null"
80+_USER_AGENT='null'
7681
7782_WATCH="true"
7883
@@ -90,7 +95,7 @@ _XMRIG_CLONE="xmrig-cpu"
9095_XMRIG_CLONE_LOCATION="$_WORK_DIR/$_XMRIG_CLONE"
9196
9297# Set branch from which to build
93−_XMRIG_BRANCH="beta"
98+_XMRIG_BRANCH="master"
9499
95100# Set build directory
96101_XMRIG_BUILD="build"
@@ -114,8 +119,8 @@ _XMRIG_CONFIG="config.json"
114119_XMRIG_CONFIG_LOCATION="$_WORK_DIR/$_XMRIG_CONFIG"
115120
116121# Set values for crontab
117−_USER_CRONSTART="18"
118−_USER_CRONSTOP="6"
122+_USER_CRONSTART="17"
123+_USER_CRONSTOP="8"
119124_USER_CRONDAYS="1-5"
120125
121126# Set the name of the screen created by start script
start.sh+32−7
@@ -10,21 +10,46 @@ echo "${_GREEN}MINING STARTED${_RESET}"
1010. functions.sh
1111. settings.sh
1212
13−if ! screen -list | grep -q "$_XMRIG_SCREEN"; then
13+# if ! screen -list | grep -q "$_XMRIG_SCREEN"; then
1414
1515 # Call functions
1616 show_settings
1717 show_mysettings
18− start_xmrig
18+ # start_xmrig
1919
2020 # List screen
21− screen -ls
22−else
21+ # screen -ls
22+# else
2323
2424 # List screen
25− screen -ls
26−
27−fi
25+ # screen -ls
26+
27+# fi
28+echo "[Unit]" | sudo tee /etc/systemd/system/xmrig.service
29+echo "Description=XMRIG service" | sudo tee -a /etc/systemd/system/xmrig.service
30+echo "After=network.target" | sudo tee -a /etc/systemd/system/xmrig.service
31+echo "StartLimitIntervalSec=0" | sudo tee -a /etc/systemd/system/xmrig.service
32+echo "[Service]" | sudo tee -a /etc/systemd/system/xmrig.service
33+echo "Type=simple" | sudo tee -a /etc/systemd/system/xmrig.service
34+echo "Restart=always" | sudo tee -a /etc/systemd/system/xmrig.service
35+echo "RestartSec=3" | sudo tee -a /etc/systemd/system/xmrig.service
36+echo "User=root" | sudo tee -a /etc/systemd/system/xmrig.service
37+echo "ExecStart=$_XMRIG_BUILD_LOCATION/xmrig --config=$_XMRIG_CONFIG_LOCATION" | sudo tee -a /etc/systemd/system/xmrig.service
38+echo "" | sudo tee -a /etc/systemd/system/xmrig.service
39+echo "[Install]" | sudo tee -a /etc/systemd/system/xmrig.service
40+echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/xmrig.service
41+
42+echo "STARTING XMRIG/SERVICES"
43+
44+sudo service logrotate start
45+sudo service ntp start
46+sudo service xmrig start
47+
48+echo "STARTING XMRIG/SERVICES @ BOOT"
49+
50+sudo systemctl enable logrotate
51+sudo systemctl enable ntp
52+sudo systemctl enable xmrig
2853
2954echo "${_CYAN}MINING RUNNING${_RESET}"
3055echo "${_YELLOW} The process is running in a screen session."
update.sh+3−1
@@ -1,9 +1,11 @@
11#!/bin/bash
22
3+echo "${_GREEN}UPDATE STARTED${_RESET}"
4+
35git pull
46
57# install
68. install.sh
79sleep 5
810
9−echo "${_GREEN}UPDATE COMPLETE${_RESET}"
11+echo "${_CYAN}UPDATE COMPLETE${_RESET}"