Strabon

annotate scripts/workaround/deploy-local-repo.sh @ 1552:0e334dc20181

bug in google maps key
author Dimitris Bilidas <d.bilidas@di.uoa.gr>
date Mon Nov 09 18:09:06 2020 +0200 (23 months ago)
parents 8495c0c9b597
children
rev   line source
kkyzir@1042 1 #!/bin/bash
kkyzir@1044 2
kkyzir@1044 3 #
kkyzir@1044 4 # This Source Code Form is subject to the terms of the Mozilla Public
kkyzir@1044 5 # License, v. 2.0. If a copy of the MPL was not distributed with this
kkyzir@1044 6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
kkyzir@1044 7 #
kkyzir@1044 8 # Copyright (C) 2010, 2011, 2012, Pyravlos Team
kkyzir@1044 9 #
kkyzir@1044 10 # http://www.strabon.di.uoa.gr/
kkyzir@1044 11 #
kkyzir@1044 12
kkyzir@1044 13 #
kkyzir@1044 14 # Script for deploying a local maven repository to a remote one
kkyzir@1044 15 #
kkyzir@1044 16 # Author: Kostis Kyzirakos <kk@di.uoa.gr>
kkyzir@1044 17 #
kkyzir@1044 18
kkyzir@1044 19
kkyzir@1044 20 # server id that maps on the <id> under <server> section of ~/.m2/settings.xml.
kkyzir@1044 21 # In most cases, this parameter will be required for authentication.
kkyzir@1044 22 DEPLOY_REPO_ID="strabon"
kkyzir@1044 23
kkyzir@1044 24 # the url of the remote repository
kkyzir@1044 25 DEPLOY_REPO_URL="http://maven.strabon.di.uoa.gr/content/repositories/strabon.sesame/"
kkyzir@1044 26
kkyzir@1044 27 # temporary folder
kkyzir@1042 28 TEMP_DIR="/tmp/deploy-local-repo-$$"
kkyzir@1042 29
kkyzir@1044 30 # command name
kkyzir@1044 31 CMD="$(basename ${0})"
kkyzir@1044 32
kkyzir@1044 33 function help() {
kkyzir@1044 34 echo "Usage: ${CMD} [OPTIONS] [DIR]"
kkyzir@1044 35 echo
kkyzir@1044 36 echo "Deploy a local maven repository to a remote one"
kkyzir@1044 37 echo
kkyzir@1044 38 echo " DIR : resume the deployment of the local repository, starting from this directory"
kkyzir@1044 39 echo
kkyzir@1044 40 echo "OPTIONS can be any of the following (variable names and values are case sensitive)"
kkyzir@1044 41 echo " --help : Print this menu"
kkyzir@1044 42 echo ""
kkyzir@1044 43 }
kkyzir@1044 44
kkyzir@1044 45 if [[ ${#} -gt "0" ]] ; then
kkyzir@1044 46 ARRAY=(${@})
kkyzir@1044 47 ELEMENTS=${#ARRAY[@]}
kkyzir@1044 48 for (( i = 0; i < ${ELEMENTS}; i++ )); do
kkyzir@1044 49 if [[ "${ARRAY[${i}]}" = "--help" ]] || [[ "${ARRAY[${i}]}" = "-help" ]] || [[ "${ARRAY[${i}]}" = "help" ]]; then
kkyzir@1044 50 help
kkyzir@1044 51 exit 0
kkyzir@1044 52 fi
kkyzir@1044 53 done
kkyzir@1044 54 fi
kkyzir@1044 55
kkyzir@1042 56 mkdir ${TEMP_DIR}
kkyzir@1042 57 if [[ ! -d "${TEMP_DIR}" ]] ; then
kkyzir@1042 58 echo "Could not create temporary directory."
kkyzir@1042 59 echo "Aborting..."
kkyzir@1042 60 exit
kkyzir@1042 61 fi
kkyzir@1042 62
kkyzir@1044 63 found=false;
kkyzir@1044 64 for d in `find ${HOME}/.m2/repository -type d|sort` ;
kkyzir@1044 65 do
kkyzir@1044 66 if [[ ! -z "$1" ]] && [[ "${found}" = "false" ]] && [[ "$d" != "$1" ]] ; then
kkyzir@1044 67 echo "Skipping ${d}"
kkyzir@1044 68 continue;
kkyzir@1044 69 fi
kkyzir@1044 70 # resuming
kkyzir@1044 71 found=true;
kkyzir@1042 72
kkyzir@1042 73 #for each directory
kkyzir@1042 74 cd ${d}
kkyzir@1044 75 children=`find . -type d|grep -v '^.$'|wc -l`
kkyzir@1044 76 if [[ "${children}" -ne "0" ]] ; then
kkyzir@1042 77 # if the directory has more subdirectories, move one
kkyzir@1042 78 continue;
kkyzir@1042 79 fi
kkyzir@1042 80
kkyzir@1042 81 countPoms=`ls -1 *.pom 2>/dev/null|wc -l`
kkyzir@1044 82 countJars=`ls -1 *.jar 2>/dev/null|wc -l`
kkyzir@1042 83
kkyzir@1042 84 if [[ "${countPoms}" -gt "1" ]] && [[ "${countJars}" -gt "1" ]] ; then
kkyzir@1042 85 echo "Found ${countPoms} poms and ${countJars} jars in directory '${d}'."
kkyzir@1042 86 echo "Aborting..."
kkyzir@1042 87 exit;
kkyzir@1042 88 elif [[ "${countPoms}" -eq "0" ]] ; then
kkyzir@1044 89 echo "No .pom file found in directory '${d}' (${children} children)."
kkyzir@1042 90 echo "Aborting..."
kkyzir@1042 91 exit;
kkyzir@1042 92 fi
kkyzir@1042 93
kkyzir@1042 94 if [[ "${countPoms}" -eq "1" ]] && [[ "${countJars}" -eq "1" ]] ; then
kkyzir@1044 95 pomFile=`ls -1 *.pom 2>/dev/null`
kkyzir@1044 96 jarFile=`ls -1 *.jar 2>/dev/null`
kkyzir@1044 97 cp ${pomFile} ${TEMP_DIR}/${pomFile} 2>/dev/null
kkyzir@1044 98 cp ${jarFile} ${TEMP_DIR}/${jarFile} 2>/dev/null
kkyzir@1042 99 # deploy the local jar file to the remote repo
kkyzir@1042 100 mvn deploy:deploy-file \
kkyzir@1042 101 -DrepositoryId=${DEPLOY_REPO_ID} \
kkyzir@1042 102 -Durl=${DEPLOY_REPO_URL} \
kkyzir@1042 103 -DpomFile=${TEMP_DIR}/${pomFile} \
kkyzir@1042 104 -Dfile=${TEMP_DIR}/${jarFile};
kkyzir@1044 105 if [[ "$?" -ne "0" ]] ; then echo "Error occured while processing directory '${d}' (temp dir is '${TEMP_DIR}')"; exit; fi
kkyzir@1042 106 elif [[ "${countPoms}" -eq "1" ]] && [[ "${countJars}" -eq "0" ]] ; then
kkyzir@1044 107 pomFile=`ls -1 *.pom 2>/dev/null`
kkyzir@1044 108 cp ${pomFile} ${TEMP_DIR}/${pomFile} 2>/dev/null
kkyzir@1042 109 # deploy the local pom file to the remote repo
kkyzir@1042 110 mvn deploy:deploy-file \
kkyzir@1042 111 -DrepositoryId=${DEPLOY_REPO_ID} \
kkyzir@1042 112 -Durl=${DEPLOY_REPO_URL} \
kkyzir@1042 113 -DpomFile=${TEMP_DIR}/${pomFile} \
kkyzir@1042 114 -Dfile=${TEMP_DIR}/${pomFile};
kkyzir@1044 115 if [[ "$?" -ne "0" ]] ; then echo "Error occured while processing directory '${d}' (temp dir is '${TEMP_DIR}'"; exit; fi
kkyzir@1044 116 elif [[ "${countPoms}" -gt "1" ]] && [[ "${countJars}" -eq "0" ]] ; then
kkyzir@1044 117 # deploy the local pom files to the remote repo
kkyzir@1044 118 for pom in `ls -1 *.pom` ; do
kkyzir@1044 119 pomFile=${pom};
kkyzir@1044 120 cp ${pomFile} ${TEMP_DIR}/${pomFile} 2>/dev/null;
kkyzir@1044 121 mvn deploy:deploy-file \
kkyzir@1044 122 -DrepositoryId=${DEPLOY_REPO_ID} \
kkyzir@1044 123 -Durl=${DEPLOY_REPO_URL} \
kkyzir@1044 124 -DpomFile=${TEMP_DIR}/${pomFile} \
kkyzir@1044 125 -Dfile=${TEMP_DIR}/${pomFile};
kkyzir@1044 126 if [[ "$?" -ne "0" ]] ; then echo "Error occured while processing directory '${d}' (temp dir is '${TEMP_DIR}'"; exit; fi
kkyzir@1044 127 done
kkyzir@1042 128 else
kkyzir@1044 129 echo "Found ${countPoms} poms and ${countJars} jars in directory '${d}' (temp dir is '${TEMP_DIR}')."
kkyzir@1042 130 echo "What should I do?"
kkyzir@1042 131 echo "Aborting..."
kkyzir@1042 132 exit;
kkyzir@1042 133 fi
kkyzir@1042 134
kkyzir@1042 135 # grooming
kkyzir@1042 136 rm ${TEMP_DIR}/*
kkyzir@1042 137 done
kkyzir@1042 138
kkyzir@1042 139
kkyzir@1042 140 # grooming
kkyzir@1042 141 rm -rf ${TEMP_DIR}