fix: [reset_ail] fix directory name

This commit is contained in:
Terrtia 2019-07-30 15:21:27 +02:00
parent 09ecc4d93f
commit 574b64b33b
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0

View file

@ -6,52 +6,126 @@ GREEN="\\033[1;32m"
[ -z "$AIL_HOME" ] && echo "Needs the env var AIL_HOME. Run the script from the virtual environment." && exit 1; [ -z "$AIL_HOME" ] && echo "Needs the env var AIL_HOME. Run the script from the virtual environment." && exit 1;
# Make sure the reseting is intentional function soft_reset {
num=$(( ( RANDOM % 100 ) + 1 )) # Access dirs and delete
cd $AIL_HOME
echo -e $RED"To reset the platform, enter the following number: "$DEFAULT $num # Kill all screens
read userInput screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill
if [ $userInput -eq $num ] set -e
then
echo "Reseting AIL..."
else
echo "Wrong number"
exit 1;
fi
# Access dirs and delete
cd $AIL_HOME
# Kill all screens if [ -d indexdir/ ]; then
screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill pushd indexdir/
rm -r *
echo 'cleaned indexdir'
popd
fi
set -e if [ $userInput -eq $num ]
then
if [ -d DATA_ARDB/ ]; then
pushd DATA_ARDB/
rm -r *
echo 'cleaned DATA_ARDB'
popd
fi
fi
# Access dirs and delete if [ -d logs/ ]; then
cd $AIL_HOME pushd logs/
rm *
echo 'cleaned logs'
popd
fi
pushd dumps/ if [ -d PASTES/ ]; then
rm * pushd PASTES/
echo 'cleaned dumps' rm -r *
popd echo 'cleaned PASTES'
popd
fi
pushd indexdir/ if [ -d HASHS/ ]; then
rm -r * pushd HASHS/
echo 'cleaned indexdir' rm -r *
popd echo 'cleaned HASHS'
popd
fi
pushd LEVEL_DB_DATA/ if [ -d CRAWLED_SCREESHOT/ ]; then
rm -r * pushd CRAWLED_SCREESHOT/
echo 'cleaned LEVEL_DB_DATA' rm -r *
popd echo 'cleaned CRAWLED_SCREESHOT'
popd
fi
pushd logs/ if [ -d temp/ ]; then
rm * pushd temp/
echo 'cleaned logs' rm -r *
popd echo 'cleaned temp'
popd
fi
pushd PASTES/ if [ -d var/www/submitted/ ]; then
rm -r * pushd var/www/submitted
echo 'cleaned PASTES' rm -r *
popd echo 'cleaned submitted'
popd
fi
echo -e $GREEN"* AIL has been reset *"$DEFAULT echo -e $GREEN"* AIL has been reset *"$DEFAULT
exit
}
#If no params,
[[ $@ ]] || {
# Make sure the reseting is intentional
num=$(( ( RANDOM % 100 ) + 1 ))
echo -e $RED"To reset the platform, enter the following number: "$DEFAULT $num
read userInput
if [ $userInput -eq $num ]
then
echo "Reseting AIL..."
else
echo "Wrong number"
exit 1;
fi
num=$(( ( RANDOM % 100 ) + 1 ))
echo -e $RED"If yes you want to delete the DB , enter the following number: "$DEFAULT $num
read userInput
set -e
soft_reset;
if [ $userInput -eq $num ]
then
if [ -d DATA_ARDB/ ]; then
pushd DATA_ARDB/
rm -r *
echo 'cleaned DATA_ARDB'
popd
fi
fi
echo -e $GREEN"* AIL has been reset *"$DEFAULT
exit
}
while [ "$1" != "" ]; do
case $1 in
--softReset ) soft_reset;
;;
* ) exit 1
esac
shift
done