@@ -1,6 +1,48 @@
3+echo -e "${_GREEN}LOADING FUNCTIONS${_RESET}"
5+function prompt_confirm() {
7+ read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY
9+ [yY]) echo ; return 0 ;;
10+ [nN]) echo ; return 1 ;;
11+ *) printf " \033[31m %s \n\033[0m" "invalid input [y/n]"
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"
23+function show_mysettings () {
24+ if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
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"
33+function load_mysettings () {
34+ if [ -f $_WORK_DIR/$_MYSETTINGS_FILE ]; then
39+function my_config_json () {
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)
3−build_xmrig () {
45+function build_xmrig () {
4 if [ -d $_XMRIG_BUILD_LOCATION ]; then
46 if [ -d $_XMRIG_BUILD_LOCATION ]; then
5 # Remove existing build directory
47 # Remove existing build directory
6 rm -rf $_XMRIG_BUILD_LOCATION
48 rm -rf $_XMRIG_BUILD_LOCATION
@@ -16,23 +58,23 @@ build_xmrig () {
16 cd $_XMRIG_BUILD_LOCATION
58 cd $_XMRIG_BUILD_LOCATION
18 # Configure cmake scafolding
60 # Configure cmake scafolding
19− cmake .. -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
61+ cmake ..
21 # Compile the software
63 # Compile the software
26−start_xmrig () {
68+function start_xmrig () {
27 screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION
69 screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION
31−stop_xmrig () {
73+function stop_xmrig () {
32 screen -S $_XMRIG_SCREEN -X kill
74 screen -S $_XMRIG_SCREEN -X kill
35−check_cpu () {
77+function check_cpu () {
36 # Check if CPU supports AES-NI
78 # Check if CPU supports AES-NI
37 cpuid | grep -i aes > hw-aes.txt
79 cpuid | grep -i aes > hw-aes.txt
38 if grep -q true "hw-aes.txt"; then
80 if grep -q true "hw-aes.txt"; then
@@ -49,33 +91,35 @@ check_cpu () {
49 _ENV_CORE_L3=$(getconf LEVEL3_CACHE_SIZE)
91 _ENV_CORE_L3=$(getconf LEVEL3_CACHE_SIZE)
52−calc_threads () {
94+function calc_threads () {
53−
95+ # Each thread needs 2048 byte (2 Megabyte)
54− # Affine number of threads for _CPU_CN
96+ # Calculate number of threads supported with L3 cache size
55− _COUNTER="$(($_ENV_CORE_THREADS - 1))"
58− for i in `seq 0 $_COUNTER`; do
98+ _ENV_THREAD_QTY=$(( ($_ENV_CORE_L3/2048)/1000 ))
59− _ENV_CPU_THREADS+=("$i")
62− _ENV_CPU_THREAD_AFFINITY="$_ENV_CPU_THREADS"
100+ # Affine number of threads for _CPU_CN
101+ _COUNTER="$(( $_ENV_THREAD_QTY-1 ))"
64− # Setting according to cpu cores but xmrig will not use all
103+ _ENV_CPU_THREAD_AFFINITY="$(seq -s " " 0 $_COUNTER)"
65− # change to make value use _ENV_CORE_THREADS
66− # Check that hugepages set in /etc/sysctl.conf
68− _ENV_CHECK="nr_hugepages"
105+}
107+function calc_hugepages () {
108+ # Setting according to cpu cores but xmrig will not use all
109+ # change to make value use _ENV_CORE_THREADS
110+ # Check that hugepages set in /etc/sysctl.conf
112+ _ENV_CHECK="nr_hugepages"
70− if sudo grep -q $_ENV_CHECK /etc/sysctl.conf; then
114+ if sudo grep -q $_ENV_CHECK /etc/sysctl.conf; then
71− sudo sysctl -p
115+ sudo sysctl -p
73− # Set value in current env
117+ # Set value in current env
74− sudo sysctl -w vm.nr_hugepages="$_ENV_CORE"
118+ sudo sysctl -w vm.nr_hugepages="$_ENV_THREAD_QTY"
75− # Add value to sysctl
119+ # Add value to sysctl
76− sudo sysctl -p
120+ sudo sysctl -p
81−echo -e "FUNCTIONS LOADED\n\n"
125+echo -e "${_CYAN}FUNCTIONS LOADED${_RESET}"