From d14fbb732b01746acaf84ccd738d68e9f2758ee9 Mon Sep 17 00:00:00 2001 From: bigeagle Date: Sun, 11 Dec 2016 15:14:30 +0800 Subject: [PATCH] updated nodesource --- nodesource.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/nodesource.sh b/nodesource.sh index b513a7f..f5b6a72 100755 --- a/nodesource.sh +++ b/nodesource.sh @@ -3,18 +3,25 @@ function sync_nodesource() { repo_url="$1" repo_dir="$2" + lftp_opts="$3" - [ ! -d "$repo_dir" ] && mkdir -p "$repo_dir" + [[ ! -d "$repo_dir" ]] && mkdir -p "$repo_dir" cd $repo_dir - lftp "${repo_url}/" -e "mirror --verbose -P 5 --delete --only-newer; bye" + lftp "${repo_url}/" -e "mirror --verbose $lftp_opts -P 5 --delete --only-newer; bye" } -sync_nodesource "https://deb.nodesource.com/node" "${TUNASYNC_WORKING_DIR}/deb" -sync_nodesource "https://deb.nodesource.com/node_0.12" "${TUNASYNC_WORKING_DIR}/deb_0.12" -sync_nodesource "https://deb.nodesource.com/node_4.x" "${TUNASYNC_WORKING_DIR}/deb_4.x" -sync_nodesource "https://deb.nodesource.com/node_6.x" "${TUNASYNC_WORKING_DIR}/deb_6.x" +DEB_BASE_URL="https://deb.nodesource.com" +RPM_BASE_URL="https://rpm.nodesource.com" -sync_nodesource "https://rpm.nodesource.com/pub" "${TUNASYNC_WORKING_DIR}/rpm" -sync_nodesource "https://rpm.nodesource.com/pub_0.12" "${TUNASYNC_WORKING_DIR}/rpm_0.12" -sync_nodesource "https://rpm.nodesource.com/pub_4.x" "${TUNASYNC_WORKING_DIR}/rpm_4.x" -sync_nodesource "https://rpm.nodesource.com/pub_6.x" "${TUNASYNC_WORKING_DIR}/rpm_6.x" +node_versions=("0.10" "0.12" "4.x" "6.x") +declare success=true + +for ver in ${node_versions[@]}; do + sync_nodesource "${DEB_BASE_URL}/node_${ver}" "${TUNASYNC_WORKING_DIR}/deb_${ver}" "--exclude db/ --exclude conf/" || success=false +done + +for ver in ${node_versions[@]}; do + sync_nodesource "${RPM_BASE_URL}/pub_${ver}" "${TUNASYNC_WORKING_DIR}/rpm_${ver}" || success=false +done + +[[ $success == true ]] && exit 0 || exit 1