mirror of
https://github.com/ilyakooo0/xmrig-bash-scripts.git
synced 2024-11-26 04:31:39 +03:00
82 lines
1.7 KiB
Bash
Executable File
82 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
build_xmrig () {
|
|
if [ -d $_XMRIG_BUILD_LOCATION ]; then
|
|
# Remove existing build directory
|
|
rm -rf $_XMRIG_BUILD_LOCATION
|
|
|
|
# Make new build directory
|
|
mkdir $_XMRIG_BUILD_LOCATION
|
|
else
|
|
# Make new build directory
|
|
mkdir $_XMRIG_BUILD_LOCATION
|
|
fi
|
|
|
|
# Change to build directory
|
|
cd $_XMRIG_BUILD_LOCATION
|
|
|
|
# Configure cmake scafolding
|
|
cmake .. -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
|
|
|
|
# Compile the software
|
|
make
|
|
}
|
|
|
|
|
|
start_xmrig () {
|
|
screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION
|
|
}
|
|
|
|
|
|
stop_xmrig () {
|
|
screen -S $_XMRIG_SCREEN -X kill
|
|
}
|
|
|
|
check_cpu () {
|
|
# Check if CPU supports AES-NI
|
|
cpuid | grep -i aes > hw-aes.txt
|
|
if grep -q true "hw-aes.txt"; then
|
|
_AES_NI=true
|
|
else
|
|
_AES_NI=false
|
|
fi
|
|
rm hw-aes.txt
|
|
|
|
# Get number of available CPU Cores
|
|
_ENV_CORE=$(nproc --all)
|
|
|
|
# Get CPU L3 cache value
|
|
_ENV_CORE_L3=$(getconf LEVEL3_CACHE_SIZE)
|
|
}
|
|
|
|
calc_threads () {
|
|
|
|
# Affine number of threads for _CPU_CN
|
|
_COUNTER="$(($_ENV_CORE_THREADS - 1))"
|
|
_ENV_CPU_THREADS=()
|
|
|
|
for i in `seq 0 $_COUNTER`; do
|
|
_ENV_CPU_THREADS+=("$i")
|
|
done
|
|
|
|
_ENV_CPU_THREAD_AFFINITY="$_ENV_CPU_THREADS"
|
|
|
|
# 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
|
|
|
|
_ENV_CHECK="nr_hugepages"
|
|
|
|
if sudo grep -q $_ENV_CHECK /etc/sysctl.conf; then
|
|
sudo sysctl -p
|
|
else
|
|
# Set value in current env
|
|
sudo sysctl -w vm.nr_hugepages="$_ENV_CORE"
|
|
# Add value to sysctl
|
|
sudo sysctl -p
|
|
fi
|
|
|
|
}
|
|
|
|
echo -e "FUNCTIONS LOADED\n\n"
|