Commit 3903193a authored by benedikt.kroening's avatar benedikt.kroening
Browse files

Finally added upgrade/downgrade scripts

removed broken/old update-same-version script
added downgrade config and script
added upgrade config and script

fixed some typos
added executable flag

removed unused text
parent ece87557
......@@ -40,6 +40,13 @@ To shut it down properly execute: `docker-compose down -v`
Versions can be configured at `setup/versions`
Check that file for more information.
### Upgrade / Downgrade
You can find scripts for upgrading & downgrading at `setup/downgrade.sh` and `setup/upgrade.sh`.
Version configuration for those scripts is located at `setup/versions.downgrade` and `setup/versions.upgrade`
These scripts will only reinstall packages. Chances are high that you will have to adapt some settings manually to fully ensure the servers functionality. Take care!
### Database versions
By modifying the DATABASE_TYPE and DATBASE_VERSION variables (located in `config/config`) you can manually specify which database type and version to use.
......
#!/bin/bash
if [[ true == "${ANY_DEB}" ]]; then
echo "Update-same-version is atm only running on Debian"
exit 2
fi
apt-get clean
apt-get update
apt-get -y dist-upgrade
apt-get clean
INSTALLED=`dpkg --get-selections | grep -E 'open-xchange|readerengine|calcengine' | cut -f 1`
CURDIR=`pwd`
DOWNDIR=oxpackages-`date +%s%N`
MISSING=""
CURL_PATH=`which curl`
if [ -z $CURL_PATH ];
then
echo "cURL not found, using wget."
CURL_PATH="wget -q"
else
CURL_PATH="$CURL_PATH -# -O"
fi
mkdir $DOWNDIR
cd $DOWNDIR
for i in ${INSTALLED};
do
URL=`apt-get install --reinstall --print-uris -qq $i | cut -d "'" -f2 | grep "/$i_"`
if [ -z "$URL" ]
then
MISSING="$MISSING $i"
echo -e "\e[00;31mMissing URL for package $i \e[00m"
else
for j in ${URL};
do
FILE=`echo $j | awk -F "/" '{print $NF}'`
if [ ! -f $FILE ]
then
echo "Downloading $FILE"
$CURL_PATH $j
fi
done
fi
done
dpkg -i *.deb
cd $CURDIR
## TODO: uhhhhh..... need to check if rm directory is valid !
## https://www.theregister.co.uk/2015/01/17/scary_code_of_the_week_steam_cleans_linux_pcs/
rm -rf $DOWNDIR
if [ -n "$MISSING" ]; then
echo -e "\nUnable to download the following packages:"
echo "$MISSING"
fi
\ No newline at end of file
......@@ -41,8 +41,52 @@ function restartService {
}
function startAllServices {
checkMiddlewareInstalled
if [[ true == "${MIDDLEWARE_INSTALLED}" ]]; then
restartService open-xchange
fi
if [[ -n "${AS_DOCUMENTCONVERTER_VERSION}" ]]; then
restartService open-xchange-documentconverter-server
fi
if [[ -n "${AS_IMAGECONVERTER_VERSION}" ]]; then
restartService open-xchange-imageconverter-server
fi
}
function stopService {
if [[ "${INSTALL_TYPE}" == *"docker"* ]]; then
echo "Stopping service $1 with supervisorctl ..."
supervisorctl stop $1
else
#echo "ERROR: Not possible to determine installation type, could not restart service $1"
echo "Stopping service $1 ..."
if [[ "${DIST}" == "SLES12" ]] || [[ "${DIST}" == "RHEL7" ]]; then
systemctl stop $1.service
else
service $1 stop
fi
fi
}
function stopAllServices {
checkMiddlewareInstalled
if [[ true == "${MIDDLEWARE_INSTALLED}" ]]; then
stopService open-xchange
fi
if [[ -n "${AS_DOCUMENTCONVERTER_VERSION}" ]]; then
stopService open-xchange-documentconverter-server
fi
if [[ -n "${AS_IMAGECONVERTER_VERSION}" ]]; then
stopService open-xchange-imageconverter-server
fi
}
function detectDistribution {
if [[ -f /etc/debian_version ]]; then
REV=$(cat /etc/debian_version)
......
......@@ -459,12 +459,16 @@ function writeGuardRepository {
}
function writeCoreRepositories {
writeBackendRepository
writeFrontendRepository
}
function writeRepositories {
setRepositories
echo "Adding repository information..."
writeCoreRepositories
#writeBackendRepository
writeFrontendRepository
#writeFrontendRepository
if [[ true == "${ANY_DEB}" ]]; then
echo "# Debian and third-party Repositories" > /etc/apt/sources.list.d/ox-debian.list
if [[ "${DIST}" == "DebianJessie" ]]; then
......@@ -979,7 +983,19 @@ function preInstallActions {
}
function checkMiddlewareInstalled {
if [[ true == "${ANY_DEB}" ]]; then
dpkg-query -l 'open-xchange-core' > /dev/null 2>&1
if [[ $? == 0 ]]; then
MIDDLEWARE_INSTALLED=true
fi
elif [[ true == "${ANY_RPM}" ]]; then
rpm -qi open-xchange-core > /dev/null 2>&1
if [[ $? == 0 ]]; then
MIDDLEWARE_INSTALLED=true
fi
fi
}
function checkInstallDefaults {
if [[ "${INSTALL_TYPE}" == "singlenode" ]]; then
......@@ -1037,4 +1053,14 @@ function checkInstallDefaults {
export INSTALL_DATABASE=false
fi
fi
}
function checkInstalled {
# TODO: sles?
if [[ true == "${ANY_DEB}" ]]; then
dpkg-query -l 'open-xchange*' > /dev/null 2>&1
elif [[ true == "${ANY_RPM}" ]]; then
rpm -qi open-xchange > /dev/null 2>&1
fi
}
\ No newline at end of file
#!/bin/bash
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P)"
# sourcing some commonly used functions and executing basic checks
source ${SCRIPT_DIR}/../lib/common.bash
source ${SCRIPT_DIR}/../lib/setup.bash
STARTED_AT=$(date)
REINSTALL_SAME_VERSION=false
## Help text
show_usage() {
echo -n "
-r | --reinstall reinstall the same version of found ox packages
"
}
### reading config from command line; overriding defaults
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
show_usage
exit 0
shift
;;
--debug)
echo "WARNING: Debug flag set (--debug)"
set -x
shift
;;
--foo) # non value argument
INSTALL_FOO=true
shift
;;
-r|--reinstall)
export REINSTALL_SAME_VERSION=true
shift
;;
*) # unknown option
echo "Unknonwn option: $1"
POSITIONAL+=("$1") # save it in an array for later
shift
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# source downgrade versions
exportProperties ${SCRIPT_DIR}/versions.downgrade
checkRootPrivileges
detectDistribution
# Checking for already installed version
checkInstalled
if [[ $? != 0 ]]; then
echo "No OX App Suite installation has been found on this machine."
exit 1
fi
# Disabling all repos
function disable_repos {
if [[ true == "${ANY_DEB}" ]]; then
APT_PATHS=( "/etc/apt/" "/etc/apt/sources.list.d/" )
for j in "${APT_PATHS[@]}"; do
cd "$j"
for i in *.list; do
if [[ -n $i ]]; then
mv "$i" "${i/.list/.list.disabled_by_appsuite_downgrade}"
fi
done
done
fi
}
# Enabling all repos
function enable_repos {
if [[ true == "${ANY_DEB}" ]]; then
APT_PATHS=( "/etc/apt/" "/etc/apt/sources.list.d/" )
for j in "${APT_PATHS[@]}"; do
cd "$j"
for i in *.list.disabled_by_appsuite_downgrade; do
if [[ -n $i ]]; then
mv "$i" "${i/.list.disabled_by_appsuite_downgrade/.list}"
fi
done
done
fi
}
disable_repos
# TODO: this still needs to be refactored somehow
writeRepositories
writeUsmEasRepository
writeGuardRepository
# Building package list
if [[ "${DIST}" == "DebianJessie" ]] || [[ "${DIST}" == "DebianStretch" ]] || [[ "${DIST}" == "DebianBuster" ]]; then
apt-get clean
apt-get -o Dir::Ignore-Files-Silently::="\.disabled_by_appsuite_downgrade$" update
PACKAGES=$(dpkg --get-selections| grep "open-xchange.*[[:space:]]install"| cut -f1)
for PKG in ${PACKAGES}; do
INSTALLED_VER=$(apt-cache policy "$PKG"| grep "Installed:.*"| xargs| cut -d ' ' -f2)
if [[ true == "${REINSTALL_SAME_VERSION}" ]]; then
NEW_VER=$(apt-cache policy "$PKG"| grep -Eo "[*]{3}[\ ]([0-9]+\.[0-9]+\.[0-9]+\-[0-9]+)"| cut -d" " -f2| xargs)
else
NEW_VER=$(apt-cache policy "$PKG"| grep -Eo "[\ ]{2}[0-9]+\.[0-9]+\.[0-9]+\-[0-9]+"| xargs | sed -e "s/$INSTALLED_VER//g")
fi
if [[ -z "$NEW_VER" ]]; then
echo "No downgradable version found for package '$PKG', removing currently installed version ($INSTALLED_VER)."
REMOVE_PACKAGE_LIST+="${PKG} "
else
NEW_PACKAGE_LIST+="${PKG}=${NEW_VER} "
fi
done
echo "Packages to remove: ${REMOVE_PACKAGE_LIST}"
echo "Packages to downgrade: ${NEW_PACKAGE_LIST}"
if [[ -z "$NEW_PACKAGE_LIST" ]]; then
echo "No packages for downgrade, aborting. In case you tried to re-install the same version again, consider the REINSTALL_SAME_VERSION option."
enable_repos
exit 1
fi
elif [[ "${DIST}" == "SLES12" ]]; then
zypper clean
zypper ref
PACKAGES=$(rpm -qa --qf "%{NAME}\n"| grep open-xchange)
for PKG in ${PACKAGES}; do
INSTALLED_VERSION=$(rpm -q --qf "%{VERSION}\n" "$PKG")
INSTALLED_REV=$(rpm -q --qf "%{RELEASE}\n" "$PKG"| cut -d '_' -f1)
INSTALLED_VER="$INSTALLED_VERSION-$INSTALLED_REV"
AS_REPOS=$(zypper lr -A| grep -Eo "ox-\S+"| sort -u| xargs| sed -e "s/ / -r /g")
NEW_VER=$(zypper search -t package -s --match-exact -r ${AS_REPOS} "$PKG"| grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\-[0-9]*_[0-9]+\.[0-9]+")
if [[ -z "$NEW_VER" ]]; then
echo "No downgradable version found for package '$PKG', removing currently installed version ($INSTALLED_VER)."
REMOVE_PACKAGE_LIST+="${PKG} "
else
NEW_PACKAGE_LIST+="${PKG}=${NEW_VER} "
fi
done
elif [[ "${DIST}" == "RHEL6" ]] || [[ "${DIST}" == "RHEL7" ]] || [[ "${DIST}" == "CENTOS6" ]] || [[ "${DIST}" == "CENTOS7" ]]; then
yum clean all
yum -y install yum-utils
PACKAGES=$(rpm -qa --qf "%{NAME}\n"| grep open-xchange)
for PKG in ${PACKAGES}; do
INSTALLED_VERSION=$(rpm -q --qf "%{VERSION}\n" "$PKG")
INSTALLED_REV=$(rpm -q --qf "%{RELEASE}\n" "$PKG"| cut -d '_' -f1)
INSTALLED_VER="$INSTALLED_VERSION-$INSTALLED_REV"
NEW_VER=$(repoquery -q --disablerepo "*" --enablerepo "ox-*" --location "$PKG"| grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
if [[ -z "$NEW_VER" ]]; then
echo "No downgradable version found for package '$PKG', removing currently installed version ($INSTALLED_VER)."
REMOVE_PACKAGE_LIST+="${PKG} "
else
NEW_PACKAGE_LIST+="${PKG} "
fi
done
fi
if [[ $? -ne 0 ]]; then
echo "Error while downgrading packages, aborting."
exit 1
fi
# Stopping App Suite before downgrading
stopAllServices
# Downgrading
if [[ "${DIST}" == "DebianJessie" ]] || [[ "${DIST}" == "DebianStretch" ]] || [[ "${DIST}" == "DebianBuster" ]]; then
if [[ -n "$REMOVE_PACKAGE_LIST" ]]; then
dpkg --purge --force-depends ${REMOVE_PACKAGE_LIST}
apt-get -o Dir::Ignore-Files-Silently::="\.disabled_by_appsuite_downgrade$" -f -y --force-yes install
fi
if [[ true == "${REINSTALL_SAME_VERSION}" ]]; then
for PKG in ${NEW_PACKAGE_LIST}; do
apt-get install -o Dir::Ignore-Files-Silently::="\.disabled_by_appsuite_downgrade$" -o Dpkg::Options::="--force-confold" --reinstall -y --force-yes ${PKG}
done
else
apt-get install -o Dir::Ignore-Files-Silently::="\.disabled_by_appsuite_downgrade$" -o Dpkg::Options::="--force-confold" -y --force-yes ${NEW_PACKAGE_LIST}
fi
elif [[ "${DIST}" == "SLES12" ]]; then
if [[ -n ${REMOVE_PACKAGE_LIST} ]]; then
rpm -e --nodeps ${REMOVE_PACKAGE_LIST}
fi
zypper -n install -f ${NEW_PACKAGE_LIST}
elif [[ "${DIST}" == "RHEL6" ]] || [[ "${DIST}" == "RHEL7" ]] || [[ "${DIST}" == "CENTOS6" ]] || [[ "${DIST}" == "CENTOS7" ]]; then
if [[ -n ${REMOVE_PACKAGE_LIST} ]]; then
rpm -e --nodeps ${REMOVE_PACKAGE_LIST}
fi
if [[ true == "${REINSTALL_SAME_VERSION}" ]]; then
yum -y reinstall ${NEW_PACKAGE_LIST}
else
yum -y --tolerant downgrade ${NEW_PACKAGE_LIST}
fi
fi
if [[ $? -ne 0 ]]; then
enable_repos
echo "Downgrade failed, good luck."
exit 1
else
enable_repos
echo "Downgrade done, re-starting services..."
fi
startAllServices
waitTillAppsuiteReady
FINISHED_AT=$(date)
echo "====================================================================================="
echo "Started at: $STARTED_AT"
echo "Finished at: $FINISHED_AT"
echo "
Note: There may now be left-over repositories which contain newer packages. Please take care of them manually.
Downgrade complete, thanks for using OX App Suite. Have a lot of fun!
"
......@@ -65,6 +65,7 @@ esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
writeFrontendRepository
PACKAGES="open-xchange-appsuite open-xchange-appsuite-help* "
installPackagesRetry "${PACKAGES}"
......
#!/bin/bash
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P)"
# sourcing some commonly used functions and executing basic checks
source ${SCRIPT_DIR}/../lib/common.bash
source ${SCRIPT_DIR}/../lib/setup.bash
STARTED_AT=$(date)
REINSTALL_SAME_VERSION=false
## Help text
show_usage() {
echo -n "
"
}
### reading config from command line; overriding defaults
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
show_usage
exit 0
shift
;;
--debug)
echo "WARNING: Debug flag set (--debug)"
set -x
shift
;;
--foo) # non value argument
INSTALL_FOO=true
shift
;;
*) # unknown option
echo "Unknonwn option: $1"
POSITIONAL+=("$1") # save it in an array for later
shift
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# source upgrade versions
exportProperties ${SCRIPT_DIR}/versions.upgrade
checkRootPrivileges
detectDistribution
# Checking for already installed version
checkInstalled
if [[ $? != 0 ]]; then
echo "No OX App Suite installation has been found on this machine."
exit 1
fi
# Disabling all repos
function disable_repos {
if [[ true == "${ANY_DEB}" ]]; then
APT_PATHS=( "/etc/apt/" "/etc/apt/sources.list.d/" )
for j in "${APT_PATHS[@]}"; do
cd "$j"
for i in *.list; do
if [[ -n $i ]]; then
mv "$i" "${i/.list/.list.disabled_by_appsuite_upgrade}"
fi
done
done
fi
}
# Enabling all repos
function enable_repos {
if [[ true == "${ANY_DEB}" ]]; then
APT_PATHS=( "/etc/apt/" "/etc/apt/sources.list.d/" )
for j in "${APT_PATHS[@]}"; do
cd "$j"
for i in *.list.disabled_by_appsuite_upgrade; do
if [[ -n $i ]]; then
mv "$i" "${i/.list.disabled_by_appsuite_upgrade/.list}"
fi
done
done
fi
}
disable_repos
# TODO: this still needs to be refactored somehow
writeRepositories
writeUsmEasRepository
writeGuardRepository
# Check what components are installed
if [[ true == "${ANY_DEB}" ]]; then
dpkg-query -l 'open-xchange-gui' > /dev/null 2>&1
if [[ $? == 0 ]]; then
LEGACY_UI=true
fi
dpkg-query -l 'open-xchange-documents-backend' > /dev/null 2>&1
if [[ $? == 0 ]]; then
AS_OFFICE=true
fi
dpkg-query -l 'open-xchange-documentconverter' > /dev/null 2>&1
if [[ $? == 0 ]]; then
AS_OFFICE_DOCUMENT_PREVIEW=true
fi
elif [[ true == "${ANY_SLES}" ]]; then
rpm -qi open-xchange-gui > /dev/null 2>&1
if [[ $? == 0 ]]; then
LEGACY_UI=true
fi
rpm -qi open-xchange-documents-backend > /dev/null 2>&1
if [[ $? == 0 ]]; then
AS_OFFICE=true
fi
rpm -qi open-xchange-documentconverter > /dev/null 2>&1
if [[ $? == 0 ]]; then
AS_OFFICE_DOCUMENT_PREVIEW=true
fi
elif [[ true == "${ANY_CENTOS}" ]] || [[ true == "${ANY_RHEL}" ]]; then
rpm -qi open-xchange-gui > /dev/null 2>&1
if [[ $? == 0 ]]; then
LEGACY_UI=true
fi
rpm -qi open-xchange-documents-backend > /dev/null 2>&1
if [[ $? == 0 ]]; then
AS_OFFICE=true
fi
rpm -qi open-xchange-documentconverter > /dev/null 2>&1
if [[ $? == 0 ]]; then
AS_OFFICE_DOCUMENT_PREVIEW=true
fi
fi
# stopping services
stopAllServices
if [[ "${DIST}" == "DebianJessie" ]] || [[ "${DIST}" == "DebianStretch" ]] || [[ "${DIST}" == "DebianBuster" ]]; then
export UCF_FORCE_CONFFNEW=1
apt-get clean
apt-get update
apt-get -y -o Dpkg::Options::="--force-confnew" dist-upgrade
elif [[ "${DIST}" == "SLES12" ]]; then
# todo
zypper ref
zypper -n dup
update-alternatives --set java /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java 2>/dev/null
elif [[ "${DIST}" == "RHEL6" ]] || [[ "${DIST}" == "RHEL7" ]] || [[ "${DIST}" == "CENTOS6" ]] || [[ "${DIST}" == "CENTOS7" ]]; then
yum clean all
yum -y upgrade
fi
startAllServices
waitTillAppsuiteReady
FINISHED_AT=$(date)
echo "====================================================================================="
echo "Started at: $STARTED_AT"
echo "Finished at: $FINISHED_AT"
echo "
Update complete, thanks for using OX App Suite. Have a lot of fun!
"
FOO_VAR_TEST=WULLEWULLE
# Set versions per component.
# This file will be sourced when calling install scripts.
# Change this to "EXT" to setup OX App Suite using repositories at
# software.open-xchange.com.
# Also make sure to adapt the versioning scheme below.
AS_REPO_SOURCE=OBS
# Change this to "EXT" for a wforce setup using repositories at dovecot.fi.
# Make sure to adapt the versioning scheme below.
WF_REPO_SOURCE=OBS
# Credentials for restricted OX App Suite repositories at
# software.open-xchange.com.
# AS_USER="<YOUR CUSTOMER USER NAME>"
# AS_PASS="<YOUR CUSTOMER USER PASSWORD>"
# Credentials for restricted wforce repositories at dovecot.fi.
# WF_USER="<YOUR CUSTOMER USER NAME>"
# WF_PASS="<YOUR CUSTOMER USER PASSWORD>"
# Different versions/repos per component can be provided. If you don't want to
# install a component, just set its version to "" or remove the corresponding line.
# When using "EXT" as *_REPO_SOURCE, different versioning schemes may apply (e.g.
# "stable" instead of "develop")
AS_BACKEND_VERSION="master"
AS_FRONTEND_VERSION="master"
AS_FRONTEND_LEGACY_VERSION=""
AS_OFFICE_VERSION="master"
AS_OFFICE_FRONTEND_VERSION="master"
AS_OFFICE_COLLABORATION_VERSION="master"
AS_DOCUMENTCONVERTER_VERSION="master"
AS_DOCUMENTCONVERTER_API_VERSION="master"