git.iko.soy/xmrig-bash-scripts
on 7837c86 help sign in
.gitignore−3
since splitsnapshots
unifiedsplit
@@ -1,7 +1,4 @@
1xmrig-cpu/
1xmrig-cpu/
2*.swp
2*.swp
3crontab
3crontab
4−null
5config.json
4config.json
6−myconfig.json
7−mysettings.sh
README.md+17−18
@@ -11,7 +11,6 @@ A set of convenience scripts, written in bash, to help manage installation, conf
11There is allot to install so the install script will do most of the heavy lifting.
11There is allot to install so the install script will do most of the heavy lifting.
12At the start the expectation is that you have:
12At the start the expectation is that you have:
13* Computer running Ubuntu 18.04 (LTS)
13* Computer running Ubuntu 18.04 (LTS)
14−* Bash shell
15* User account with sudo privileges
14* User account with sudo privileges
16* Installed git
15* Installed git
17* Optionally installed [xmrig-proxy](https://github.com/xmrig/xmrig-proxy)
16* Optionally installed [xmrig-proxy](https://github.com/xmrig/xmrig-proxy)
@@ -22,37 +21,38 @@ Some knowledge of:
22* Linux Command Line Interface
21* Linux Command Line Interface
23* Linux shell `bash`
22* Linux shell `bash`
24
23
24+There is more to install but the install script will install the rest.
25+
25### Installation
26### Installation
26
27
271. Change to your user home directory.
281. Change to your user home directory.
28 `cd ~`
29 `cd ~`
30+
29−1. Install git.
31+2. Install git.
30 `sudo apt install git`
32 `sudo apt install git`
33+
31−1. Clone this project.
34+3. Clone this project.
32 `git clone https://github.com/seanwhe/xmrig-bash-scripts`
35 `git clone https://github.com/seanwhe/xmrig-bash-scripts`
36+
33−1. Change into the cloned directory.
37+4. Change into the cloned directory.
34 `cd xmrig-bash-scripts`
38 `cd xmrig-bash-scripts`
39+
40+5. Edit the settings file to your preference.
41+ `vim settings.sh`
42+
35−1. Run the install script
43+6. Run the install script
36 `./install.sh`
44 `./install.sh`
37−1. When prompted: "Enter your own settings?" enter 'y'es.
45+
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.
46+7. After install is complete. Attach to the screen session created during the installation.
45 `screen -r`
47 `screen -r`
46
48
47### Operation
49### Operation
48
50
49Defaults - 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.
51Defaults - 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.
50
52
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.
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.
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'.
54
54
55−This should work out the box, if you follow the installation steps and enter your own values for 'mysettings.sh.
55+This should work out the box, if you edit only the top section of `settings.sh` and followed the steps here.
56
56
57Once you have a running xmrig then you can start playing around and tweaking to suite requirements.
57Once you have a running xmrig then you can start playing around and tweaking to suite requirements.
58
58
@@ -67,7 +67,6 @@ The scripts are designed to be modular to promote resuse, execute exclusion and
67* crontab-on.sh - redefines the users crontab as created during install.
67* crontab-on.sh - redefines the users crontab as created during install.
68* depends.sh - installs dependancies required by xmrig and these scripts.
68* depends.sh - installs dependancies required by xmrig and these scripts.
69* functions.sh - a collection of functions used in various of the scripts.
69* functions.sh - a collection of functions used in various of the scripts.
70−* input.sh - prompts to enter values for creating 'mysettings.sh'
71* install.sh - the main entry point when first installing.
70* install.sh - the main entry point when first installing.
72* maintenance.sh - performs apt update, upgrade, autoremove and autoclean operations.
71* maintenance.sh - performs apt update, upgrade, autoremove and autoclean operations.
73* settings.sh - contains variables used by these scripts.
72* settings.sh - contains variables used by these scripts.
build.sh+1−3
@@ -1,7 +1,5 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−echo "${_GREEN}BUILD STARTED${_RESET}"
4−
5# Clone source
3# Clone source
6if [ -d "$_XMRIG_CLONE_LOCATION" ]; then
4if [ -d "$_XMRIG_CLONE_LOCATION" ]; then
7
5
@@ -47,5 +45,5 @@ sudo cp $_XMRIG_BUILD_LOCATION/xmrig $_XMRIG_TARGET_LOCATION
47
45
48cd $_WORK_DIR
46cd $_WORK_DIR
49
47
50−echo "${_CYAN}BUILD STOPPED${_RESET}"
48+echo "BUILD COMPLETE"
51
49
config.sh+1−3
@@ -1,8 +1,6 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−echo "${_GREEN}CONFIG STARTED${_RESET}"
4−
5echo "$_CONFIG_JSON" | tee config.json
3echo "$_CONFIG_JSON" | tee config.json
6
4
7−echo "${_CYAN}CONFIG STOPPED${_RESET}"
5+echo "CONFIG CREATED"
8
6
crontab-off.sh+8−3
@@ -1,12 +1,15 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−echo "${_GREEN}DISABLE CRONTAB STARTED${_RESET}"
4−
5# Removes a user crontab
3# Removes a user crontab
6# Used in conjunction with crontab-on.sh to toggle user crontab between states:
4# Used in conjunction with crontab-on.sh to toggle user crontab between states:
7# on - start/stop xmrig at specified times
5# on - start/stop xmrig at specified times
8# off - do not start/stop xmrig
6# off - do not start/stop xmrig
9
7
8+echo "#################################"
9+echo "# DISABLING CRONTAB #"
10+echo "#################################"
11+
12+
10# Remove existing crontab
13# Remove existing crontab
11echo "Backup existing crontab"
14echo "Backup existing crontab"
12crontab -l > crontab
15crontab -l > crontab
@@ -14,5 +17,7 @@ crontab -l > crontab
14echo "Removing exiting crontab"
17echo "Removing exiting crontab"
15crontab -r
18crontab -r
16
19
17−echo "${_CYAN}DISABLE CRONTAB STOPPED${_RESET}"
20+echo "#################################"
21+echo "# CRONTAB DISABLED #"
22+echo "#################################"
18
23
crontab-on.sh+7−3
@@ -1,12 +1,14 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−echo "${_GREEN}ENABLE CRONTAB STARTED${_RESET}"
4−
5# Defines a user crontab with schedules as defined in settings.sh
3# Defines a user crontab with schedules as defined in settings.sh
6# Used in conjunction with crontab-off.sh to toggle user crontab between states:
4# Used in conjunction with crontab-off.sh to toggle user crontab between states:
7# on - start/stop xmrig at specified times
5# on - start/stop xmrig at specified times
8# off - do not start/stop xmrig
6# off - do not start/stop xmrig
9
7
8+echo "####################################"
9+echo "# ENABLING CRONTAB #"
10+echo "####################################"
11+
10# Get settings
12# Get settings
11. settings.sh
13. settings.sh
12. functions.sh
14. functions.sh
@@ -16,5 +18,7 @@ sleep 5
16. crontab.sh
18. crontab.sh
17sleep 5
19sleep 5
18
20
19−echo "${_CYAN}ENABLE CRONTAB STOPPED${_RESET}"
21+echo "####################################"
22+echo "# CRONTAB ENABLED #"
23+echo "####################################"
20
24
crontab.sh+2−5
@@ -1,8 +1,5 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−
4−echo "${_GREEN}CRONTAB STARTED${_RESET}"
5−
6# Set values in settings script
3# Set values in settings script
7
4
8# Remove existing crontab
5# Remove existing crontab
@@ -12,11 +9,11 @@ crontab -r
12
9
13# Setup users contab
10# Setup users contab
14
11
15−crontab -l | { cat; echo "#Start at $_USER_CRONSTART on days $_USER_CRONDAYS
12+crontab -l | { cat; echo "#Start at $_USER_TIMESTART on days $_USER_CRONDAYS
160 $_USER_CRONSTART * * $_USER_CRONDAYS screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION"; } | crontab -
130 $_USER_CRONSTART * * $_USER_CRONDAYS screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION"; } | crontab -
17
14
18crontab -l | { cat; echo "#Stop at $_USER_TIMESTOP on days $_USER_CRONDAYS
15crontab -l | { cat; echo "#Stop at $_USER_TIMESTOP on days $_USER_CRONDAYS
190 $_USER_CRONSTOP * * $_USER_CRONDAYS screen -S $_XMRIG_SCREEN -X kill"; } | crontab -
160 $_USER_CRONSTOP * * $_USER_CRONDAYS screen -S $_XMRIG_SCREEN -X kill"; } | crontab -
20
17
21−echo "${_CYAN}CRONTAB STOPPED${_RESET}"
18+echo "CRONTAB CREATED"
22
19
depends.sh+2−4
@@ -2,9 +2,7 @@
2
2
3# Install the software requirements
3# Install the software requirements
4
4
5−echo "${_GREEN}INSTALL DEPENDS STARTED${_RESET}"
6−
7−if [ "$_APT_DEPENDS" -eq "1" ]; then
5+if [ $_APT_DEPENDS = 1 ]; then
8
6
9 # Install xmrig depends
7 # Install xmrig depends
10 sudo apt install -y software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev libhwloc-dev gcc g++
8 sudo apt install -y software-properties-common git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev libhwloc-dev gcc g++
@@ -14,4 +12,4 @@ if [ "$_APT_DEPENDS" -eq "1" ]; then
14
12
15fi
13fi
16
14
17−echo "${_CYAN}INSTALL DEPENDS STOPPED${_RESET}"
15+echo "DEPENDENCIES INSTALLED"
functions.sh+10−56
@@ -1,48 +1,6 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−echo -e "${_GREEN}LOADING FUNCTIONS${_RESET}"
4−
5−function prompt_confirm() {
6− while true; do
7− read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY
8− case $REPLY in
9− [yY]) echo ; return 0 ;;
10− [nN]) echo ; return 1 ;;
11− *) printf " \033[31m %s \n\033[0m" "invalid input [y/n]"
12− esac
13− done
14−}
15−
16−function show_settings () {
17− echo "${_CYAN}Settings from loaded environment:${_RESET}"
18− echo "${_GREEN}Pool URL:${_RESET}: $_POOLS_URL"
19− echo "${_GREEN}Recieve Wallet:${_RESET}: $_POOLS_USER"
20− echo "${_GREEN}Email Address:${_RESET}: $_POOLS_PASS"
21−}
22−
23−function show_mysettings () {
24− if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
25− load_mysettings
26− echo "${_CYAN}Settings from mysettings.sh:${_RESET}"
27− echo "${_GREEN}Pool URL:${_RESET}: $_POOLS_URL"
28− echo "${_GREEN}Recieve Wallet:${_RESET}: $_POOLS_USER"
29− echo "${_GREEN}Email Address:${_RESET}: $_POOLS_PASS"
30− fi
31−}
32−
33−function load_mysettings () {
34− if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
35− . $_MYSETTINGS_FILE
36− fi
37−}
38−
39−function my_config_json () {
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−
43−}
44−
45−function build_xmrig () {
3+build_xmrig () {
46 if [ -d $_XMRIG_BUILD_LOCATION ]; then
4 if [ -d $_XMRIG_BUILD_LOCATION ]; then
47 # Remove existing build directory
5 # Remove existing build directory
48 rm -rf $_XMRIG_BUILD_LOCATION
6 rm -rf $_XMRIG_BUILD_LOCATION
@@ -58,23 +16,23 @@ function build_xmrig () {
58 cd $_XMRIG_BUILD_LOCATION
16 cd $_XMRIG_BUILD_LOCATION
59
17
60 # Configure cmake scafolding
18 # Configure cmake scafolding
61− cmake ..
19+ cmake .. -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
62
20
63 # Compile the software
21 # Compile the software
64 make
22 make
65}
23}
66
24
67
25
68−function start_xmrig () {
26+start_xmrig () {
69 screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION
27 screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION
70}
28}
71
29
72
30
73−function stop_xmrig () {
31+stop_xmrig () {
74 screen -S $_XMRIG_SCREEN -X kill
32 screen -S $_XMRIG_SCREEN -X kill
75}
33}
76
34
77−function check_cpu () {
35+check_cpu () {
78 # Check if CPU supports AES-NI
36 # Check if CPU supports AES-NI
79 cpuid | grep -i aes > hw-aes.txt
37 cpuid | grep -i aes > hw-aes.txt
80 if grep -q true "hw-aes.txt"; then
38 if grep -q true "hw-aes.txt"; then
@@ -91,20 +49,16 @@ function check_cpu () {
91 _ENV_CORE_L3=$(getconf LEVEL3_CACHE_SIZE)
49 _ENV_CORE_L3=$(getconf LEVEL3_CACHE_SIZE)
92}
50}
93
51
94−function calc_threads () {
52+calc_threads () {
95− # Each thread needs 2048 byte (2 Megabyte)
96− # Calculate number of threads supported with L3 cache size
97−
98− _ENV_THREAD_QTY=$(( ($_ENV_CORE_L3/2048)/1000 ))
99
53
100 # Affine number of threads for _CPU_CN
54 # Affine number of threads for _CPU_CN
101− _COUNTER="$(( $_ENV_THREAD_QTY-1 ))"
55+ _COUNTER="$(( $_ENV_CORE-1 ))"
102
56
103 _ENV_CPU_THREAD_AFFINITY="$(seq -s " " 0 $_COUNTER)"
57 _ENV_CPU_THREAD_AFFINITY="$(seq -s " " 0 $_COUNTER)"
104
58
105}
59}
106
60
107−function calc_hugepages () {
61+calc_hugepages () {
108 # Setting according to cpu cores but xmrig will not use all
62 # Setting according to cpu cores but xmrig will not use all
109 # change to make value use _ENV_CORE_THREADS
63 # change to make value use _ENV_CORE_THREADS
110 # Check that hugepages set in /etc/sysctl.conf
64 # Check that hugepages set in /etc/sysctl.conf
@@ -115,11 +69,11 @@ function calc_hugepages () {
115 sudo sysctl -p
69 sudo sysctl -p
116 else
70 else
117 # Set value in current env
71 # Set value in current env
118− sudo sysctl -w vm.nr_hugepages="$_ENV_THREAD_QTY"
72+ sudo sysctl -w vm.nr_hugepages="$_ENV_CORE"
119 # Add value to sysctl
73 # Add value to sysctl
120 sudo sysctl -p
74 sudo sysctl -p
121 fi
75 fi
122
76
123}
77}
124
78
125−echo -e "${_CYAN}FUNCTIONS LOADED${_RESET}"
79+echo -e "FUNCTIONS LOADED\n\n"
input.shdeleted−61
@@ -1,61 +0,0 @@
1−#!/bin/bash
2−
3−# Ask user questions
4−# Capture input
5−# if setting already exist use existing
6−
7−echo -e "${_GREEN}USER SETTINGS STARTED${_RESET}"
8−
9−if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
10−
11− # Call function
12−
13− load_mysettings
14−
15− my_config_json
16−
17−else
18− echo -e " ${_YELLOW}Opt for default settings or enter your own.\n"
19−
20− echo -e " No - 'config.json' created with values from 'settings.sh'."
21− echo -e " Yes - 'config.json' created with values from 'mysettings.sh' (recomended).\n"
22−
23− echo -e " When 'mysettings.sh' exists this prompt will be skipped at furture installation."
24− echo -e " Own settings is recomended to avoid your settings being overidden in upgrades.${_RESET}\n"
25−
26−
27− prompt_confirm "Enter your own settings?"
28−
29− if [ "$?" -eq 0 ]; then
30−
31− # Create a file
32−
33− touch $_MYSETTINGS_FILE_LOCATION
34− chmod +x $_MYSETTINGS_FILE_LOCATION
35− echo "#!/bin/bash" > $_MYSETTINGS_FILE_LOCATION
36−
37− # Prompt user input
38−
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
42−
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
46−
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
50−
51− fi
52−
53− # Call function
54−
55− load_mysettings
56−
57− my_config_json
58−
59−fi
60−
61−echo "${_CYAN}USER SETTINGS STOPPED${_RESET}"
install.sh+16−22
@@ -1,23 +1,11 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−
4−# Colors
5−_CYAN=`tput setaf 1`
6−_GREEN=`tput setaf 2`
7−_YELLOW=`tput setaf 3`
8−_BLUE=`tput setaf 4`
9−_MAGENTA=`tput setaf 5`
10−_CYAN=`tput setaf 6`
11−_RESET=`tput sgr0`
12−
13−echo "${_GREEN}INSTALLATION STARTED${_RESET}"
14−
15−_DEBUG=$1
3+_DEBUG=true
16
4
17if $_DEBUG; then
5if $_DEBUG; then
18− set +x
19−else
20 set -x
6 set -x
7+else
8+ set +x
21fi
9fi
22
10
23# Set that user passwdless sudo
11# Set that user passwdless sudo
@@ -33,24 +21,30 @@ fi
33
21
34# Get settings
22# Get settings
35. settings.sh
23. settings.sh
24+sleep 5
25+
26+# Stop running instance
27+. stop.sh
36
28
37# Update system
29# Update system
38. maintenance.sh
30. maintenance.sh
31+sleep 5
39
32
40# Install dependencies
33# Install dependencies
41. depends.sh
34. depends.sh
42−
35+sleep 5
43−# User input
44−. input.sh
45−
46−# Stop running instance
47−. stop.sh
48
36
49# Get source and build by sourcing our build file
37# Get source and build by sourcing our build file
50. build.sh
38. build.sh
39+sleep 5
51
40
52# Create a config.json
41# Create a config.json
53. config.sh
42. config.sh
43+sleep 5
44+
45+# Setup crontab for user
46+. crontab.sh
47+sleep 5
54
48
55# Unset REPO variable so start script will execute program
49# Unset REPO variable so start script will execute program
56SCREEN=""
50SCREEN=""
@@ -59,4 +53,4 @@ SCREEN=""
59. start.sh
53. start.sh
60
54
61
55
62−echo -e "${_CYAN}INSTALLATION COMPLETED${_RESET}"
56+echo -e "INSTALLATION COMPLETE\n"
maintenance.sh+2−4
@@ -1,12 +1,10 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−echo "${_GREEN}MAINTENANCE STARTED${_RESET}"
4−
5−if [ "$_APT_MAINETANCE" -eq "1" ]; then
3+if [ $_APT_MAINETANCE = 1 ]; then
6
4
7 sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean
5 sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean
8
6
9fi
7fi
10
8
11−echo "${_CYAN}MAINTENANCE STOPPED${_RESET}"
9+echo "MAINTENANCE COMPLETE"
12
10
settings.sh+18−33
@@ -1,22 +1,17 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−echo -e "${_GREEN}LOADING DEFAULT SETTINGS${_RESET}"
3+_EMAIL="miners@prepaidmeters.com"
4
4
5−_EMAIL="spam@iko.soy"
5+_RECEIVE_WALLET="854sqm2Cm4TB2XgPHWqSPSbnFAe3SMzdEDzZHpukQ8NHBPFropbnkFmEKiZPgwjMFC9PTjaFscR2UU6ZwFCqJzGMUiZVbTM"
6
6
7−_RECEIVE_WALLET="44FADBDhNRvjJszF5mLS4VCwZ71mY7ftfUErEisPoT724hb5eYuvuFqWthniY8dGPBTcWuBoeLrLJVkxLHCb1Lsd4DdbZzZ"
8−
9−_POOL_SERVER_URL="xmrpool.eu"
7+_POOL_SERVER_URL="192.168.4.5"
10−_POOL_SERVER_PORT="5555"
8+_POOL_SERVER_PORT="3333"
11−
12−# Call function
13−show_settings
14
9
15#######################################################################
10#######################################################################
16# DO NOT CHANGE AFTER THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING #
11# DO NOT CHANGE AFTER THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING #
17#######################################################################
12#######################################################################
18
13
19−_API_ID='null'
14+_API_ID="null"
20_API_WORKER_ID="$HOSTNAME"
15_API_WORKER_ID="$HOSTNAME"
21
16
22_AUTOSAVE="true"
17_AUTOSAVE="true"
@@ -34,29 +29,24 @@ calc_threads
34_CPU_ENABLED="true"
29_CPU_ENABLED="true"
35_CPU_HUGE_PAGES="true"
30_CPU_HUGE_PAGES="true"
36_CPU_HW_AES="$_AES_NI"
31_CPU_HW_AES="$_AES_NI"
37−_CPU_PRIORITY='null'
32+_CPU_PRIORITY="null"
38_CPU_ASM="true"
33_CPU_ASM="true"
39_CPU_CN="$_ENV_CPU_THREAD_AFFINITY"
34_CPU_CN="$_ENV_CPU_THREAD_AFFINITY"
40
35
41_CPU_CN_0="false"
36_CPU_CN_0="false"
42_CPU_CN_LITE_0="false"
37_CPU_CN_LITE_0="false"
43
38
44−_OPENCL_ENABLED="false"
45−_OPENCL_CACHE="true"
46−_OPENCL_LOADER='null'
47−_OPENCL_PLATFORM="AMD"
48−
49−_DONATE_LEVEL="0"
39+_DONATE_LEVEL="5"
50
40
51_DONATE_OVER_PROXY="1"
41_DONATE_OVER_PROXY="1"
52
42
53_HTTP_ENABLED="true"
43_HTTP_ENABLED="true"
54_HTTP_HOST=$(hostname --all-ip-addresses | awk '{print $1}')
44_HTTP_HOST=$(hostname --all-ip-addresses | awk '{print $1}')
55_HTTP_PORT="8080"
45_HTTP_PORT="8080"
56−_HTTP_ACCESS_TOKEN='null'
46+_HTTP_ACCESS_TOKEN="null"
57_HTTP_RESTRICTED="false"
47_HTTP_RESTRICTED="false"
58
48
59−_LOG_FILE='null'
49+_LOG_FILE="null"
60
50
61_POOLS_ALGO="cn/r"
51_POOLS_ALGO="cn/r"
62_POOLS_URL="$_POOL_SERVER_URL:$_POOL_SERVER_PORT"
52_POOLS_URL="$_POOL_SERVER_URL:$_POOL_SERVER_PORT"
@@ -66,8 +56,8 @@ _POOLS_RIG_ID="$HOSTNAME"
66_POOLS_NICEHASH="true"
56_POOLS_NICEHASH="true"
67_POOLS_KEEPALIVE="true"
57_POOLS_KEEPALIVE="true"
68_POOLS_ENABLED="true"
58_POOLS_ENABLED="true"
69−_POOLS_TLS='null'
59+_POOLS_TLS="null"
70−_POOLS_TLS_FINDERPRINT='null'
60+_POOLS_TLS_FINDERPRINT="null"
71_POOLS_DAEMON="false"
61_POOLS_DAEMON="false"
72
62
73_PRINT_TIME="30"
63_PRINT_TIME="30"
@@ -77,10 +67,12 @@ _RETRIES_PAUSE="5"
77
67
78_SYSLOG="false"
68_SYSLOG="false"
79
69
80−_USER_AGENT='null'
70+_USER_AGENT="null"
81
71
82_WATCH="true"
72_WATCH="true"
83
73
74+_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)
75+
84# Set working directory
76# Set working directory
85_WORK_DIR="$(pwd)"
77_WORK_DIR="$(pwd)"
86cd $_WORK_DIR
78cd $_WORK_DIR
@@ -95,7 +87,7 @@ _XMRIG_CLONE="xmrig-cpu"
95_XMRIG_CLONE_LOCATION="$_WORK_DIR/$_XMRIG_CLONE"
87_XMRIG_CLONE_LOCATION="$_WORK_DIR/$_XMRIG_CLONE"
96
88
97# Set branch from which to build
89# Set branch from which to build
98−_XMRIG_BRANCH="master"
90+_XMRIG_BRANCH="beta"
99
91
100# Set build directory
92# Set build directory
101_XMRIG_BUILD="build"
93_XMRIG_BUILD="build"
@@ -106,12 +98,6 @@ _XMRIG_BUILD_LOCATION="$_XMRIG_CLONE_LOCATION/$_XMRIG_BUILD"
106# Set where to install binary
98# Set where to install binary
107_XMRIG_TARGET_LOCATION="/usr/bin/"
99_XMRIG_TARGET_LOCATION="/usr/bin/"
108
100
109−# Set mysettings file
110−_MYSETTINGS_FILE="mysettings.sh"
111−
112−# Set mysettings file location
113−_MYSETTINGS_FILE_LOCATION="$_WORK_DIR/$_MYSETTINGS_FILE"
114−
115# Set the config file name
101# Set the config file name
116_XMRIG_CONFIG="config.json"
102_XMRIG_CONFIG="config.json"
117
103
@@ -119,8 +105,8 @@ _XMRIG_CONFIG="config.json"
119_XMRIG_CONFIG_LOCATION="$_WORK_DIR/$_XMRIG_CONFIG"
105_XMRIG_CONFIG_LOCATION="$_WORK_DIR/$_XMRIG_CONFIG"
120
106
121# Set values for crontab
107# Set values for crontab
122−_USER_CRONSTART="17"
108+_USER_CRONSTART="18"
123−_USER_CRONSTOP="8"
109+_USER_CRONSTOP="6"
124_USER_CRONDAYS="1-5"
110_USER_CRONDAYS="1-5"
125
111
126# Set the name of the screen created by start script
112# Set the name of the screen created by start script
@@ -134,6 +120,5 @@ _APT_MAINETANCE="1"
134# 1 = yes 0 = no
120# 1 = yes 0 = no
135_APT_DEPENDS="1"
121_APT_DEPENDS="1"
136
122
137−
138−echo -e "${_CYAN}DEFAULT SETTINGS LOADED${_RESET}"
123+echo -e "SETTINGS LOADED\n\n"
139
124
start.sh+12−45
@@ -1,59 +1,26 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−echo "${_GREEN}MINING STARTED${_RESET}"
4−
5# When this script is:
3# When this script is:
6# * run by crontab, load the settings
4# * run by crontab, load the settings
7# * run by install, do not load settings
5# * run by install, do not load settings
8
6
9# Reload settings and functions for when running standalone
7# Reload settings and functions for when running standalone
10−. functions.sh
11. settings.sh
8. settings.sh
9+. functions.sh
12
10
13−# if ! screen -list | grep -q "$_XMRIG_SCREEN"; then
11+if ! screen -list | grep -q "$_XMRIG_SCREEN"; then
14−
12+
15− # Call functions
13+ # Call function
16− show_settings
17− show_mysettings
18− # start_xmrig
14+ start_xmrig
19
15
20 # List screen
16 # List screen
21− # screen -ls
17+ screen -ls
22−# else
18+else
23
19
24 # List screen
20 # List screen
25− # screen -ls
21+ screen -ls
26−
22+
27−# fi
23+fi
28−echo "[Unit]" | sudo tee /etc/systemd/system/xmrig.service
24+
29−echo "Description=XMRIG service" | sudo tee -a /etc/systemd/system/xmrig.service
25+echo "MINING STARTED"
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
53−
54−echo "${_CYAN}MINING RUNNING${_RESET}"
55−echo "${_YELLOW} The process is running in a screen session."
56−echo "${_YELLOW} The screen session is named:${_RESET} $_XMRIG_SCREEN"
57−echo "${_YELLOW} Command to view process:${_RESET} screen -r $_XMRIG_SCREEN"
58−echo "${_MAGENTA} ENJOY!!!${_RESET}"
59
26
stop.sh+1−3
@@ -4,8 +4,6 @@
4# * run by crontab, load the settings
4# * run by crontab, load the settings
5# * run by install, do not load settings
5# * run by install, do not load settings
6
6
7−echo "${_GREEN}END MINING STARTED${_RESET}"
8−
9if [ -z "$_XMRIG_SCREEN" ]; then
7if [ -z "$_XMRIG_SCREEN" ]; then
10 # Load settings when run by crontab
8 # Load settings when run by crontab
11 . settings.sh
9 . settings.sh
@@ -18,5 +16,5 @@ else
18 stop_xmrig
16 stop_xmrig
19fi
17fi
20
18
21−echo "${_CYAN}END MINING STOPPED${_RESET}"
19+echo "MINING STOPPED"
22
20
update.sh+1−3
@@ -1,11 +1,9 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−echo "${_GREEN}UPDATE STARTED${_RESET}"
4−
5git pull
3git pull
6
4
7# install
5# install
8. install.sh
6. install.sh
9sleep 5
7sleep 5
10
8
11−echo "${_CYAN}UPDATE COMPLETE${_RESET}"
9+echo "UPATE COMPLETE"