diff --git a/main/core/ChangeLog b/main/core/ChangeLog index e2a17d5bae..a97f947c9e 100755 --- a/main/core/ChangeLog +++ b/main/core/ChangeLog @@ -1,3 +1,6 @@ +8.0.1 + + Improve disabling of unattended-upgrade + + Remove release-upgrade script 8.0.0 + Set version to 8.0.0 + Remove deprecated build dep diff --git a/main/core/debian/changelog b/main/core/debian/changelog index 67b12be910..93fb0137ab 100644 --- a/main/core/debian/changelog +++ b/main/core/debian/changelog @@ -1,3 +1,9 @@ +zentyal-core (8.0.1) jammy; urgency=high + + * New upstream release + + -- Daniel Joven Wed, 10 Apr 2024 15:20:31 +0100 + zentyal-core (8.0.0) jammy; urgency=medium * New upstream release diff --git a/main/core/debian/zentyal-core.postinst b/main/core/debian/zentyal-core.postinst index ef1df4b2fc..ebdac0a612 100644 --- a/main/core/debian/zentyal-core.postinst +++ b/main/core/debian/zentyal-core.postinst @@ -127,9 +127,13 @@ case "$1" in chmod 644 /etc/zentyal/pre-save/README chmod 644 /etc/zentyal/post-save/README - # Remove unattended-upgrade - sed -i 's/1/0/g' /etc/apt/apt.conf.d/20auto-upgrades - systemctl disable --now unattended-upgrades + # Disable unattended-upgrade + if dpkg -l | grep -qo ' unattended-upgrades '; then + if [[ -f '/etc/apt/apt.conf.d/20auto-upgrades' ]]; then + sed -i 's/1/0/g' /etc/apt/apt.conf.d/20auto-upgrades + fi + systemctl disable --now unattended-upgrades + fi dpkg-trigger --no-await zentyal-core ;; diff --git a/main/core/src/scripts/release-upgrade b/main/core/src/scripts/release-upgrade deleted file mode 100755 index da9a33c304..0000000000 --- a/main/core/src/scripts/release-upgrade +++ /dev/null @@ -1,658 +0,0 @@ -#!/usr/sbin/env bash - -# Debug -# set -x - -#### -## Variables -#### - -SOURCES=/etc/apt/sources.list -UPGRADE_FILE=/var/lib/zentyal/.upgrade-finished -TMPFILE=/tmp/packages-list -LOG_FILE="/var/log/zentyal/upgrade.log" -LOG_DATE="$(date "+%d-%m-%Y %H:%M:%S") " -CURCODE='focal' -DSTCODE='jammy' -CURMAJORV=$(dpkg -l|grep zentyal-core | awk '{print $3}' | cut -d'.' -f1) -CURMINORV=$(dpkg -l|grep zentyal-core | awk '{print $3}' | cut -d'.' -f2) -DESTMAJOR=$(curl -s http://update.zentyal.org/update-from-${CURMAJORV}.${CURMINORV}.txt | cut -d '.' -f1) -DESTMINOR=$(curl -s http://update.zentyal.org/update-from-${CURMAJORV}.${CURMINORV}.txt | cut -d '.' -f2) -CURRV="${CURMAJORV}.${CURMINORV}" -DESTV="${DESTMAJOR}.${DESTMINOR}" -ZEN_REPO_KEY_URL='https://keys.zentyal.org/' -ZEN_REPO_KEY_NAME="zentyal-${DESTV}-packages-org.asc" -ZEN_REPO_URL='https://packages.zentyal.org/zentyal' -BACKUP_DB_WEBMAIL='/var/lib/zentyal/upgrade_backup-sogo.sql' - -#### -## Functions -#### - -function checkZentyalVersion -{ - echo "${LOG_DATE} ... Checking the zentyal-core version" | tee -a ${LOG_FILE} - - if [ $CURMAJORV -gt $DESTMAJOR ]; then - echo "${LOG_DATE} ...... Your system is up to date" | tee -a ${LOG_FILE} - exit 130 - elif [ $DESTMAJOR -gt $CURMAJORV ]; then - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} - elif [ $CURMINORV -gt $DESTMINOR ] || [ $CURMINORV -eq $DESTMINOR ]; then - echo "${LOG_DATE} ...... Your system is up to date" | tee -a ${LOG_FILE} - exit 130 - fi -} - -function checkDiskSpace -{ - echo "${LOG_DATE} ... Checking for available disk space" | tee -a ${LOG_FILE} - - if [ $(df /boot | tail -1 | awk '{print $4}') -lt 250000 ]; - then - echo "${LOG_DATE} ...... Upgrade cannot be performed due to insufficient disk space (less than 250 MB available on /boot)" | tee -a ${LOG_FILE} - exit 130 - fi - - for i in / /var - do - if [ `df $i | tail -1 | awk '{print $4}'` -lt 3072000 ]; - then - echo "${LOG_DATE} ...... Upgrade cannot be performed due to insufficient disk space (less than 3GB available on $i)" | tee -a ${LOG_FILE} - exit 130 - fi - done - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function checkInternetAccess -{ - echo "${LOG_DATE} ... Checking if there is Internet" | tee -a ${LOG_FILE} - - if ! ping -4 -W 15 -q -c 5 google.es 2> /dev/null; then - echo "${LOG_DATE} ...... There is not Internet connection and it is required for the upgrade" | tee -a ${LOG_FILE} - exit 130 - fi - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function checkPendingPackages -{ - echo "${LOG_DATE} ... Checking if the server is up-to-date" | tee -a ${LOG_FILE} - - IFS=';' read updates security_updates < <(/usr/lib/update-notifier/apt-check 2>&1) - if (( $updates != 0 )) && (( $security_updates != 0 )); then - echo "${LOG_DATE} ...... There are $updates updates available and $security_updates security updates available, please, install them before to upgrade your system" | tee -a ${LOG_FILE} - exit 130 - fi - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function checkUbuntuReposotories -{ - echo "${LOG_DATE} ... Setting Ubuntu repositories if not present" | tee -a ${LOG_FILE} - - if ! grep -v "^#" $SOURCES | grep -q "ubuntu.com" - then - echo "${LOG_DATE} ...... Adding repositories" | tee -a ${LOG_FILE} - - echo "deb http://archive.ubuntu.com/ubuntu/ $DSTCODE main restricted universe multiverse" >> $SOURCES - echo "deb http://archive.ubuntu.com/ubuntu/ $DSTCODE-updates main restricted universe multiverse" >> $SOURCES - echo "deb http://security.ubuntu.com/ubuntu/ $DSTCODE-security main restricted universe multiverse" >> $SOURCES - fi - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function repairPkgs -{ - echo "${LOG_DATE} ...... Trying to fix the following broken packages" | tee -a ${LOG_FILE} - - local PKGS=$(dpkg -l | grep -vE '^(ii|rc|hi)'| awk '{ if ( NR > 5 ) { print $2} }') - for pkg in ${PKGS}; do - echo "...... Broken package: ${pkg}" | tee -a ${LOG_FILE} - done - - for i in {1..10}; do - dpkg --configure --force-confdef -a - done - - echo "${LOG_DATE} ...... OK" | tee -a ${LOG_FILE} -} - -function checkBrokenPackages -{ - echo "${LOG_DATE} ... Checking if there are broken packages" | tee -a ${LOG_FILE} - - dpkg -l | grep 'zentyal-' - touch $TMPFILE && dpkg -l | awk '{ if ( NR > 5 ) { print } }' > $TMPFILE - - if grep -vE '^(ii|rc|ic|hi)' $TMPFILE - then - if [[ $(systemctl is-active redis) != 'active' ]] - then - echo "${LOG_DATE} ...... Restarting Redis" | tee -a ${LOG_FILE} - systemctl restart redis - fi - echo "${LOG_DATE} ...... There are broken packages" | tee -a ${LOG_FILE} - repairPkgs - fi - rm -f $TMPFILE - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function checkGPG -{ - echo "${LOG_DATE} ... Looking for gnupg package" | tee -a ${LOG_FILE} - - dpkg -s gnupg &> /dev/null - if [ $? -ne 0 ]; then - echo "${LOG_DATE} ...... Package is NOT installed! Trying to install it" | tee -a ${LOG_FILE};echo - apt install gnupg -y - fi - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function checkZentyalMySQL -{ - echo "${LOG_DATE} ... Checking Zentyal's MySQL db" | tee -a ${LOG_FILE} - - mysqlcheck --databases zentyal - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function cleanPreviousUpgrade -{ - echo "${LOG_DATE} ... Cleaning $UPGRADE_FILE if exists" | tee -a ${LOG_FILE} - - if [ -f $UPGRADE_FILE ] - then - rm -f $UPGRADE_FILE - fi - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function prepareUpgrade -{ - checkZentyalVersion - checkDiskSpace - checkInternetAccess - checkPendingPackages - checkUbuntuReposotories - checkBrokenPackages - checkGPG - checkZentyalMySQL - cleanPreviousUpgrade -} - -function ensureInternet -{ - if ! ping -4 -W 15 -q -c 5 google.es 2> /dev/null; then - zs network restart - fi -} - -function upgradePackages -{ - echo "${LOG_DATE} ... Upgrading the system" - - export DEBIAN_FRONTEND=noninteractive - apt update - apt dist-upgrade -y -o DPkg::Options::="--force-overwrite" -o DPkg::Options::="--force-confdef" - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} - checkBrokenPackages - apt clean -} - -function prepareUbuntuRepositories -{ - echo "${LOG_DATE} ... Setting new Ubuntu repositories" | tee -a ${LOG_FILE} - - sed -i "s/^deb-src/#deb-src/g" /etc/apt/sources.list - sed -i "s/$CURCODE/$DSTCODE/g" /etc/apt/sources.list - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function prepareZentyalRepositories -{ - echo "${LOG_DATE} ... Adding required repositories for Zentyal..." | tee -a ${LOG_FILE} - - # Remove existing Zentyal and Suricata repositories - for url in packages.zentyal.com packages.zentyal.org archive.zentyal.org archive.zentyal.com suricata-stable - do - sed -i "/${url}/d" /etc/apt/sources.list - - for repo in $(find /etc/apt/sources.list.d/ -type f) - do - sed -i "/${url}/d" ${repo} - done - done - - # Set up Zentyal repository - wget -q ${ZEN_REPO_KEY_URL}/${ZEN_REPO_KEY_NAME} -P /etc/apt/trusted.gpg.d/ - echo "deb [signed-by=/etc/apt/trusted.gpg.d/${ZEN_REPO_KEY_NAME}] ${ZEN_REPO_URL} ${DESTV} main extra" > /etc/apt/sources.list.d/zentyal.list - - ## Set up Docker repository for zentyal-docker module - if [[ ! -f /etc/apt/trusted.gpg.d/docker.gpg ]]; then - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg - fi - chmod 0644 /etc/apt/trusted.gpg.d/docker.gpg - echo "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list - - ## Set up Firefox repository for zenbuntu-desktop package - wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- > /etc/apt/trusted.gpg.d/packages.mozilla.org.asc - chmod 0644 /etc/apt/trusted.gpg.d/packages.mozilla.org.asc - echo "deb [signed-by=/etc/apt/trusted.gpg.d/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" > /etc/apt/sources.list.d/mozilla.list -cat < /etc/apt/preferences.d/mozilla -Package: * -Pin: origin packages.mozilla.org -Pin-Priority: 1000 -EOF - - apt update - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function configurationNetwork -{ - echo "${LOG_DATE} ...... Configuring Network module" | tee -a ${LOG_FILE} - - find /etc/netplan/ -type f -exec rm -f {} \; - - mkdir /etc/connman/ - local NIC=$(ip -o link show | grep -v 'lo' | awk -F': ' '{print $2}' | tr '\n' ',' | sed 's/,$//') - echo -e "[General]\nNetworkInterfaceBlacklist=$NIC" > /etc/connman/main.conf - - echo "${LOG_DATE} ...... OK" | tee -a ${LOG_FILE} -} - -function configurationDNS -{ - echo "${LOG_DATE} ...... Configuring DNS module" | tee -a ${LOG_FILE} - - rm -f /etc/systemd/system/named.service.wants/fix-744304.conf - - for file in /usr/share/zentyal/stubs/dns/named.conf.options.mas /etc/zentyal/stubs/dns/named.conf.options.mas /etc/bind/named.conf.options; do - if [ -f ${file} ]; then - sed -i "/dnssec-enable/d" ${file} - fi - done - - systemctl restart named - - echo "${LOG_DATE} ...... OK" | tee -a ${LOG_FILE} -} - -function configurationJabber -{ - # This function is created as a workaround for the bug: https://bugs.launchpad.net/ubuntu/+source/ejabberd/+bug/1970791 - - echo "${LOG_DATE} ... Configuring Ejabberd module" | tee -a ${LOG_FILE} - - if [[ $(systemctl is-enabled ejabberd) == 'enabled' ]]; then - systemctl stop ejabberd - fi -cat < /lib/systemd/system/ejabberd.service -[Unit] -# Bug: https://bugs.launchpad.net/ubuntu/+source/ejabberd/+bug/1970791 -Description=Custom workaround: Robust, scalable and extensible realtime platform (XMPP server + MQTT broker + SIP service) -Documentation=https://www.process-one.net/en/ejabberd/docs/ -After=epmd.service network.target -Requires=epmd.service - -[Service] -Type=forking -User=ejabberd -Group=ejabberd -LimitNOFILE=65536 -Restart=on-failure -RestartSec=5 -ExecStart=/bin/sh -c '/usr/sbin/ejabberdctl start && /usr/sbin/ejabberdctl started' -ExecStop=/bin/sh -c '/usr/sbin/ejabberdctl stop && /usr/sbin/ejabberdctl stopped' -ExecReload=/bin/sh -c '/usr/sbin/ejabberdctl reload_config' -PrivateTmp=true -ProtectHome=true -ProtectSystem=full -TimeoutSec=300 - -[Install] -WantedBy=multi-user.target -EOF - systemctl daemon-reload - - sed -i 's/log_rotate_size.*/log_rotate_size: 10485760/' /etc/ejabberd/ejabberd.yml - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function configurationVPN -{ - echo "${LOG_DATE} ...... Configuring OpenVPN module" | tee -a ${LOG_FILE} - - export DEBIAN_FRONTEND=noninteractive - apt update - apt install -y frr - - echo "${LOG_DATE} ...... OK" | tee -a ${LOG_FILE} -} - -function configurationDHCP -{ - echo "${LOG_DATE} ...... Configuring DHCP module" | tee -a ${LOG_FILE} - - if [[ -f /etc/apparmor.d/disable/usr.sbin.dhcpd ]]; then - rm -v /etc/apparmor.d/disable/usr.sbin.dhcpd - fi - - echo "${LOG_DATE} ...... OK" | tee -a ${LOG_FILE} -} - -function configurationDomainController -{ - echo "${LOG_DATE} ...... Configuring Domain Controller module" | tee -a ${LOG_FILE} - - local GET_CUR_VALUE=$(mysql -sN -u root -p$(cat /var/lib/zentyal/conf/zentyal-mysql.passwd) zentyal -e 'SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = "samba_access" AND COLUMN_NAME="username";' 2>/dev/null) - if [ ${GET_CUR_VALUE} == 'varchar(24)' ]; then - echo "${LOG_DATE} ......... Updating column username" | tee -a ${LOG_FILE} - - mysql \ - -u root \ - -p$(cat /var/lib/zentyal/conf/zentyal-mysql.passwd) \ - zentyal \ - -e 'ALTER TABLE samba_access CHANGE username username VARCHAR(50) NULL DEFAULT NULL;' 2>/dev/null - - echo "${LOG_DATE} ......... OK" | tee -a ${LOG_FILE} - fi - - echo "${LOG_DATE} ...... OK" | tee -a ${LOG_FILE} -} - -function configurationMail -{ - echo "${LOG_DATE} ...... Configuring Mail module" | tee -a ${LOG_FILE} - - if [[ ! -s /etc/dovecot/dh.pem ]]; then - cp /usr/share/dovecot/dh.pem /etc/dovecot/dh.pem - chmod 0640 /etc/dovecot/dh.pem - chown root:dovecot /etc/dovecot/dh.pem - fi - - echo "${LOG_DATE} ...... OK" | tee -a ${LOG_FILE} -} - -function configurationSogo -{ - echo "${LOG_DATE} ...... Configuring Webmail module" | tee -a ${LOG_FILE} - - export DEBIAN_FRONTEND=noninteractive - apt install -y -o DPkg::Options::="--force-confdef" zentyal-sogo - - echo "${LOG_DATE} ......... Importing Webmail database" | tee -a ${LOG_FILE} - mysqldump -u root -p$(cat /var/lib/zentyal/conf/zentyal-mysql.passwd) sogo < ${BACKUP_DB_WEBMAIL} - - echo "${LOG_DATE} ...... OK" | tee -a ${LOG_FILE} -} - -function configurationMailFilter -{ - echo "${LOG_DATE} ...... Configuring Mailfilter module" | tee -a ${LOG_FILE} - - local db_name=spamassassin - local db_user=amavis - local db_pass="$(cat /var/lib/zentyal/conf/sa-mysql.passwd)" - local DBA_FILTER="$(mysql -sN -u root -p$(cat /var/lib/zentyal/conf/zentyal-mysql.passwd) -e "select user from mysql.user where user='$db_user';" 2>/dev/null)" - local MOD_STATUS="$(zs mailfilter enabled | cut -d '[' -f2 | tr -d ' ]')" - - if [[ -z ${DBA_FILTER} && ${MOD_STATUS} == 'ENABLED' ]]; then - echo "${LOG_DATE} ......... Adding DBA user" | tee -a ${LOG_FILE} - - echo "CREATE DATABASE IF NOT EXISTS $db_name; - CREATE USER IF NOT EXISTS '$db_user'@'localhost' IDENTIFIED BY \"$db_pass\"; - GRANT ALL PRIVILEGES ON $db_name.* TO '$db_user'@'localhost'; - FLUSH PRIVILEGES;" | mysql --defaults-file=/etc/mysql/debian.cnf - - echo "${LOG_DATE} ......... OK" | tee -a ${LOG_FILE} - fi - - echo "${LOG_DATE} ...... OK" | tee -a ${LOG_FILE} -} - -function configurationDesktop -{ - echo "${LOG_DATE} ...... Configuring zenbuntu-desktop module" | tee -a ${LOG_FILE} - - apt-mark unhold firefox - export DEBIAN_FRONTEND=noninteractive - apt update - apt install -y --reinstall --allow-downgrades firefox - checkBrokenPackages - - - systemctl disable lxdm - systemctl enable zentyal.lxdm - - echo "${LOG_DATE} ...... OK" | tee -a ${LOG_FILE} -} - -function preUbuntuUpgrade -{ - echo "${LOG_DATE} ... Pre configuration before upgrading Ubuntu" | tee -a ${LOG_FILE} - - configurationNetwork - - # DNS configuration - if dpkg -l | grep -qo 'ii zentyal-dns '; then - configurationDNS - fi - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function upgradeUbuntu -{ - echo "${LOG_DATE} ... Upgrading Ubuntu" | tee -a ${LOG_FILE} - - for log in /var/log/zentyal/zentyal.log /var/log/syslog /var/log/dpkg.log; do - echo "## Updating Ubuntu packages" | tee -a ${log} - done - - # Needed to avoid issues during the upgrade - apt-mark hold ${PKG} firefox - - ## Holding Zentyal packages to avoid unexpected removal - PKG=$(dpkg -l | egrep '^ii.*(zenbuntu-|zentyal)' | awk '{print $2}') - apt-mark hold ${PKG} - - upgradePackages - - apt-mark unhold ${PKG} - ensureInternet - - if [[ "$(lsb_release -cs)" != "${DSTCODE}" ]]; then - echo "${LOG_DATE} Ubuntu upgrade FAILED. Full log at ${LOG_FILE} " - exit 130 - fi - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function postUbuntuUpgrade -{ - echo "${LOG_DATE} ... Post configuration after upgrading Ubuntu" | tee -a ${LOG_FILE} - - systemctl disable --now connman - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function preZentyalUpgrade -{ - echo "${LOG_DATE} ... Pre configuration before upgrading Zentyal" | tee -a ${LOG_FILE} - - # Jabber configuration - if dpkg -l | grep -qo 'ii zentyal-jabber '; then - configurationJabber - fi - - # DHCP configuration - if dpkg -l | grep -qo 'ii zentyal-dhcp '; then - configurationDHCP - fi - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function upgradeZentyal -{ - echo "${LOG_DATE} ... Upgrading Zentyal" | tee -a ${LOG_FILE} - - for log in /var/log/zentyal/zentyal.log /var/log/syslog /var/log/dpkg.log; do - echo "## Updating Zentyal packages" | tee -a ${log} - done - - ensureInternet - - if dpkg -l | grep -qo 'ii zentyal-sogo '; then - local WEBMAIL=1 - mysqldump -u root -p$(cat /var/lib/zentyal/conf/zentyal-mysql.passwd) sogo > ${BACKUP_DB_WEBMAIL} - if [[ $(du -s ${BACKUP_DB_WEBMAIL} | awk '{print $1}') -lt 4 ]]; then - echo "${LOG_DATE} Zentyal upgrade FAILED. Could not export Sogo database, full log at ${LOG_FILE} " | tee -a ${LOG_FILE} - exit 130 - else - echo "${LOG_DATE} ...... Sogo database located at '${BACKUP_DB_WEBMAIL}'" | tee -a ${LOG_FILE} - fi - fi - - # OpenVPN configuration - if dpkg -l | grep -qo 'ii zentyal-openvpn '; then - configurationVPN - fi - - # zenbuntu-desktop configuration - if dpkg -l | grep -qo ' zenbuntu-desktop '; then - configurationDesktop - fi - - upgradePackages - - # Webmail configuration - if [[ -n ${WEBMAIL} ]]; then - configurationSogo - fi - - # Check if main zentyal-core package was upgraded - if [[ "$(dpkg -l | grep zentyal-core | awk '{print $3}' | cut -d '.' -f1,2)" != "${DESTV}" ]]; then - echo "${LOG_DATE} Zentyal upgrade FAILED. Full log at ${LOG_FILE}" - exit 130 - fi - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function postZentyalUpgrade -{ - echo "${LOG_DATE} ... Pre configuration before upgrading Zentyal" | tee -a ${LOG_FILE} - - # Ensure unattended-upgrade is disabled - sed -i 's/1/0/' /etc/apt/apt.conf.d/20auto-upgrades - - # Domain Controller configuration - if dpkg -l | grep -qo ' zentyal-samba '; then - configurationDomainController - fi - - # Mail configuration - if dpkg -l | grep -qo ' zentyal-mail '; then - configurationMail - fi - - # Mailfilter configuration - if dpkg -l | grep -qo ' zentyal-mailfilter '; then - configurationMailFilter - fi - - ensureInternet - - # Purge all no longer needed running services - dpkg -l | grep 'zentyal-' | cut -d' ' -f3 | xargs apt-mark manual - apt autoremove --purge -y -o DPkg::Options::="--force-confdef" - dpkg --configure -a --force-confdef - apt -f install -y -o DPkg::Options::="--force-confdef" - checkBrokenPackages - - # Remove packages in 'rc' or 'ic' status - local PKG_TO_REMOVE=$(dpkg -l | egrep '^(rc|ic)' | awk '{print $2}') - if [[ -n ${PKG_TO_REMOVE} ]]; then - echo "${LOG_DATE} ...... Removing packages that are not longer needed" | tee -a ${LOG_FILE} - dpkg --purge ${PKG_TO_REMOVE} - echo "${LOG_DATE} ......OK" | tee -a ${LOG_FILE} - fi - - sleep 2 - apt clean - - ## Send message if stub directory exists: - if [[ -d '/etc/zentyal/stubs/' ]]; then - echo "${LOG_DATE} ...... IMPORTANT: You might have persistant stubs, ensure you have the latest changes" | tee -a ${LOG_FILE} - fi - - echo "${LOG_DATE} ... OK" | tee -a ${LOG_FILE} -} - -function finishUpgrade -{ - sleep 2 - pkill -f upgrade-log-server - touch $UPGRADE_FILE - for log in /var/log/zentyal/zentyal.log /var/log/syslog /var/log/dpkg.log; do - echo "## Update finished" >> ${log} - done -} - - -#### -## Calls -#### - -if [[ -f ${LOG_FILE} ]]; then - rm -f ${LOG_FILE} -fi -touch ${LOG_FILE} - -echo "${LOG_DATE} Preparing your system for the upgrade" | tee -a ${LOG_FILE} -prepareUpgrade -echo "${LOG_DATE} OK" | tee -a ${LOG_FILE} - -echo "${LOG_DATE} Preparing repositories for upgrade to Zentyal ${DESTV}" | tee -a ${LOG_FILE} -prepareUbuntuRepositories -prepareZentyalRepositories -echo "${LOG_DATE} OK" | tee -a ${LOG_FILE} - -echo "${LOG_DATE} Upgrading Ubuntu from ${CURCODE} to ${DSTCODE}" | tee -a ${LOG_FILE} -if [[ $(lsb_release -cs) != "${DSTCODE}" ]]; then - preUbuntuUpgrade - upgradeUbuntu - postUbuntuUpgrade - echo "${LOG_DATE} OK" | tee -a ${LOG_FILE} -else - echo "${LOG_DATE} Ubuntu version is up to date...skkiping" | tee -a ${LOG_FILE} -fi - -echo "${LOG_DATE} Upgrading Zentyal from ${CURMAJORV}.${CURMINORV} to ${DESTMAJOR}.${DESTMINOR}" | tee -a ${LOG_FILE} -preZentyalUpgrade -upgradeZentyal -postZentyalUpgrade -echo "${LOG_DATE} OK" | tee -a ${LOG_FILE} - -echo "${LOG_DATE} Finishing the upgrade" | tee -a ${LOG_FILE} -finishUpgrade