first commit
This commit is contained in:
138
scripts/backup.sh
Executable file
138
scripts/backup.sh
Executable file
@@ -0,0 +1,138 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# VARIABLES
|
||||
#
|
||||
export APPS_PATH=`dirname "$(readlink -f "$0")"`
|
||||
export TMP_PATH=$APPS_PATH/../tmp
|
||||
export DATA_PATH=$APPS_PATH/../data
|
||||
export FLAG_PATH=$APPS_PATH/../flags
|
||||
|
||||
MINUTE=`date +%M | sed 's/^0*//'`
|
||||
DATE=`date +%Y%m%d0000`
|
||||
|
||||
#
|
||||
# OUTILS
|
||||
#
|
||||
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"
|
||||
sortie 1
|
||||
}
|
||||
|
||||
# synchro de la blockchain
|
||||
if [ -f $FLAG_PATH/no_blockchain ]
|
||||
then
|
||||
debug "No Blockchain synchro"
|
||||
else
|
||||
debug "Update the Blockchain"
|
||||
$APPS_PATH/blockchain/robot.sh 2>&1
|
||||
STATUS=$?
|
||||
if [ ! $STATUS -eq 0 ]
|
||||
then
|
||||
echec
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Toujours placer la version HASHES
|
||||
#
|
||||
$APPS_PATH/methode/hashes/robot.sh
|
||||
|
||||
#
|
||||
# CHOISIR UN MODE 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
|
||||
|
||||
if [ ! -f $DATA_PATH/$ROBOT/$BLOCK.png ]
|
||||
then
|
||||
debug "Compute $DATA_PATH/$ROBOT/$BLOCK.png"
|
||||
php robot.php $BLOCK
|
||||
fi
|
||||
|
||||
#
|
||||
# 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
|
||||
fi
|
||||
|
||||
if [ ! -f $DATA_PATH/hasard/$BLOCK.png ]
|
||||
then
|
||||
ln $DATA_PATH/$ROBOT/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
|
||||
fi
|
||||
|
||||
done
|
||||
fi
|
||||
|
||||
#
|
||||
# TWEET toutes les 20 minutes
|
||||
#
|
||||
if [ 0 -eq $TWEET ]
|
||||
then
|
||||
debug "send a TWEET"
|
||||
# tweet R. Topisto
|
||||
$APPS_PATH/twitter/twitterbot/robot.sh 2>&1
|
||||
|
||||
# "auto likes" from Topisto
|
||||
$APPS_PATH/twitter/likebot/robot.sh 2>&1
|
||||
fi
|
||||
|
||||
#
|
||||
# CLEAN OLD DATA
|
||||
#
|
||||
|
||||
if [ -d $DATA_PATH ]
|
||||
then
|
||||
find $DATA_PATH -mtime +1 -type f -name *.png -exec rm -f {} \;
|
||||
find $DATA_PATH -mtime +1 -type f -name *.zip -exec rm -f {} \;
|
||||
fi
|
||||
|
||||
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
|
||||
125
scripts/blocks.sh
Executable file
125
scripts/blocks.sh
Executable file
@@ -0,0 +1,125 @@
|
||||
#!/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 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
|
||||
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
|
||||
23
scripts/clean_data.sh
Executable file
23
scripts/clean_data.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$#" -eq "0" ]
|
||||
then
|
||||
if [ -d $DATA_PATH ]
|
||||
then
|
||||
find $DATA_PATH -mtime +1 -type f -name *.png -exec rm -f {} \;
|
||||
find $DATA_PATH -mtime +1 -type f -name *.zip -exec rm -f {} \;
|
||||
fi
|
||||
else
|
||||
if [ "$1" -eq "FULL" ]
|
||||
then
|
||||
if [ -d $DATA_PATH ]
|
||||
then
|
||||
rm -f $DATA_PATH/*/*
|
||||
fi
|
||||
if [ -d $TMP_PATH ]
|
||||
then
|
||||
rm -f $TMP_PATH/*
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
65
scripts/hashes.sh
Executable file
65
scripts/hashes.sh
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/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"
|
||||
sortie 1
|
||||
}
|
||||
|
||||
#
|
||||
# TEST DU FLAG
|
||||
#
|
||||
if [ -f $flag ]
|
||||
then
|
||||
debug "$0 is already running !"
|
||||
exit 1
|
||||
fi
|
||||
touch $flag
|
||||
|
||||
#
|
||||
# PARAMETRES PAR FICHIER FLAGS
|
||||
#
|
||||
if [ -f $FLAG_PATH/no_hashes ]
|
||||
then
|
||||
debug "No Hashes"
|
||||
echec
|
||||
fi
|
||||
|
||||
#
|
||||
# Toujours placer la version HASHES
|
||||
#
|
||||
debug "Compute HASHES ..."
|
||||
$APPS_PATH/methode/hashes/robot.sh
|
||||
|
||||
#
|
||||
# SORTIE AVEC SUCCES
|
||||
#
|
||||
succes
|
||||
21
scripts/lancer_tout.sh
Executable file
21
scripts/lancer_tout.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# VARIABLES
|
||||
#
|
||||
export APPS_PATH=`dirname "$(readlink -f "$0")"`
|
||||
export TMP_PATH=$APPS_PATH/../tmp
|
||||
export DATA_PATH=$APPS_PATH/../data
|
||||
export FLAG_PATH=$APPS_PATH/../flags
|
||||
|
||||
MINUTE=`date +%M`
|
||||
DATE=`date +%Y%m%d0000`
|
||||
|
||||
|
||||
for methode in `ls $APPS_PATH/methode`
|
||||
do
|
||||
echo $methode
|
||||
source $APPS_PATH/methode/$methode/robot.sh
|
||||
done
|
||||
|
||||
|
||||
68
scripts/synchronize.sh
Executable file
68
scripts/synchronize.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/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"
|
||||
sortie 1
|
||||
}
|
||||
|
||||
#
|
||||
# TEST DU FLAG
|
||||
#
|
||||
if [ -f $flag ]
|
||||
then
|
||||
debug "$0 is already running !"
|
||||
exit 1
|
||||
fi
|
||||
touch $flag
|
||||
|
||||
#
|
||||
# Synchronize the Blockchain
|
||||
#
|
||||
if [ -f $FLAG_PATH/no_blockchain ]
|
||||
then
|
||||
debug "No Blockchain synchro"
|
||||
echec
|
||||
fi
|
||||
|
||||
debug "Update the Blockchain ..."
|
||||
|
||||
$APPS_PATH/blockchain/robot.sh 2>&1
|
||||
STATUS=$?
|
||||
if [ ! $STATUS -eq 0 ]
|
||||
then
|
||||
echec
|
||||
fi
|
||||
|
||||
#
|
||||
# SORTIE AVEC SUCCES
|
||||
#
|
||||
succes
|
||||
76
scripts/tweet.sh
Executable file
76
scripts/tweet.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/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"
|
||||
sortie 1
|
||||
}
|
||||
|
||||
#
|
||||
# TEST DU FLAG
|
||||
#
|
||||
if [ -f $flag ]
|
||||
then
|
||||
debug "$0 is already running !"
|
||||
exit 1
|
||||
fi
|
||||
touch $flag
|
||||
|
||||
#
|
||||
# PARAMETRES PAR FICHIER FLAGS
|
||||
#
|
||||
if [ -f $FLAG_PATH/no_tweet ]
|
||||
then
|
||||
debug "No Tweet"
|
||||
echec
|
||||
fi
|
||||
|
||||
#
|
||||
# TWEET
|
||||
#
|
||||
TWEET=3
|
||||
if [ $((MINUTE % $TWEET)) -eq 0 ]
|
||||
then
|
||||
debug "send a TWEET"
|
||||
|
||||
# tweet R. Topisto
|
||||
$APPS_PATH/twitter/twitterbot/robot.sh 2>&1
|
||||
|
||||
# "auto likes" from Topisto
|
||||
$APPS_PATH/twitter/likebot/robot.sh 2>&1
|
||||
else
|
||||
debug "no TWEET"
|
||||
fi
|
||||
|
||||
#
|
||||
# SORTIE AVEC SUCCES
|
||||
#
|
||||
succes
|
||||
Reference in New Issue
Block a user