2019-02-20 12:28:23 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-02-19 16:45:15 +01:00
|
|
|
#
|
|
|
|
# CONFIGURATION
|
|
|
|
#
|
2019-02-19 13:53:09 +01:00
|
|
|
|
2019-02-19 16:45:15 +01:00
|
|
|
# Interval between two consecutive posts
|
2019-02-24 00:33:29 +01:00
|
|
|
FLOOR_HOUR_SLEEP_INTERVAL=5
|
|
|
|
CEILING_HOUR_SLEEP_INTERVAL=19
|
2019-02-19 13:53:09 +01:00
|
|
|
|
2019-02-19 16:45:15 +01:00
|
|
|
# File containing the toots to post
|
2019-02-21 10:52:30 +01:00
|
|
|
DATA_FILE=megafono.txt
|
2019-02-20 17:34:02 +01:00
|
|
|
|
2019-02-19 16:45:15 +01:00
|
|
|
#
|
|
|
|
# CONFIGURATION END
|
|
|
|
#
|
|
|
|
|
2019-02-24 00:33:29 +01:00
|
|
|
random_time_on_range(){
|
|
|
|
FLOOR=$1
|
|
|
|
CEILING=$2
|
|
|
|
RANGE=$(($CEILING-$FLOOR+1));
|
|
|
|
#echo "You will generate a random number between $FLOOR and $CEILING (both inclusive). There are $RANGE possible numbers!"
|
|
|
|
RESULT=$RANDOM;
|
|
|
|
#echo "We just generated the random number $RESULT, which might not be in the range we want";
|
|
|
|
let "RESULT %= $RANGE";
|
|
|
|
RESULT=$(($RESULT+$FLOOR));
|
|
|
|
echo $RESULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-19 13:57:34 +01:00
|
|
|
while :
|
2019-02-19 13:53:09 +01:00
|
|
|
do
|
2019-02-19 13:57:34 +01:00
|
|
|
# Last line should be empty, so we dont need an additional read here
|
|
|
|
# after the while loop
|
|
|
|
while read line
|
|
|
|
do
|
2019-02-24 00:33:29 +01:00
|
|
|
#eval ./toot.sh $line
|
|
|
|
SLEEP_TOOT=$(random_time_on_range $FLOOR_HOUR_SLEEP_INTERVAL $CEILING_HOUR_SLEEP_INTERVAL)
|
|
|
|
sleep $SLEEP_TOOT"h"
|
2019-02-19 16:45:15 +01:00
|
|
|
done < ${DATA_FILE}
|
2019-02-19 13:57:34 +01:00
|
|
|
|
2019-02-24 00:33:29 +01:00
|
|
|
done
|