mirror of
https://github.com/ilyakooo0/xmrig-bash-scripts.git
synced 2024-11-22 04:04:22 +03:00
tidup logic
This commit is contained in:
parent
72859d6cb4
commit
42c23ebf14
4
build.sh
4
build.sh
@ -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}"
|
||||
|
||||
|
@ -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}"
|
||||
|
||||
|
@ -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}"
|
||||
|
||||
|
@ -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}"
|
||||
|
||||
|
@ -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}"
|
||||
|
||||
|
@ -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}"
|
||||
|
21
functions.sh
21
functions.sh
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo -e "${_GREEN}FUNCTIONS LOADING${_RESET}"
|
||||
|
||||
function prompt_confirm() {
|
||||
while true; do
|
||||
read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY
|
||||
@ -11,10 +13,9 @@ function prompt_confirm() {
|
||||
done
|
||||
}
|
||||
|
||||
function show_mysettings () {
|
||||
if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
|
||||
. $_MYSETTINGS_FILE
|
||||
echo "${_CYAN}Settings from loaded from mysettings.sh.${_RESET}"
|
||||
function show_settings () {
|
||||
if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
|
||||
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 +24,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 +114,4 @@ function calc_hugepages () {
|
||||
|
||||
}
|
||||
|
||||
echo -e "${_GREEN}FUNCTIONS LOADED${_RESET}"
|
||||
echo -e "${_CYAN}FUNCTIONS LOADED${_RESET}"
|
||||
|
31
input.sh
31
input.sh
@ -2,21 +2,27 @@
|
||||
|
||||
# Ask user questions
|
||||
# Capture input
|
||||
# if setting already exist use existing
|
||||
|
||||
echo -e "${_YELLOW}Opt for default settings or enter your own.\n"
|
||||
|
||||
echo -e "No - values taken from 'settings.sh'."
|
||||
echo -e "Yes - values taken from 'mysettings.sh' (recomended).\n"
|
||||
|
||||
echo -e "When 'mysettings.sh' they are given preference at installation and on subsequence restarts."
|
||||
echo -e "Own settings is recomended to avoid your settings being overidden in upgrades.${_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?"
|
||||
|
||||
@ -52,9 +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 -e "${_GREEN}MYSETTINGS LOADED${_RESET}"
|
||||
echo "${_CYAN}USER SETTINGS STOPPED${_RESET}"
|
||||
|
15
install.sh
15
install.sh
@ -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 STOPPED${_RESET}"
|
||||
|
@ -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}"
|
||||
|
||||
|
16
settings.sh
16
settings.sh
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo -e "${_GREEN}DEFAULT SETTINGS LOADING${_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}"
|
||||
|
||||
|
8
start.sh
8
start.sh
@ -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
|
||||
@ -23,5 +25,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: $_XMRIG_SCREEN"
|
||||
echo "${_YELLOW} To view the process enter 'screen -r $_XMRIG_SCREEN'${_RESET}"
|
||||
echo "${_MAGENTA} ENJOY!!!${_RESET}"
|
||||
|
||||
|
4
stop.sh
4
stop.sh
@ -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}"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user