2017-09-28 20:00:51 +00:00
|
|
|
|
#!/bin/bash
|
2017-10-05 22:53:35 +00:00
|
|
|
|
|
2017-10-05 22:02:02 +00:00
|
|
|
|
###################################################
|
|
|
|
|
# Do not change any contents of this script!
|
|
|
|
|
###################################################
|
|
|
|
|
|
2017-10-05 19:13:58 +00:00
|
|
|
|
# Some vars
|
|
|
|
|
myCONFIGFILE="/opt/tpot/etc/tpot.yml"
|
|
|
|
|
myRED="[0;31m"
|
|
|
|
|
myGREEN="[0;32m"
|
|
|
|
|
myWHITE="[0;0m"
|
|
|
|
|
myBLUE="[0;34m"
|
|
|
|
|
|
2017-09-28 20:00:51 +00:00
|
|
|
|
# Got root?
|
|
|
|
|
myWHOAMI=$(whoami)
|
|
|
|
|
if [ "$myWHOAMI" != "root" ]
|
|
|
|
|
then
|
|
|
|
|
echo "Need to run as root ..."
|
|
|
|
|
sudo ./$0
|
|
|
|
|
exit
|
|
|
|
|
fi
|
|
|
|
|
|
2017-10-05 19:13:58 +00:00
|
|
|
|
# Check for existing tpot.yml
|
|
|
|
|
function fuCONFIGCHECK () {
|
|
|
|
|
echo "### Checking for T-Pot configuration file ..."
|
|
|
|
|
echo -n "###### $myBLUE$myCONFIGFILE$myWHITE "
|
|
|
|
|
if ! [ -f $myCONFIGFILE ];
|
|
|
|
|
then
|
|
|
|
|
echo
|
|
|
|
|
echo $myRED"Error - No T-Pot configuration file present."
|
|
|
|
|
echo "Please copy one of the preconfigured configuration files from /opt/tpot/etc/compose/*.yml to /opt/tpot/etc/tpot.yml."$myWHITE
|
|
|
|
|
echo
|
|
|
|
|
exit 1
|
|
|
|
|
else
|
|
|
|
|
echo $myGREEN"OK"$myWHITE
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Let's test the internet connection
|
|
|
|
|
function fuCHECKINET () {
|
|
|
|
|
mySITES=$1
|
|
|
|
|
echo "### Now checking availability of ..."
|
|
|
|
|
for i in $mySITES;
|
|
|
|
|
do
|
|
|
|
|
echo -n "###### $myBLUE$i$myWHITE "
|
|
|
|
|
curl --connect-timeout 5 -IsS $i 2>&1>/dev/null
|
|
|
|
|
if [ $? -ne 0 ];
|
|
|
|
|
then
|
|
|
|
|
echo
|
|
|
|
|
echo $myRED"Error - Internet connection test failed. This might indicate some problems with your connection."
|
|
|
|
|
echo "Exiting."$myWHITE
|
|
|
|
|
echo
|
|
|
|
|
exit 1
|
|
|
|
|
else
|
|
|
|
|
echo $myGREEN"OK"$myWHITE
|
|
|
|
|
fi
|
|
|
|
|
done;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-05 22:02:02 +00:00
|
|
|
|
function fuSELFUPDATE () {
|
2017-10-05 22:34:41 +00:00
|
|
|
|
echo "### Now checking for newer files in repository ..."
|
2017-10-05 22:02:02 +00:00
|
|
|
|
git fetch
|
2017-10-05 22:34:41 +00:00
|
|
|
|
myREMOTESTAT=$(git status | grep -c "up-to-date")
|
|
|
|
|
if [ "$myREMOTESTAT" != "0" ];
|
|
|
|
|
then
|
|
|
|
|
echo "###### $myBLUE"No updates found in repository."$myWHITE"
|
|
|
|
|
return
|
|
|
|
|
fi
|
2017-10-05 22:53:35 +00:00
|
|
|
|
myRESULT=$(git diff --name-only origin/17.06 | grep update.sh)
|
2017-10-05 22:02:02 +00:00
|
|
|
|
myLOCALSTAT=$(git status -uno | grep -c update.sh)
|
|
|
|
|
if [ "$myRESULT" == "update.sh" ];
|
|
|
|
|
then
|
2017-10-05 22:40:31 +00:00
|
|
|
|
if [ "$myLOCALSTAT" == "0" ];
|
2017-10-05 22:02:02 +00:00
|
|
|
|
then
|
|
|
|
|
echo "###### $myBLUE"Found newer version, will update myself and restart."$myWHITE"
|
|
|
|
|
git pull --force
|
|
|
|
|
exec "$1" "$2"
|
|
|
|
|
exit 1
|
|
|
|
|
else
|
|
|
|
|
echo $myRED"Error - Update script was changed locally, cannot update."
|
|
|
|
|
echo "Exiting."$myWHITE
|
|
|
|
|
echo
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
echo "###### Update script is already up-to-date."
|
2017-10-13 21:53:21 +00:00
|
|
|
|
git pull --force
|
2017-10-05 22:02:02 +00:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-28 20:00:51 +00:00
|
|
|
|
# Only run with command switch
|
|
|
|
|
if [ "$1" != "-y" ]; then
|
|
|
|
|
echo "This script will update / upgrade all T-Pot related scripts, tools and packages"
|
|
|
|
|
echo "Some of your changes might be overwritten, so make sure to save your work"
|
|
|
|
|
echo "This feature is still experimental, run with \"-y\" switch"
|
|
|
|
|
echo
|
|
|
|
|
exit
|
|
|
|
|
fi
|
2017-10-05 21:02:36 +00:00
|
|
|
|
|
2017-10-05 19:13:58 +00:00
|
|
|
|
echo "### Now running T-Pot update script."
|
|
|
|
|
echo
|
2017-10-05 22:34:41 +00:00
|
|
|
|
|
2017-10-05 19:13:58 +00:00
|
|
|
|
fuCHECKINET "https://index.docker.io https://github.com https://pypi.python.org https://ubuntu.com"
|
|
|
|
|
echo
|
2017-10-05 21:02:36 +00:00
|
|
|
|
|
2017-10-05 22:02:02 +00:00
|
|
|
|
fuSELFUPDATE "$0" "$@"
|
|
|
|
|
echo
|
|
|
|
|
|
2017-10-05 19:13:58 +00:00
|
|
|
|
fuCONFIGCHECK
|
|
|
|
|
echo
|
2017-09-28 20:00:51 +00:00
|
|
|
|
|
|
|
|
|
echo "### Now stopping T-Pot"
|
|
|
|
|
systemctl stop tpot
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "### Now upgrading packages"
|
|
|
|
|
apt-get autoclean -y
|
|
|
|
|
apt-get autoremove -y
|
|
|
|
|
apt-get update
|
|
|
|
|
apt-get dist-upgrade -y
|
|
|
|
|
pip install --upgrade pip
|
|
|
|
|
pip install docker-compose==1.16.1
|
|
|
|
|
pip install elasticsearch-curator==5.2.0
|
|
|
|
|
ln -s /usr/bin/nodejs /usr/bin/node 2>&1
|
|
|
|
|
npm install https://github.com/t3chn0m4g3/wetty -g
|
|
|
|
|
npm install https://github.com/t3chn0m4g3/elasticsearch-dump -g
|
|
|
|
|
wget https://github.com/bcicen/ctop/releases/download/v0.6.1/ctop-0.6.1-linux-amd64 -O /usr/bin/ctop && chmod +x /usr/bin/ctop
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "### Now replacing T-Pot related config files on host"
|
|
|
|
|
cp host/etc/systemd/* /etc/systemd/system/
|
|
|
|
|
cp host/etc/issue /etc/
|
|
|
|
|
cp -R host/etc/nginx/ssl /etc/nginx/
|
|
|
|
|
cp host/etc/nginx/tpotweb.conf /etc/nginx/sites-available/
|
|
|
|
|
cp host/etc/nginx/nginx.conf /etc/nginx/nginx.conf
|
|
|
|
|
cp host/usr/share/nginx/html/* /usr/share/nginx/html/
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "### Now reloading systemd, nginx"
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
nginx -s reload
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "### Now restarting wetty, nginx, docker"
|
|
|
|
|
systemctl restart wetty.service
|
|
|
|
|
systemctl restart nginx.service
|
|
|
|
|
systemctl restart docker.service
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "### Now pulling latest docker images"
|
|
|
|
|
docker-compose -f /opt/tpot/etc/tpot.yml pull
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "### Now starting T-Pot service"
|
|
|
|
|
systemctl start tpot
|
|
|
|
|
|
|
|
|
|
echo
|
2017-10-05 22:34:41 +00:00
|
|
|
|
echo "### Done."
|