#!/bin/bash USAGE="on_libs.sh clone|pull REPO_URL has to be set in enviroment: example: export REPO_URL=https://rlung.librecloud.online " REPO_URL=${REPO_URL:-ssh://git@rlung.librecloud.online:32225} [ "$1" == "-h" ] && echo -e "$USAGE" && exit 1 LIST=" Bin library|LibreCloud/lib_bin CLDS Library|LibreCloud/lib_clds Datastore Library|LibreCloud/lib_datastores Datastore defs Library|LibreCloud/lib_datastores_defs Datastore Conectors Library|LibreCloud/lib_datastores_connectors Defs Library|LibreCloud/lib_defs GraphQL Library|LibreCloud/lib_graphql Key of Life Library|LibreCloud/lib_key_of_life Macros Library|LibreCloud/lib_macros Utils Library|LibreCloud/lib_utils Tkdr Library|LibreCloud/lib_tkdr Webenv library|LibreCloud/lib_webenv Wrap Webservices Handlers Library|LibreCloud/lib_wraphandlers Wrap Webservices Filters Library|LibreCloud/lib_wrapfilters " [ -z "$REPO_URL" ] && echo "REPO_URL not found in enviroment" && exit 1 case "$1" in clone|c) TASK="clone" ;; pull|p) TASK="pull" ;; *) echo "TASK $1 not defined" ; exit 1 esac while read -r line do name=$(echo "$line" | cut -f1 -d"|") lib_path=$(echo "$line" | cut -f2 -d"|") [ -z "$name" ] || [ -z "$lib_path" ] && continue echo -n "$name ... $TASK ... " case "$TASK" in clone) echo "" name=$(echo $(basename "$lib_path") | sed 's/lib_//g' | sed 's,_,/,g') if [ ! -d "$name" ] ; then git clone "$REPO_URL/$lib_path.git" "$name" fi ;; pull) dir_path=$(basename "$lib_path"| sed 's/lib_//g') if [ -d "$dir_path" ] && [ -d "$dir_path/.git" ]; then echo "" cd "$dir_path" || continue git pull cd .. else echo "Dir: $dir_path with .git not found" fi ;; esac done < <((echo "$LIST"))