Created
April 15, 2022 02:49
-
-
Save researcx/aac0fafa12ba6a8e3ed8c121c6efc73e to your computer and use it in GitHub Desktop.
check weather and time conditions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOCATION="Hampshire" | |
CONDITION=`curl -s wttr.in/$LOCATION?format=%C` | |
SUNSET=`curl -s wttr.in/$LOCATION?format=%s` | |
SUNRISE=`curl -s wttr.in/$LOCATION?format=%S` | |
TIME=`date "+%H:%M:%S"` | |
sunset_time=$(date -d $SUNSET +%s) | |
sunrise_time=$(date -d $SUNRISE +%s) | |
current_time=$(date -d $TIME +%s) | |
CONDITIONS=('Sunny' 'Partly cloudy' 'Clear') | |
echo "Location: $LOCATION | Weather: $CONDITION" | |
echo "Time: $TIME | Sunrise: $SUNRISE | Sunset: $SUNSET" | |
if [[ ${CONDITIONS[*]} =~ $CONDITION ]] | |
then | |
#echo "Compatible weather condition" | |
if [ $current_time -ge $sunset_time ] | |
then | |
echo "It's not solar time, killing xmrig" | |
#pkill -9 xmrig | |
elif [ $current_time -ge $sunrise_time ] | |
then | |
echo "It's solar time, running xmrig" | |
bash check_xmrig.sh | |
fi | |
else | |
echo "Incompatible weather condition, killing xmrig" | |
#pkill -9 xmrig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment