#!/bin/bash apt -y install apache2 docker-compose rm -r /var/www/html/* cat << 'EOF' > /usr/local/bin/mtm-zmbuild #!/bin/bash BUILDVER=${1} BUILDNO=${2} BUILDCHAIN=${3} show_help() { echo "mtm-zmbuild version buildno buildchain" echo "" echo "Example :" echo " mtm-zmbuild 10.0.5 4574 10.0.5,10.0.4,10.0.3,10.0.2,10.0.1,10.0.0-GA,10.0.0" echo " mtm-zmbuild 10.0.4 4518 10.0.4,10.0.3,10.0.2,10.0.1,10.0.0-GA,10.0.0" } if [ "${BUILDVER}" == "" ] || [ "${BUILDNO}" == "" ] || [ "${BUILDCHAIN}" == "" ]; then show_help exit 1 fi mkdir -p /root/zimbra/${BUILDVER}-${BUILDNO} { echo "#!/bin/bash" echo "BUILDVER=${BUILDVER}" echo "BUILDCHAIN=${BUILDCHAIN}" echo "BUILDNO=${BUILDNO}" echo "apt -y install software-properties-common openjdk-8-jdk ant ant-optional ant-contrib ruby git maven build-essential debhelper rclone rsync" echo "git clone --depth 1 --branch ${BUILDVER} https://github.com/Zimbra/zm-build.git" echo "cd zm-build" echo "ENV_CACHE_CLEAR_FLAG=true ./build.pl --ant-options -DskipTests=true --git-default-tag=${BUILDCHAIN} --build-release-no=${BUILDVER} --build-type=FOSS --build-release=Daffodil --build-release-candidate=GA --build-thirdparty-server=files.zimbra.com --build-no=${BUILDNO} --no-interactive" echo "cp /home/build/BUILDS/UBUNTU*/zcs-*.tgz /root" echo "exit" } > /root/zimbra/${BUILDVER}-${BUILDNO}/build docker run -it --rm -u root -v /root/zimbra/${BUILDVER}-${BUILDNO}:/root zimbra/zm-base-os:devcore-ubuntu-20.04 bash /root/build rm -r /root/zimbra/${BUILDVER}-${BUILDNO}/.* cp /root/zimbra/${BUILDVER}-${BUILDNO}/zcs-*.tgz /var/www/html/zcs-${BUILDVER}.tgz EOF chmod +x /usr/local/bin/mtm-zmbuild if [ -f "/etc/iptables/rules.v4" ]; then sed -i '/^-A INPUT -i lo -j ACCEPT.*/a -A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT' /etc/iptables/rules.v4 iptables-restore /etc/iptables/rules.v4 fi