mirror of
https://github.com/ilyakooo0/xmrig-bash-scripts.git
synced 2024-11-22 04:04:22 +03:00
Fix crontab
This commit is contained in:
parent
9b5730d61c
commit
2d34d17106
11
crontab.sh
11
crontab.sh
@ -14,19 +14,16 @@ crontab -l > crontab
|
||||
echo "Removing exiting crontab"
|
||||
crontab -r
|
||||
|
||||
# Define env path
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/games:/snap/bin:/bin/:$_WORK_DIR
|
||||
|
||||
# Setup users contab
|
||||
echo "Creating new crontab"
|
||||
|
||||
crontab -l | { cat; echo "#Start at $_USER_TIMESTART on days $_USER_CRONDAYS
|
||||
0 $_USER_CRONSTART * * $_USER_CRONDAYS bash start.sh"; } | crontab -
|
||||
0 $_USER_CRONSTART * * $_USER_CRONDAYS screen -dmS $_XMRIG_SCREEN xmrig --config=$_XMRIG_CONFIG_LOCATION"; } | crontab -
|
||||
|
||||
crontab -l | { cat; echo "#Stop at $_USER_TIMESTOP on days $_USER_CRONDAYS
|
||||
0 $_USER_CRONSTOP * * $_USER_CRONDAYS bash stop.sh"; } | crontab -
|
||||
0 $_USER_CRONSTOP * * $_USER_CRONDAYS screen -S $_XMRIG_SCREEN -X kill"; } | crontab -
|
||||
|
||||
|
||||
crontab -l
|
||||
|
||||
echo "#################################"
|
||||
echo " CRONTAB UPDATED"
|
||||
echo "#################################"
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
build_xmrig () {
|
||||
if [ -d $_XMRIG_BUILD_LOCATION ]; then
|
||||
# Remove existing build directory
|
||||
|
@ -1,5 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 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"
|
||||
else
|
||||
echo -e "$USER does not have passwdles sudo. Fixing that!!\n"
|
||||
echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/README
|
||||
fi
|
||||
|
||||
# Get settings
|
||||
. settings.sh
|
||||
. functions.sh
|
||||
|
11
settings.sh
11
settings.sh
@ -70,17 +70,6 @@ echo -e "Cron on days: $_USER_CRONDAYS\n"
|
||||
_XMRIG_SCREEN="xmrig-cpu"
|
||||
echo -e "Screen session name: $_XMRIG_SCREEN\n"
|
||||
|
||||
# Set that user passwdless sudo
|
||||
#sudo grep $USER /etc/sudoers.d/README
|
||||
|
||||
if sudo grep -q $USER /etc/sudoers.d/README; then
|
||||
echo -e "User $USER found in /etc/sudoers.d/README. All good!!\n"
|
||||
else
|
||||
echo -e "$USER does not have passwdles sudo. Fixing that!!\n"
|
||||
echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/README
|
||||
fi
|
||||
|
||||
|
||||
# Check if CPU supports AES-NI
|
||||
cpuid | grep -i aes > hw-aes.txt
|
||||
if grep -q true "hw-aes.txt"; then
|
||||
|
35
start.sh
35
start.sh
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# When this script is:
|
||||
# * run by crontab, load the settings
|
||||
@ -7,29 +7,24 @@
|
||||
echo "####################################"
|
||||
echo " STARTING "
|
||||
echo "####################################"
|
||||
. settings.sh
|
||||
. functions.sh
|
||||
|
||||
if [ -z "$_XMRIG_SCREEN" ]; then
|
||||
# Load settings when run by crontab
|
||||
# Also ensures vm.nr_hugepages is set
|
||||
. settings.sh
|
||||
. functions.sh
|
||||
|
||||
# Check another instance is not already running
|
||||
if ! screen -list | grep -q "$_XMRIG_SCREEN"; then
|
||||
# Call function
|
||||
start_xmrig
|
||||
fi
|
||||
else
|
||||
# Call function
|
||||
if ! screen -list | grep -q "$_XMRIG_SCREEN"; then
|
||||
# Call function
|
||||
echo "No screen sessionfound. Starting new screen session."
|
||||
start_xmrig
|
||||
|
||||
# Unset _XMRIG_SCREEN variable.
|
||||
# The start script will have to load settings on next start
|
||||
$_XMRIG_SCREEN=""
|
||||
fi
|
||||
# List screen
|
||||
screen -ls
|
||||
else
|
||||
# Call function
|
||||
echo "Found existing screen session. Leaving."
|
||||
|
||||
# List screen
|
||||
screen -ls
|
||||
# List screen
|
||||
screen -ls
|
||||
|
||||
fi
|
||||
|
||||
echo "####################################"
|
||||
echo " STARTED - use screen -r to view "
|
||||
|
Loading…
Reference in New Issue
Block a user