3.1.7p1 update only chnanged files?

Discussion in 'ISPConfig 3 Priority Support' started by radim_h, Oct 6, 2017.

  1. radim_h

    radim_h Member HowtoForge Supporter

    Hello,
    my ISPC is bi tmodified, i do not want go through complete update. from 3.1.7 Is it possible to download only changed files?
    I'm not using Centos, bt i'm using remote api with server_get_app_version

    RH
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

  3. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

  4. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    I have written a small script that works in these cases:
    Code:
    #!/bin/bash
    if [[ -d "/tmp/ispconfig3" ]] ; then
        echo "There is a dir /tmp/ispconfig3. Please delete it before you run this." ;
        exit 1 ;
    fi
    
    if [[ ! -f "/usr/local/ispconfig/server/lib/config.inc.php" ]] ; then
        echo "Could not find ISPConfig 3 on this server." ;
        exit 1;
    fi
    
    VERSION=$(grep "'ISPC_APP_VERSION'" /usr/local/ispconfig/server/lib/config.inc.php | awk -F "'" '{print $4}');
    if [[ "$VERSION" == "" ]] ; then
        echo "Could not get ISPConfig 3 version from this server." ;
        exit 1;
    fi
    
    if [[ "$VERSION" == *"dev" ]] ; then
        echo "You are running a development (git) version of ISPConfig, so this script cannot work." ;
        exit 1;
    fi
    
    GIT=$(which git);
    if [[ "$GIT" == "" || ! -e "$GIT" ]] ; then
        echo "You need git for this script to work." ;
        exit 1;
    fi
    
    echo -n "Cloning ISPConfig3 repository ... ";
    cd /tmp && git clone "https://git.ispconfig.org/ispconfig/ispconfig3.git" > /dev/null 2>&1
    echo "Done.";
    cd /tmp/ispconfig3
    
    TAG=$(git tag | grep "^$VERSION\$");
    if [[ "$TAG" == "" ]] ; then
        echo "Could not find tag $VERSION in ISPConfig3 repository." ;
        exit 1;
    fi
    
    LASTTAG=$(git tag | xargs -I@ git log --format=format:"%ai @%n" -1 @ | sort | awk '{print $4}' | grep '^[0-9]' | grep -v 'dev' | tail -n 1) ;
    echo "Latest version tag is $LASTTAG.";
    
    read -p "Continue? (y/n)" ANSWER
    if [[ "$ANSWER" != "y" ]] ; then
        echo "Aborted.";
        exit 1;
    fi
    
    echo -n "Creating diff from repository (${TAG}...${LASTTAG}) ... ";
    git diff --patch ${TAG}...${LASTTAG} -- . ':!install' > /tmp/ispc3_patch.diff
    echo "Done.";
    
    if [[ ! -s "/tmp/ispc3_patch.diff" ]] ; then
        echo "Invalid patch file created (maybe no patches found).";
        exit 1;
    fi
    
    echo -n "Checking if diff could be applied ... ";
    OK=$(patch -p1 --dry-run -i /tmp/ispc3_patch.diff -d /usr/local/ispconfig >/dev/null 2>&1 ; echo $?) ;
    if [[ "$OK" != "0" ]] ; then
        rm -rf /tmp/ispconfig3
        rm -f /tmp/ispc3_patch.diff
        echo "FAILED.";
        echo "Maybe your local ISPConfig version was modified." ;
        exit 1;
    fi
    echo "OK";
    
    echo "WARNING: USE AT YOUR OWN RISK!";
    echo "THIS PATCH WON'T RECONFIGURE SERVICES ETC, SO YOUR INSTALL MIGHT BE BROKEN AFTER THIS.";
    echo "USE ONLY ON PATCH LEVEL VERSIONS AND IF YOU KNOW, WHAT YOU ARE DOING!";
    read -p "Continue to apply patches? (y/n)" ANSWER
    if [[ "$ANSWER" != "y" ]] ; then
        echo "Aborted.";
        exit 1;
    fi
    
    echo "Will now apply patches ..."
    patch -p1 -i /tmp/ispc3_patch.diff -d /usr/local/ispconfig >/dev/null
    echo "Done."
    
    rm -rf /tmp/ispconfig3
    rm -f /tmp/ispc3_patch.diff
    
    sed -i -r "s/'${VERSION}'/'${LASTTAG}'/g" /usr/local/ispconfig/server/lib/config.inc.php
    sed -i -r "s/'${VERSION}'/'${LASTTAG}'/g" /usr/local/ispconfig/interface/lib/config.inc.php
    
    echo "Finished patch. You should now be at version ${LASTTAG}.";
    
    exit 0;
     
    radim_h, till and ztk.me like this.
  5. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Fixed a small typo.
     
  6. radim_h

    radim_h Member HowtoForge Supporter

    Hello,
    thank you. I need to run script only on master server ?
     
  7. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    As every update of ISPConfig it only updates the server you run it on. So it is better to do it on every server.
     
    radim_h likes this.

Share This Page