100 blocks

This commit is contained in:
2024-01-28 13:13:47 +01:00
parent 06e604f268
commit be73b23564
19 changed files with 573 additions and 107 deletions
+133
View File
@@ -0,0 +1,133 @@
#!/bin/bash
lescript=`basename $0 .sh`
#
# TOOLS
#
function debug
{
if [ -f $FLAG_PATH/debug ]
then
echo $1
fi
}
function sortie
{
exit $1
}
function succes
{
debug "SUCCES"
sortie 0
}
function echec
{
debug "ECHEC"
exit 1
}
#
# PARAMETRES PAR FICHIER FLAGS
#
if [ -f $FLAG_PATH/no_blocks ]
then
debug "No blocks"
echec
fi
BLOCK=`grep LAST $DATA_PATH/block_list.txt | awk '{print $2}'`
TODAY=$(date -d '00:00:00' +%s)
N=0
while [ $N -ne 100 ]
do
echo $BLOCK
cd $APPS_PATH/info
infos=`php robot.php $BLOCK`
HEIGHT=`echo $infos | awk '{print $1}'`
TIMETS=`echo $infos | awk '{print $2}'`
NBTX=`echo $infos | awk '{print $3}'`
NONCE=`echo $infos | awk '{print $4}'`
PREV=`echo $infos | awk '{print $5}'`
if [ -z "$TIMETS" ]
then
break
fi
if [ $TIMETS -lt $TODAY ]
then
break
fi
#
# TEST DU FLAG
#
flag=$FLAG_PATH/bot_${lescript}_${BLOCK}.flag
if [ -f $flag ]
then
debug "${lescript}_${BLOCK} already done"
continue
fi
touch $flag
if [ ! -f $DATA_PATH/nonce/$BLOCK.png ]
then
#
# Si c'est la première fois que l'on dessine le block
# On choisit la méthode qui découle du nonce
#
cd $APPS_PATH/nonce
nbmethodes=`cat $DATA_PATH/nonce_methods_list.txt | wc -l`
lenonce=`php robot.php $BLOCK`
lamethode=$((lenonce % nbmethodes))
if [ $lamethode -eq 0 ]
then
lamethode=$nbmethodes
fi
LISTE_METHODE=`cat $DATA_PATH/nonce_methods_list.txt | head -n $lamethode | tail -1`
cd $APPS_PATH/methode2
for METHODE in $LISTE_METHODE
do
if [ ! -d $DATA_PATH/$METHODE ]
then
mkdir -p $DATA_PATH/$METHODE
fi
echo $BLOCK $NAME $METHODE
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
then
php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
fi
done
cd - >> /dev/null
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png
fi
rm -f $flag
BLOCK=$PREV
N=$(($N+1))
done
#
# List of finished blocks
#
rm -f $DATA_PATH/finished_block_list.txt
grep -v CACHE $DATA_PATH/block_list.txt >> $DATA_PATH/finished_block_list.txt
#
# SORTIE AVEC SUCCES
#
succes
+86
View File
@@ -0,0 +1,86 @@
#!/bin/bash
lescript=`basename $0 .sh`
#
# TOOLS
#
function debug
{
if [ -f $FLAG_PATH/debug ]
then
echo $1
fi
}
function sortie
{
exit $1
}
function succes
{
debug "SUCCES"
sortie 0
}
function echec
{
debug "ECHEC"
exit 1
}
#
# PARAMETRES PAR FICHIER FLAGS
#
if [ -f $FLAG_PATH/no_blocks ]
then
debug "No blocks"
echec
fi
BLOCK=`grep LAST $DATA_PATH/block_list.txt | awk '{print $2}'`
echo $BLOCK
cd $APPS_PATH/info
infos=`php robot.php $BLOCK`
HEIGHT=`echo $infos | awk '{print $1}'`
TIMETS=`echo $infos | awk '{print $2}'`
NBTX=`echo $infos | awk '{print $3}'`
NONCE=`echo $infos | awk '{print $4}'`
PREV=`echo $infos | awk '{print $5}'`
#
# TEST DU FLAG
#
flag=$FLAG_PATH/bot_${lescript}_${BLOCK}.flag
if [ -f $flag ]
then
debug "${lescript}_${BLOCK} already done"
fi
touch $flag
LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf`
cd $APPS_PATH/methode2
for METHODE in $LISTE_METHODE
do
if [ ! -d $DATA_PATH/$METHODE ]
then
mkdir -p $DATA_PATH/$METHODE
fi
echo $BLOCK $NAME $METHODE
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
then
php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
fi
done
cd - >> /dev/null
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png
#
# SORTIE AVEC SUCCES
#
succes
-1
View File
@@ -1,6 +1,5 @@
#!/bin/bash
lescript=`basename $0 .sh`
flag=$TMP_PATH/bot_$lescript.flag
#
# TOOLS
+105
View File
@@ -0,0 +1,105 @@
#!/bin/bash
lescript=blocks2
#
# TOOLS
#
function debug
{
if [ -f $FLAG_PATH/debug ]
then
echo $1
fi
}
function sortie
{
exit $1
}
function succes
{
debug "SUCCES"
sortie 0
}
function echec
{
debug "ECHEC"
exit 1
}
#
# PARAMETRES PAR FICHIER FLAGS
#
if [ -f $FLAG_PATH/no_blocks ]
then
debug "No blocks"
echec
fi
while IFS='' read -r line || [[ -n "$line" ]]; do
NAME=`echo $line | awk '{print $1}'`
BLOCK=`echo $line | awk '{print $2}'`
HEIGHT=`echo $line | awk '{print $3}'`
NBTX=`echo $line | awk '{print $4}'`
#
# TEST DU FLAG
#
flag=$FLAG_PATH/bot_${lescript}_${BLOCK}.flag
if [ -f $flag ]
then
debug "${lescript}_${BLOCK} already done"
continue
fi
touch $flag
#
# CHOISIR UNE METHODE2 AU HASARD
#
# LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf`
# LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf | head -n 1`
# en rajoutant le head, on ne fait qu'un seul dessin
LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf | head -n 1`
if [ $HEIGHT -eq 1 ]
then
LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v treemap | grep -v robot | shuf | head -n 1`
fi
cd $APPS_PATH/methode2
for METHODE in $LISTE_METHODE
do
if [ ! -d $DATA_PATH/$METHODE ]
then
mkdir -p $DATA_PATH/$METHODE
fi
echo $BLOCK $NAME $METHODE
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
then
php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png
fi
done
cd - >> /dev/null
if [ ! -f $DATA_PATH/hasard/$BLOCK.png ]
then
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
fi
rm -f $flag
done < $DATA_PATH/block_list.txt
#
# List of finished blocks
#
rm -f $DATA_PATH/finished_block_list.txt
grep -v CACHE $DATA_PATH/block_list.txt >> $DATA_PATH/finished_block_list.txt
#
# SORTIE AVEC SUCCES
#
succes
+1 -51
View File
@@ -1,6 +1,5 @@
#!/bin/bash
lescript=`basename $0 .sh`
flag=$TMP_PATH/bot_$lescript.flag
#
# TOOLS
@@ -59,62 +58,13 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
if [ ! -f $DATA_PATH/nonce/$BLOCK.png ]
then
#
# Si c'est la première fois que l'on dessine le block
# On choisit la méthode qui découle du nonce
#
cd $APPS_PATH/nonce
nbmethodes=`cat $DATA_PATH/nonce_methods_list.txt | wc -l`
lenonce=`php robot.php $BLOCK`
lamethode=$((lenonce % nbmethodes))
if [ $lamethode -eq 0 ]
then
lamethode=$nbmethodes
fi
LISTE_METHODE=`cat $DATA_PATH/nonce_methods_list.txt | head -n $lamethode | tail -1`
else
#
# CHOISIR UNE METHODE2 AU HASARD
#
LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf`
if [ $NBTX -lt 10 ]
then
LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | grep -v treemap | grep -v mondrian | shuf`
fi
fi
cd $APPS_PATH/methode2
for METHODE in $LISTE_METHODE
do
if [ ! -d $DATA_PATH/$METHODE ]
then
mkdir -p $DATA_PATH/$METHODE
fi
echo $BLOCK $NAME $METHODE
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
then
php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
fi
done
cd - >> /dev/null
if [ ! -f $DATA_PATH/nonce/$BLOCK.png ]
then
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png
echo "Aucune image pour nonce !"
fi
rm -f $flag
done < $DATA_PATH/block_list.txt
#
# List of finished blocks
#
rm -f $DATA_PATH/finished_block_list.txt
grep -v CACHE $DATA_PATH/block_list.txt >> $DATA_PATH/finished_block_list.txt
#
# SORTIE AVEC SUCCES
#
+140
View File
@@ -0,0 +1,140 @@
#!/bin/bash
lescript=`basename $0 .sh`
flag=$TMP_PATH/bot_$lescript.flag
#
# TOOLS
#
function debug
{
if [ -f $FLAG_PATH/debug ]
then
echo $1
fi
}
function sortie
{
if [ -f $flag ]
then
rm -f $flag
fi
exit $1
}
function succes
{
debug "SUCCES"
sortie 0
}
function echec
{
debug "ECHEC"
exit 1
}
#
# TEST DU FLAG
#
if [ -f $flag ]
then
debug "$0 is already running !"
echec
fi
touch $flag
#
# PARAMETRES PAR FICHIER FLAGS
#
if [ -f $FLAG_PATH/no_blocks ]
then
debug "No blocks"
echec
fi
#
# CHOISIR UNE METHODE2 AU HASARD
#
ROBOT=`ls $APPS_PATH/methode2 | shuf | tail -n 1`
debug $ROBOT
$APPS_PATH/methode2/robot.sh $ROBOT
succes
#
# CHOISIR UNE METHODE AU HASARD
#
ROBOT=`ls $APPS_PATH/methode | grep -v hashes | shuf | tail -n 1`
debug $ROBOT
#
# Y A PLUS QU'A !
#
if [ ! -f $FLAG_PATH/no_$ROBOT ]
then
cd $APPS_PATH/methode/$ROBOT
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
do
#
# Pour renouveller l'affichage des blocs remarquables
# De temps en temps (15%), on efface le block
#
if [ $((RANDOM % 100)) -lt 15 ]
then
rm -f $DATA_PATH/$ROBOT/$BLOCK.png
fi
#
# Si l'image n'existe pas, on la calcule
#
if [ ! -f $DATA_PATH/$ROBOT/$BLOCK.png ]
then
debug "Compute $DATA_PATH/$ROBOT/$BLOCK.png"
php robot.php $BLOCK
fi
#
# Les actions suivantes ne sont réalisées que si
# robot.php a produit une image
#
if [ -f $DATA_PATH/$ROBOT/$BLOCK.png ]
then
#
# Les blocs remarquables sont anti datés à minuit
# Pour l'affichage et le nettoyage automatique
#
BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'`
if [ "$BNAME" != "LAST" ]
then
touch -t $DATE $DATA_PATH/$ROBOT/$BLOCK.png
if [ -f $DATA_PATH/spline/$BLOCK.png ]
then
rm -f $DATA_PATH/hasard/$BLOCK.png
ln $DATA_PATH/spline/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
fi
fi
#
# Maintenir le hasard
#
if [ ! -f $DATA_PATH/hasard/$BLOCK.png ]
then
ln $DATA_PATH/$ROBOT/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
fi
fi
done
fi
#
# List of finished blocks
#
rm -f $DATA_PATH/finished_block_list.txt
grep -v CACHE $DATA_PATH/block_list.txt >> $DATA_PATH/finished_block_list.txt
#
# SORTIE AVEC SUCCES
#
succes
+7 -4
View File
@@ -2,7 +2,9 @@
# Antidater les données des blocks connus
date=`date +%Y%m%d0000`
touch -t $date $DATA_PATH/emptybot/*
touch -t $date $DATA_PATH/emptybot/*.{png,txt}
for BLOCK in `grep -v LAST $DATA_PATH/block_list.txt | grep -v CACHE | awk '{print $2}'`
do
touch -t $date $DATA_PATH/*/$BLOCK.*
@@ -13,10 +15,11 @@ if [ "$#" -eq "0" ]
then
if [ -d $DATA_PATH ]
then
find $DATA_PATH -mtime +3 -type f -name *.png -exec rm -f {} \;
find $DATA_PATH -mtime +3 -type f -name *.zip -exec rm -f {} \;
echo "CLEAN +3 $DATA_PATH" > $TMP_PATH/clean_data.log
find $DATA_PATH -mtime +3 -type f -name *.png -exec rm -f {} \;
find $DATA_PATH -mtime +3 -type f -name *.zip -exec rm -f {} \;
find $TMP_PATH -mtime +3 -type f -name *.flag -exec rm -f {} \;
find $TMP_PATH -mtime +3 -type f -name *.flag -exec rm -f {} \;
fi
else
if [ "$1" -eq "FULL" ]
+16 -4
View File
@@ -48,22 +48,34 @@ touch $flag
# DO IT !
#
while IFS='' read -r line || [[ -n "$line" ]]; do
NAME=`echo $line | awk '{print $1}'`
BLOCK=`echo $line | awk '{print $2}'`
HEIGHT=`echo $line | awk '{print $3}'`
NBTX=`echo $line | awk '{print $4}'`
#
# On choisit la méthode qui découle du nonce
#
cd $APPS_PATH/nonce
nbmethodes=`ls $APPS_PATH/methode2 | grep -v robot | wc -l`
nbmethodes=`cat $DATA_PATH/nonce_methods_list.txt | wc -l`
lenonce=`php robot.php $BLOCK`
lamethode=$((lenonce%nbmethodes))
[ $lamethode -eq 0 ] ; lamethode=$nbmethodes
METHODE=`ls $APPS_PATH/methode2 | grep -v robot | head -n $lamethode`
lamethode=$((lenonce % nbmethodes))
if [ $lamethode -eq 0 ]
then
lamethode=$nbmethodes
fi
METHODE=`cat $DATA_PATH/nonce_methods_list.txt | head -n $lamethode | tail -1`
echo $NAME $METHODE $lenonce $nbmethodes $lamethode
if [ -f $DATA_PATH/$METHODE/$BLOCK.png ]
then
cp $DATA_PATH/$METHODE/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png
fi
done < $DATA_PATH/block_list.txt
rm -f $flag
#
# SORTIE AVEC SUCCES
#
succes
+1 -1
View File
@@ -82,7 +82,7 @@ then
$APPS_PATH/twitter/twitterbot/robot.sh 2>&1
# "auto likes" from Topisto
$APPS_PATH/twitter/likebot/robot.sh 2>&1
# $APPS_PATH/twitter/likebot/robot.sh 2>&1
touch $DATA_PATH/twitterbot/$DATEHOUR
else