Merge branch 'release/v1.0.7'

This commit is contained in:
Sean Wheller 2019-08-11 16:45:34 +02:00
commit edc6f8dfdd
14 changed files with 120 additions and 51 deletions

View File

@ -11,6 +11,7 @@ A set of convenience scripts, written in bash, to help manage installation, conf
There is allot to install so the install script will do most of the heavy lifting.
At the start the expectation is that you have:
* Computer running Ubuntu 18.04 (LTS)
* Bash shell
* User account with sudo privileges
* Installed git
* Optionally installed [xmrig-proxy](https://github.com/xmrig/xmrig-proxy)
@ -21,38 +22,37 @@ Some knowledge of:
* Linux Command Line Interface
* Linux shell `bash`
There is more to install but the install script will install the rest.
### Installation
1. Change to your user home directory.
`cd ~`
2. Install git.
1. Install git.
`sudo apt install git`
3. Clone this project.
1. Clone this project.
`git clone https://github.com/seanwhe/xmrig-bash-scripts`
4. Change into the cloned directory.
1. Change into the cloned directory.
`cd xmrig-bash-scripts`
5. Edit the settings file to your preference.
`vim settings.sh`
6. Run the install script
1. Run the install script
`./install.sh`
7. After install is complete. Attach to the screen session created during the installation.
1. When prompted: "Enter your own settings?" enter 'y'es.
1. Enter values for your:
1. Pool server URL
1. Pool server TCP port
1. Receive wallet address
1. Email address
1. Miner identifier name
1. After install is complete. Attach to the screen session created during the installation.
`screen -r`
### Operation
Defaults - 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.
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.
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.
This should work out the box, if you edit only the top section of `settings.sh` and followed the steps here.
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'.
This should work out the box, if you follow the installation steps and enter your own values for 'mysettings.sh.
Once you have a running xmrig then you can start playing around and tweaking to suite requirements.
@ -67,6 +67,7 @@ The scripts are designed to be modular to promote resuse, execute exclusion and
* crontab-on.sh - redefines the users crontab as created during install.
* depends.sh - installs dependancies required by xmrig and these scripts.
* functions.sh - a collection of functions used in various of the scripts.
* input.sh - prompts to enter values for creating 'mysettings.sh'
* install.sh - the main entry point when first installing.
* maintenance.sh - performs apt update, upgrade, autoremove and autoclean operations.
* settings.sh - contains variables used by these scripts.

View File

@ -1,5 +1,7 @@
#!/bin/bash
echo "${_GREEN}BUILD STARTED${_RESET}"
# Clone source
if [ -d "$_XMRIG_CLONE_LOCATION" ]; then
@ -45,5 +47,5 @@ sudo cp $_XMRIG_BUILD_LOCATION/xmrig $_XMRIG_TARGET_LOCATION
cd $_WORK_DIR
echo "${_GREEN}BUILD COMPLETE${_RESET}"
echo "${_CYAN}BUILD STOPPED${_RESET}"

View File

@ -1,6 +1,8 @@
#!/bin/bash
echo "${_GREEN}CONFIG STARTED${_RESET}"
echo "$_CONFIG_JSON" | tee config.json
echo "${_GREEN}CONFIG CREATED${_RESET}"
echo "${_CYAN}CONFIG STOPPED${_RESET}"

View File

@ -1,5 +1,7 @@
#!/bin/bash
echo "${_GREEN}DISABLE CRONTAB STARTED${_RESET}"
# Removes a user crontab
# Used in conjunction with crontab-on.sh to toggle user crontab between states:
# on - start/stop xmrig at specified times
@ -12,5 +14,5 @@ crontab -l > crontab
echo "Removing exiting crontab"
crontab -r
echo "${_GREEN}CRONTAB DISABLED${_RESET}"
echo "${_CYAN}DISABLE CRONTAB STOPPED${_RESET}"

View File

@ -1,5 +1,7 @@
#!/bin/bash
echo "${_GREEN}ENABLE CRONTAB STARTED${_RESET}"
# Defines a user crontab with schedules as defined in settings.sh
# Used in conjunction with crontab-off.sh to toggle user crontab between states:
# on - start/stop xmrig at specified times
@ -14,5 +16,5 @@ sleep 5
. crontab.sh
sleep 5
echo "${_GREEN}CRONTAB ENABLED${_RESET}"
echo "${_CYAN}ENABLE CRONTAB STOPPED${_RESET}"

View File

@ -1,5 +1,8 @@
#!/bin/bash
echo "${_GREEN}CRONTAB STARTED${_RESET}"
# Set values in settings script
# Remove existing crontab
@ -15,5 +18,5 @@ crontab -l | { cat; echo "#Start at $_USER_TIMESTART on days $_USER_CRONDAYS
crontab -l | { cat; echo "#Stop at $_USER_TIMESTOP on days $_USER_CRONDAYS
0 $_USER_CRONSTOP * * $_USER_CRONDAYS screen -S $_XMRIG_SCREEN -X kill"; } | crontab -
echo "${_GREEN}CRONTAB CREATED${_RESET}"
echo "${_CYAN}CRONTAB STOPPED${_RESET}"

View File

@ -2,6 +2,8 @@
# Install the software requirements
echo "${_GREEN}INSTALL DEPENDS STARTED${_RESET}"
if [ $_APT_DEPENDS = 1 ]; then
# Install xmrig depends
@ -12,4 +14,4 @@ if [ $_APT_DEPENDS = 1 ]; then
fi
echo "${_GREEN}DEPENDENCIES INSTALLED${_RESET}"
echo "${_CYAN}INSTALL DEPENDS STOPPED${_RESET}"

View File

@ -1,5 +1,7 @@
#!/bin/bash
echo -e "${_GREEN}LOADING FUNCTIONS${_RESET}"
function prompt_confirm() {
while true; do
read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY
@ -11,10 +13,20 @@ function prompt_confirm() {
done
}
function show_settings () {
echo "${_CYAN}Settings from loaded environment:${_RESET}"
echo "${_GREEN}Pool URL:${_RESET}: $_POOL_SERVER_URL"
echo "${_GREEN}Pool Port:${_RESET}: $_POOL_SERVER_PORT"
echo "${_GREEN}Recieve Wallet:${_RESET}: $_RECEIVE_WALLET"
echo "${_GREEN}Email Address:${_RESET}: $_EMAIL"
echo "${_GREEN}Worker Identity:${_RESET}: $_API_WORKER_ID"
}
function show_mysettings () {
if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
. $_MYSETTINGS_FILE
echo "${_GREEN}Settings from loaded from mysettings.sh.${_RESET}"
if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
load_mysettings
echo "${_CYAN}Settings from mysettings.sh:${_RESET}"
echo "${_CYAN}Settings loaded:${_RESET}"
echo "${_GREEN}Pool URL:${_RESET}: $_POOL_SERVER_URL"
echo "${_GREEN}Pool Port:${_RESET}: $_POOL_SERVER_PORT"
echo "${_GREEN}Recieve Wallet:${_RESET}: $_RECEIVE_WALLET"
@ -23,6 +35,16 @@ function show_mysettings () {
fi
}
function load_mysettings () {
if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
. $_MYSETTINGS_FILE
fi
}
function my_config_json () {
_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)
}
function build_xmrig () {
if [ -d $_XMRIG_BUILD_LOCATION ]; then
# Remove existing build directory
@ -103,4 +125,4 @@ function calc_hugepages () {
}
echo -e "${_GREEN}FUNCTIONS LOADED${_RESET}"
echo -e "${_CYAN}FUNCTIONS LOADED${_RESET}"

View File

@ -2,23 +2,27 @@
# Ask user questions
# Capture input
. functions.sh
. settings.sh
# if setting already exist use existing
echo -e "${_YELLOW}Choose to use default settings or enter your own.\n"
echo -e "Use defaults and values will be taken from 'settings.sh'."
echo -e "Enter your own and settings will persist to 'mysettings.sh'.\n"
echo -e "Preference is given to settings in 'mysettings.sh'."
echo -e "When starting from 'start.sh' and 'mysettings.sh' exists it will be loaded instead of 'settings.sh'.${_RESET}\n"
echo -e "${_GREEN}USER SETTINGS STARTED${_RESET}"
if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
# Call function
show_mysettings
load_mysettings
my_config_json
else
echo -e " ${_YELLOW}Opt for default settings or enter your own.\n"
echo -e " No - 'config.json' created with values from 'settings.sh'."
echo -e " Yes - 'config.json' created with values from 'mysettings.sh' (recomended).\n"
echo -e " When 'mysettings.sh' exists this prompt will be skipped at furture installation."
echo -e " Own settings is recomended to avoid your settings being overidden in upgrades.${_RESET}\n"
prompt_confirm "Enter your own settings?"
@ -54,7 +58,16 @@ else
echo "_RECEIVE_WALLET=\"$_RECEIVE_WALLET\"" >> $_MYSETTINGS_FILE_LOCATION
echo "_EMAIL=\"$_EMAIL\"" >> $_MYSETTINGS_FILE_LOCATION
echo "_API_WORKER_ID=\"$_API_WORKER_ID\"" >> $_MYSETTINGS_FILE_LOCATION
echo "_POOLS_URL=\"$_POOL_SERVER_URL:$_POOL_SERVER_PORT\"" >> $_MYSETTINGS_FILE_LOCATION
fi
# Call function
load_mysettings
my_config_json
fi
echo "${_CYAN}USER SETTINGS STOPPED${_RESET}"

View File

@ -1,5 +1,17 @@
#!/bin/bash
# Colors
_CYAN=`tput setaf 1`
_GREEN=`tput setaf 2`
_YELLOW=`tput setaf 3`
_BLUE=`tput setaf 4`
_MAGENTA=`tput setaf 5`
_CYAN=`tput setaf 6`
_RESET=`tput sgr0`
echo "${_GREEN}INSTALLATION STARTED${_RESET}"
_DEBUG=$1
if $_DEBUG; then
@ -18,6 +30,7 @@ fi
# Load functions
. functions.sh
sleep 5
# Get settings
. settings.sh
@ -57,4 +70,4 @@ SCREEN=""
. start.sh
echo -e "${_GREEN}INSTALLATION COMPLETE${_RESET}"
echo -e "${_CYAN}INSTALLATION COMPLETED${_RESET}"

View File

@ -1,10 +1,12 @@
#!/bin/bash
echo "${_GREEN}MAINTENANCE STARTED${_RESET}"
if [ $_APT_MAINETANCE = 1 ]; then
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean
fi
echo "${_GREEN}MAINTENANCE COMPLETE${_RESET}"
echo "${_CYAN}MAINTENANCE STOPPED${_RESET}"

View File

@ -1,5 +1,7 @@
#!/bin/bash
echo -e "${_GREEN}LOADING DEFAULT SETTINGS${_RESET}"
_EMAIL="miners@prepaidmeters.com"
_RECEIVE_WALLET="854sqm2Cm4TB2XgPHWqSPSbnFAe3SMzdEDzZHpukQ8NHBPFropbnkFmEKiZPgwjMFC9PTjaFscR2UU6ZwFCqJzGMUiZVbTM"
@ -7,6 +9,9 @@ _RECEIVE_WALLET="854sqm2Cm4TB2XgPHWqSPSbnFAe3SMzdEDzZHpukQ8NHBPFropbnkFmEKiZPgwj
_POOL_SERVER_URL="pool.supportxmr.com"
_POOL_SERVER_PORT="3333"
# Call function
show_settings
#######################################################################
# DO NOT CHANGE AFTER THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING #
#######################################################################
@ -71,8 +76,6 @@ _USER_AGENT="null"
_WATCH="true"
_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)
# Set working directory
_WORK_DIR="$(pwd)"
cd $_WORK_DIR
@ -126,13 +129,6 @@ _APT_MAINETANCE="1"
# 1 = yes 0 = no
_APT_DEPENDS="1"
# Colors
_GREEN=`tput setaf 2`
_YELLOW=`tput setaf 3`
_BLUE=`tput setaf 4`
_MAGENTA=`tput setaf 5`
_CYAN=`tput setaf 6`
_RESET=`tput sgr0`
echo -e "${_GREEN}SETTINGS LOADED${_RESET}"
echo -e "${_CYAN}DEFAULT SETTINGS LOADED${_RESET}"

View File

@ -1,5 +1,7 @@
#!/bin/bash
echo "${_GREEN}MINING STARTED${_RESET}"
# When this script is:
# * run by crontab, load the settings
# * run by install, do not load settings
@ -11,6 +13,7 @@
if ! screen -list | grep -q "$_XMRIG_SCREEN"; then
# Call functions
show_settings
show_mysettings
start_xmrig
@ -23,5 +26,9 @@ else
fi
echo "${_GREEN}MINING STARTED${_RESET}"
echo "${_CYAN}MINING RUNNING${_RESET}"
echo "${_YELLOW} The process is running in a screen session."
echo "${_YELLOW} The screen session is named:${_RESET} $_XMRIG_SCREEN"
echo "${_YELLOW} Command to view process:${_RESET} screen -r $_XMRIG_SCREEN"
echo "${_MAGENTA} ENJOY!!!${_RESET}"

View File

@ -4,6 +4,8 @@
# * run by crontab, load the settings
# * run by install, do not load settings
echo "${_GREEN}END MINING STARTED${_RESET}"
if [ -z "$_XMRIG_SCREEN" ]; then
# Load settings when run by crontab
. settings.sh
@ -16,5 +18,5 @@ else
stop_xmrig
fi
echo "${_GREEN}MINING STOPPED${_RESET}"
echo "${_CYAN}END MINING STOPPED${_RESET}"