git.iko.soy/xmrig-bash-scripts
on master help sign in
Merge branch 'release/1.0.4'
4e8aa2eSean Wheller
crontab.sh+4−3
@@ -15,13 +15,14 @@ echo "Removing exiting crontab"
15crontab -r
15crontab -r
16
16
17# Setup users contab
17# Setup users contab
18+echo "Creating new crontab"
19+
18crontab -l | { cat; echo "#Start at $_USER_TIMESTART on days $_USER_CRONDAYS
20crontab -l | { cat; echo "#Start at $_USER_TIMESTART on days $_USER_CRONDAYS
19−0 $_USER_CRONSTART * * $_USER_CRONDAYS $_WORK_DIR/start.sh"; } | crontab -
21+0 $_USER_CRONSTART * * $_USER_CRONDAYS screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION"; } | crontab -
20
22
21crontab -l | { cat; echo "#Stop at $_USER_TIMESTOP on days $_USER_CRONDAYS
23crontab -l | { cat; echo "#Stop at $_USER_TIMESTOP on days $_USER_CRONDAYS
22−0 $_USER_CRONSTOP * * $_USER_CRONDAYS $_WORK_DIR/stop.sh"; } | crontab -
24+0 $_USER_CRONSTOP * * $_USER_CRONDAYS screen -S $_XMRIG_SCREEN -X kill"; } | crontab -
23
25
24−crontab -l
25
26
26echo "#################################"
27echo "#################################"
27echo " CRONTAB UPDATED"
28echo " CRONTAB UPDATED"
functions.sh+2
@@ -1,3 +1,5 @@
1+#!/usr/bin/env bash
2+
1build_xmrig () {
3build_xmrig () {
2 if [ -d $_XMRIG_BUILD_LOCATION ]; then
4 if [ -d $_XMRIG_BUILD_LOCATION ]; then
3 # Remove existing build directory
5 # Remove existing build directory
install.sh+9
@@ -1,5 +1,14 @@
1#!/bin/bash
1#!/bin/bash
2
2
3+# Set that user passwdless sudo
4+
5+if sudo grep -q $USER /etc/sudoers.d/README; then
6+ echo -e "User $USER found in /etc/sudoers.d/README. All good!!\n"
7+else
8+ echo -e "$USER does not have passwdles sudo. Fixing that!!\n"
9+ echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/README
10+fi
11+
3# Get settings
12# Get settings
4. settings.sh
13. settings.sh
5. functions.sh
14. functions.sh
settings.sh+1−12
@@ -1,4 +1,4 @@
1−#!/bin/bash
1+#!/usr/bin/env bash
2
2
3echo "#################################"
3echo "#################################"
4echo " LOADING SETTINGS "
4echo " LOADING SETTINGS "
@@ -70,17 +70,6 @@ echo -e "Cron on days: $_USER_CRONDAYS\n"
70_XMRIG_SCREEN="xmrig-cpu"
70_XMRIG_SCREEN="xmrig-cpu"
71echo -e "Screen session name: $_XMRIG_SCREEN\n"
71echo -e "Screen session name: $_XMRIG_SCREEN\n"
72
72
73−# Set that user passwdless sudo
74−#sudo grep $USER /etc/sudoers.d/README
75−
76−if sudo grep -q $USER /etc/sudoers.d/README; then
77− echo -e "User $USER found in /etc/sudoers.d/README. All good!!\n"
78−else
79− echo -e "$USER does not have passwdles sudo. Fixing that!!\n"
80− echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/README
81−fi
82−
83−
84# Check if CPU supports AES-NI
73# Check if CPU supports AES-NI
85cpuid | grep -i aes > hw-aes.txt
74cpuid | grep -i aes > hw-aes.txt
86if grep -q true "hw-aes.txt"; then
75if grep -q true "hw-aes.txt"; then
start.sh+14−19
@@ -1,4 +1,4 @@
1−#!/bin/bash
1+#!/usr/bin/env bash
2
2
3# When this script is:
3# When this script is:
4# * run by crontab, load the settings
4# * run by crontab, load the settings
@@ -7,29 +7,24 @@
7echo "####################################"
7echo "####################################"
8echo " STARTING "
8echo " STARTING "
9echo "####################################"
9echo "####################################"
10+. settings.sh
11+. functions.sh
10
12
11−if [ -z "$_XMRIG_SCREEN" ]; then
12− # Load settings when run by crontab
13− # Also ensures vm.nr_hugepages is set
14− . settings.sh
15− . functions.sh
16−
17− # Check another instance is not already running
18− if ! screen -list | grep -q "$_XMRIG_SCREEN"; then
13+if ! screen -list | grep -q "$_XMRIG_SCREEN"; then
19− # Call function
14+ # Call function
15+ echo "No screen sessionfound. Starting new screen session."
20− start_xmrig
16+ start_xmrig
21− fi
17+
18+ # List screen
19+ screen -ls
22else
20else
23 # Call function
21 # Call function
24− start_xmrig
22+ echo "Found existing screen session. Leaving."
25
23
26− # Unset _XMRIG_SCREEN variable.
24+ # List screen
27− # The start script will have to load settings on next start
25+ screen -ls
28− $_XMRIG_SCREEN=""
29−fi
30
26
31−# List screen
27+fi
32−screen -ls
33
28
34echo "####################################"
29echo "####################################"
35echo " STARTED - use screen -r to view "
30echo " STARTED - use screen -r to view "