mirror of
https://github.com/ilyakooo0/xmrig-bash-scripts.git
synced 2024-11-22 12:31:57 +03:00
add mysettings
This commit is contained in:
parent
e75e65ff95
commit
9a6ad6d757
35
functions.sh
35
functions.sh
@ -1,6 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
build_xmrig () {
|
||||
function prompt_confirm() {
|
||||
while true; do
|
||||
read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY
|
||||
case $REPLY in
|
||||
[yY]) echo ; return 0 ;;
|
||||
[nN]) echo ; return 1 ;;
|
||||
*) printf " \033[31m %s \n\033[0m" "invalid input [y/n]"
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
function show_mysettings () {
|
||||
if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
|
||||
. $_MYSETTINGS_FILE
|
||||
echo "${_GREEN}Settings from loaded from mysettings.sh.${_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"
|
||||
fi
|
||||
}
|
||||
|
||||
function build_xmrig () {
|
||||
if [ -d $_XMRIG_BUILD_LOCATION ]; then
|
||||
# Remove existing build directory
|
||||
rm -rf $_XMRIG_BUILD_LOCATION
|
||||
@ -23,16 +46,16 @@ build_xmrig () {
|
||||
}
|
||||
|
||||
|
||||
start_xmrig () {
|
||||
function start_xmrig () {
|
||||
screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION
|
||||
}
|
||||
|
||||
|
||||
stop_xmrig () {
|
||||
function stop_xmrig () {
|
||||
screen -S $_XMRIG_SCREEN -X kill
|
||||
}
|
||||
|
||||
check_cpu () {
|
||||
function check_cpu () {
|
||||
# Check if CPU supports AES-NI
|
||||
cpuid | grep -i aes > hw-aes.txt
|
||||
if grep -q true "hw-aes.txt"; then
|
||||
@ -49,7 +72,7 @@ check_cpu () {
|
||||
_ENV_CORE_L3=$(getconf LEVEL3_CACHE_SIZE)
|
||||
}
|
||||
|
||||
calc_threads () {
|
||||
function calc_threads () {
|
||||
# Each thread needs 2048 byte (2 Megabyte)
|
||||
# Calculate number of threads supported with L3 cache size
|
||||
|
||||
@ -62,7 +85,7 @@ calc_threads () {
|
||||
|
||||
}
|
||||
|
||||
calc_hugepages () {
|
||||
function calc_hugepages () {
|
||||
# Setting according to cpu cores but xmrig will not use all
|
||||
# change to make value use _ENV_CORE_THREADS
|
||||
# Check that hugepages set in /etc/sysctl.conf
|
||||
|
60
input.sh
Executable file
60
input.sh
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Ask user questions
|
||||
# Capture input
|
||||
. functions.sh
|
||||
. settings.sh
|
||||
|
||||
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"
|
||||
|
||||
if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
|
||||
|
||||
# Call function
|
||||
show_mysettings
|
||||
|
||||
else
|
||||
|
||||
prompt_confirm "Enter your own settings?"
|
||||
|
||||
if [ "$?" -eq 0 ]; then
|
||||
|
||||
# Create a file
|
||||
|
||||
touch $_MYSETTINGS_FILE_LOCATION
|
||||
chmod +x $_MYSETTINGS_FILE_LOCATION
|
||||
echo "#!/bin/bash" > $_MYSETTINGS_FILE_LOCATION
|
||||
|
||||
# Prompt user input
|
||||
|
||||
echo "Current pool URL: $_POOL_SERVER_URL"
|
||||
read -p "Enter new pool URL: " _POOL_SERVER_URL
|
||||
|
||||
echo "Current pool TCP Port: $_POOL_SERVER_PORT"
|
||||
read -p "Enter new pool TCP Port: " _POOL_SERVER_PORT
|
||||
|
||||
echo "Current Receive Wallet address: $_RECEIVE_WALLET"
|
||||
read -p "Enter new Receive Wallet address: " _RECEIVE_WALLET
|
||||
|
||||
echo "Current email address: $_EMAIL"
|
||||
read -p "Enter new email address: " _EMAIL
|
||||
|
||||
echo "Current Miner Identifier: $_API_WORKER_ID"
|
||||
read -p "Enter Miner Identifier: " _API_WORKER_ID
|
||||
|
||||
# Write user input to file
|
||||
|
||||
echo "_POOL_SERVER_URL=\"$_POOL_SERVER_URL\"" >> $_MYSETTINGS_FILE_LOCATION
|
||||
echo "_POOL_SERVER_PORT=\"$_POOL_SERVER_PORT\"" >> $_MYSETTINGS_FILE_LOCATION
|
||||
echo "_RECEIVE_WALLET=\"$_RECEIVE_WALLET\"" >> $_MYSETTINGS_FILE_LOCATION
|
||||
echo "_EMAIL=\"$_EMAIL\"" >> $_MYSETTINGS_FILE_LOCATION
|
||||
echo "_API_WORKER_ID=\"$_API_WORKER_ID\"" >> $_MYSETTINGS_FILE_LOCATION
|
||||
|
||||
fi
|
||||
|
||||
fi
|
@ -8,9 +8,6 @@ else
|
||||
set -x
|
||||
fi
|
||||
|
||||
_GREEN=`tput setaf 2`
|
||||
_RESET=`tput sgr0`
|
||||
|
||||
# Set that user passwdless sudo
|
||||
if sudo grep -q $USER /etc/sudoers.d/README; then
|
||||
echo -e "User $USER found in /etc/sudoers.d/README. All good!!\n"
|
||||
@ -26,6 +23,10 @@ fi
|
||||
. settings.sh
|
||||
sleep 5
|
||||
|
||||
# User input
|
||||
. input.sh
|
||||
sleep 5
|
||||
|
||||
# Stop running instance
|
||||
. stop.sh
|
||||
|
||||
|
16
settings.sh
16
settings.sh
@ -4,7 +4,7 @@ _EMAIL="miners@prepaidmeters.com"
|
||||
|
||||
_RECEIVE_WALLET="854sqm2Cm4TB2XgPHWqSPSbnFAe3SMzdEDzZHpukQ8NHBPFropbnkFmEKiZPgwjMFC9PTjaFscR2UU6ZwFCqJzGMUiZVbTM"
|
||||
|
||||
_POOL_SERVER_URL="192.168.4.5"
|
||||
_POOL_SERVER_URL="pool.supportxmr.com"
|
||||
_POOL_SERVER_PORT="3333"
|
||||
|
||||
#######################################################################
|
||||
@ -98,6 +98,12 @@ _XMRIG_BUILD_LOCATION="$_XMRIG_CLONE_LOCATION/$_XMRIG_BUILD"
|
||||
# Set where to install binary
|
||||
_XMRIG_TARGET_LOCATION="/usr/bin/"
|
||||
|
||||
# Set mysettings file
|
||||
_MYSETTINGS_FILE="mysettings.sh"
|
||||
|
||||
# Set mysettings file location
|
||||
_MYSETTINGS_FILE_LOCATION="$_WORK_DIR/$_MYSETTINGS_FILE"
|
||||
|
||||
# Set the config file name
|
||||
_XMRIG_CONFIG="config.json"
|
||||
|
||||
@ -120,5 +126,13 @@ _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}"
|
||||
|
||||
|
5
start.sh
5
start.sh
@ -5,12 +5,13 @@
|
||||
# * run by install, do not load settings
|
||||
|
||||
# Reload settings and functions for when running standalone
|
||||
. settings.sh
|
||||
. functions.sh
|
||||
. settings.sh
|
||||
|
||||
if ! screen -list | grep -q "$_XMRIG_SCREEN"; then
|
||||
|
||||
# Call function
|
||||
# Call functions
|
||||
show_mysettings
|
||||
start_xmrig
|
||||
|
||||
# List screen
|
||||
|
Loading…
Reference in New Issue
Block a user