This commit is contained in:
Marco Ochse 2022-04-12 12:47:07 +02:00 committed by GitHub
parent edc5188f08
commit 5d1640c1f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

103
update.sh
View file

@ -68,7 +68,7 @@ function fuSELFUPDATE () {
return return
fi fi
### DEV ### DEV
myRESULT=$(git diff --name-only origin/master | grep update.sh) myRESULT=$(git diff --name-only origin/master | grep "^update.sh")
if [ "$myRESULT" == "update.sh" ]; if [ "$myRESULT" == "update.sh" ];
then then
echo "###### $myBLUE""Found newer version, will be pulling updates and restart myself.""$myWHITE" echo "###### $myBLUE""Found newer version, will be pulling updates and restart myself.""$myWHITE"
@ -84,17 +84,57 @@ function fuSELFUPDATE () {
echo echo
} }
# Let's check for version # Let's check for version, upgrade to Debian 11
function fuCHECK_VERSION () { function fuCHECK_VERSION () {
local myMINVERSION="20.06.0" local myMINVERSION="20.06.0"
local myMASTERVERSION="22.04.0" local myMASTERVERSION="22.04.0"
echo echo
echo "### Checking for Release ID" echo "### Checking for Release ID"
myRELEASE=$(lsb_release -i | grep Debian -c) myRELEASE=$(lsb_release -c | awk '{ print $2 }')
if [ "$myRELEASE" == "0" ] if [ "$myRELEASE" != "$myLSB_RELEASE" ]
then then
echo "###### This version of T-Pot cannot be upgraded automatically. Please run a fresh install.$myWHITE"" [ $myRED""NOT OK""$myWHITE ]" echo "###### Need to upgrade to Debian 11 (Bullseye) first:$myWHITE"" [ $myRED""NOT OK""$myWHITE ]"
exit echo "###### Upgrade may result in complete data loss and should not be run via SSH."
echo "###### If you installed T-Pot using the post-install method instead of the ISO it is recommended you upgrade manually to Debian 11 (Bullseye) and then re-run update.sh."
echo "###### Do you want to upgrade to Debian 11 (Bullseye) now?"
while [ "$myQST" != "y" ] && [ "$myQST" != "n" ];
do
read -p "Upgrade? (y/n) " myQST
done
if [ "$myQST" = "n" ];
then
echo
echo $myGREEN"Aborting!"$myWHITE
echo
exit
else
echo "###### Stopping and disabling T-Pot services ... "
echo
systemctl stop tpot
systemctl disable tpot
systemctl stop docker
systemctl start docker
docker stop $(docker ps -aq)
docker rm -v $(docker ps -aq)
echo "###### Switching /etc/apt/sources.list from buster to bullseye ... "
echo
sed -i 's/buster/bullseye/g' /etc/apt/sources.list
echo "###### Updating repositories ... "
echo
apt-fast update
export DEBIAN_FRONTEND=noninteractive
echo "###### Running full upgrade ... "
echo
echo "docker.io docker.io/restart boolean true" | debconf-set-selections -v
echo "ssh ssh/restart boolean true" | debconf-set-selections -v
echo "cron cron/restart boolean true" | debconf-set-selections -v
echo "debconf debconf/frontend select noninteractive" | debconf-set-selections -v
apt-fast full-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes
dpkg --configure -a
echo "###### $myBLUE""Finished with upgrading. Now restarting update.sh and to continue with T-Pot related updates.""$myWHITE"
exec ./update.sh -y
exit 1
fi
fi fi
echo echo
echo "### Checking for version tag ..." echo "### Checking for version tag ..."
@ -115,7 +155,6 @@ if [ -f "version" ];
echo echo
} }
# Stop T-Pot to avoid race conditions with running containers with regard to the current T-Pot config # Stop T-Pot to avoid race conditions with running containers with regard to the current T-Pot config
function fuSTOP_TPOT () { function fuSTOP_TPOT () {
echo echo
@ -191,56 +230,6 @@ echo
} }
function fuUPDATER () { function fuUPDATER () {
# Need to check for Debian release after self update to run upgrade to Debian 11
echo "### Checking for Release ID"
myRELEASE=$(lsb_release -c | awk '{ print $2 }')
if [ "$myRELEASE" != "$myLSB_RELEASE" ]
then
echo "###### Need to upgrade to Debian 11 (Bullseye) first:$myWHITE"" [ $myRED""NOT OK""$myWHITE ]"
echo "###### Upgrade may result in complete data loss and should not be run via SSH."
echo "###### If you installed T-Pot using the post-install method instead of the ISO it is recommended you upgrade manually to Debian 11 (Bullseye) and then re-run update.sh."
echo "###### Do you want to upgrade to Debian 11 (Bullseye) now?"
while [ "$myQST" != "y" ] && [ "$myQST" != "n" ];
do
read -p "Upgrade? (y/n) " myQST
done
if [ "$myQST" = "n" ];
then
echo
echo $myGREEN"Aborting!"$myWHITE
echo
exit
else
echo "###### Stopping and disabling T-Pot services ... "
echo
systemctl stop tpot
systemctl disable tpot
systemctl stop docker
systemctl start docker
docker stop $(docker ps -aq)
docker rm -v $(docker ps -aq)
echo "###### Switching /etc/apt/sources.list from buster to bullseye ... "
echo
sed -i 's/buster/bullseye/g' /etc/apt/sources.list
echo "###### Updating repositories ... "
echo
apt-fast update
export DEBIAN_FRONTEND=noninteractive
echo "###### Running full upgrade ... "
echo
echo "docker.io docker.io/restart boolean true" | debconf-set-selections -v
echo "ssh ssh/restart boolean true" | debconf-set-selections -v
echo "cron cron/restart boolean true" | debconf-set-selections -v
echo "debconf debconf/frontend select noninteractive" | debconf-set-selections -v
apt-fast full-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes
dpkg --configure -a
echo "###### $myBLUE""Finished with upgrading. Now restarting update.sh and to continue with T-Pot related updates.""$myWHITE"
exec ./update.sh -y
exit 1
fi
fi
echo
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
echo echo
echo "### Installing apt-fast" echo "### Installing apt-fast"