From 3a6167bf48a7d47e18b11a8185028282d7aaf33c Mon Sep 17 00:00:00 2001 From: bigeagle Date: Sun, 6 Nov 2016 22:03:05 +0800 Subject: [PATCH] elastic stack --- ELK.sh | 2 -- elastic.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100755 elastic.sh diff --git a/ELK.sh b/ELK.sh index 852b181..42c8189 100755 --- a/ELK.sh +++ b/ELK.sh @@ -51,8 +51,6 @@ EOF for repo in "${!REPO_VERSIONS[@]}"; do for version in ${REPO_VERSIONS[$repo]}; do -yum_url= -dest_path="${APT_PATH}/${repo}/${version}" cat <> ${cfg} [${repo}-${version}] name=${repo} ${version} packages diff --git a/elastic.sh b/elastic.sh new file mode 100755 index 0000000..f652b7b --- /dev/null +++ b/elastic.sh @@ -0,0 +1,69 @@ +#!/bin/bash +set -e +set -o pipefail + +_here=`dirname $(realpath $0)` +. ${_here}/helpers/apt-download + +[ -z "${LOADED_APT_DOWNLOAD}" ] && (echo "failed to load apt-download"; exit 1) + +BASE_URL=${TUNASYNC_UPSTREAM_URL:-"https://artifacts.elastic.co"} + +BASE_PATH="${TUNASYNC_WORKING_DIR%/}" +BASE_URL="${BASE_URL%/}" + +ELASTIC_VERSION=("5.x") + +YUM_PATH="${BASE_PATH}/yum" +APT_PATH="${BASE_PATH}/apt" + +mkdir -p ${YUM_PATH} ${APT_PATH} + +# =================== APT repos =============================== +if [[ ! -z ${DRY_RUN:-} ]]; then + export APT_DRY_RUN=1 +fi + +for elsver in "${ELASTIC_VERSION[@]}"; do + mkdir -p ${BASE_PATH}/${elsver} + + apt_url="${BASE_URL}/packages/${elsver}/apt" + dest_path="${APT_PATH}/${elsver}" + + apt-download-binary ${apt_url} "stable" "main" "amd64" "${dest_path}" || true + apt-download-binary ${apt_url} "stable" "main" "i386" "${dest_path}" || true + + ln -sf "${APT_PATH}/${elsver}" "${BASE_PATH}/${elsver}/apt" +done + +# # ================ YUM/DNF repos =============================== + +cache_dir="/tmp/yum-elastic-cache/" +cfg="/tmp/yum-elastic.conf" +cat < ${cfg} +[main] +keepcache=0 + +EOF + +for elsver in "${ELASTIC_VERSION[@]}"; do +cat <> ${cfg} +[elastic-${elsver}] +name=elastic stack ${elsver} packages +baseurl=${BASE_URL}/packages/${elsver}/yum +repo_gpgcheck=0 +gpgcheck=0 +enabled=1 +sslverify=0 + +EOF +done + +if [[ -z ${DRY_RUN:-} ]]; then + reposync -c $cfg -d -p ${YUM_PATH} -e ${cache_dir} + for elsver in ${ELASTIC_VERSION[@]}; do + createrepo --update -v -c ${cache_dir} -o ${YUM_PATH}/elastic-${elsver}/ ${YUM_PATH}/elastic-${elsver}/ + ln -sf ${YUM_PATH}/elastic-${elsver} ${BASE_PATH}/${elsver}/yum + done +fi +rm $cfg