HEX
Server: Apache
System: Linux hz.vslconceptsdomains.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: dkfounda (3233)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //var/lib/dpkg/info/cpanel-roundcubemail.preinst
#!/bin/sh

set -e

export ROUNDCUBE_ROOT=/usr/local/cpanel/base/3rdparty/roundcube
export ROUNDCUBE_DATA=/var/cpanel/roundcube

## <asset scriplets/pre>


# shared script with debian/preinst and rpm %pre
# please keep these two in sync
runPreInst() {

    # check to see if we're NOT in an initial install situation (there will be no database to backup) #
    if [ "x$CPANEL_BASE_INSTALL" != "x" ];
    then
        /bin/echo "No MySQL server (or tools) are available, skipping roundcube database backup."
        /bin/echo "NOTE: Fresh installs will not have a database to backup."
        return
    fi

    # do a backup of the existing database if the database exists #
    HAS_DB=$(perl -e 'qx{mysqlshow roundcube >/dev/null 2>&1}; print qq[ok] if $? == 0')
    if [ "x${HAS_DB}" = "x" ]; then
        /bin/echo 'No existing Roundcube database detected; skipping database backup.'
        return
    fi
    DATE="$(date '+%s')"
    BACKUP_FILE=${ROUNDCUBE_DATA}/roundcube.backup.sql.${DATE}
    /bin/echo "Archiving current Roundcube data to ${BACKUP_FILE}"
    mysqldump --no-create-db --skip-comments --complete-insert \
        --ignore-table=roundcube.cache --ignore-table=roundcube.session \
        --ignore-table=roundcube.messages --databases roundcube \
        > ${BACKUP_FILE}
    /bin/echo "Roundcube DB successfully archived"
    # ensure the latest backup symlink is correct #
    /bin/ln -sf ${BACKUP_FILE} ${ROUNDCUBE_DATA}/latest
}

## </asset>


case "$1" in
  install)
    runPreInst;
  ;;
esac

exit 0