hs.scripts/updates/znuny.sh

74 lines
2.4 KiB
Bash
Raw Normal View History

2024-04-25 13:49:12 +02:00
#!/bin/bash
set -e
echo "WARNING: please announce a maintenance! (waiting 3s)"
sleep 3
if [ -z "$1" ]
then
echo "ERROR: Can't continue. Version querying not implemented as we might not use the latest major release."
echo "Usage: bash ./update.sh 9.9.9"
exit 1
fi
echo "This script will stop the Znuny daemon, but Cron can start it again."
read -p "Is the Cronjob for [ otrs.Daemon.pl ] commented? (yY)" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Please make sure Cron does not start our daemon."
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # https://stackoverflow.com/questions/1885525/how-do-i-prompt-a-user-for-confirmation-in-bash-script
fi
cd $HOME/znuny
echo "not stopping Cron.sh, it might (FIXME) not apply"
#bin/Cron.sh stop
$HOME/znuny/bin/otrs.Daemon.pl stop
mkdir -p $HOME/tmp
cd $HOME/tmp
wget https://download.znuny.org/releases/znuny-$1.tar.gz
tar -xf znuny-$1.tar.gz
rm -v *tar.gz
mv -v znuny-$1 $HOME/
echo "NOT running otrs.SetPermissions.pl because we are not usually elevated (not checking)"
cd $HOME
cp -av $HOME/znuny/Kernel/Config.pm $HOME/znuny-$1/Kernel/
if [ -n "$(ls -A $HOME/znuny/var/article 2>/dev/null)" ]; then
cp -rpv $HOME/znuny/var/article/* $HOME/znuny-$1/var/article/
else
echo "nothing found in var/article"
fi
for f in $(find -L $HOME/znuny -maxdepth 1 -type f -name .\* -not -name \*.dist); do cp -av "$f" $HOME/znuny-$1/; done
for f in $(find -L $HOME/znuny/var/cron -maxdepth 1 -type f -name .\* -not -name \*.dist); do cp -av "$f" $HOME/znuny-$1/var/cron/; done
rm -v $HOME/znuny
ln -sv $HOME/znuny-$1 $HOME/znuny
$HOME/znuny/bin/otrs.Console.pl Maint::Database::Check
$HOME/znuny/bin/otrs.CheckModules.pl --all
migrationscript=`ls $HOME/znuny-$1/scripts/MigrateToZnuny* | xargs -n 1 basename`
read -p "Our migrationscript appears to be: [ $migrationscript ]. Is this correct? (yY)" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Skipping [ Admin::Package::UpgradeAll ] and [ $migrationscript ]..."
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # https://stackoverflow.com/questions/1885525/how-do-i-prompt-a-user-for-confirmation-in-bash-script
fi
$HOME/znuny/scripts/MigrateToZnuny6_5.pl
$HOME/znuny/bin/otrs.Console.pl Admin::Package::UpgradeAll
echo Script ended without errors!
echo "https://doc.znuny.org/znuny_lts/releases/installupdate/"
echo "https://wiki.hostsharing.net/index.php?title=Znuny_installieren#Updates"