diff --git a/on_libs.sh b/on_libs.sh new file mode 100755 index 0000000..f226f93 --- /dev/null +++ b/on_libs.sh @@ -0,0 +1,53 @@ +#!/bin/bash +USAGE="on_libs.sh clone|pull + + REPO_URL has to be set in enviroment: + example: export REPO_URL=https://rlung.librecloud.online +" +[ "$1" == "-h" ] && echo -e "$USAGE" && exit 1 +LIST=" +Bin library|LibreCloud/lib_bin +CLDS Library|LibreCloud/lib_clds +Defs Library|LibreCloud/lib_defs +Webservices Filters Library|LibreCloud/lib_filters +GraphQL Library|LibreCloud/lib_graphql +Webservices Handlers Library|LibreCloud/lib_handlers +Key of Life Library|LibreCloud/lib_key_of_life +Macros Library|LibreCloud/lib_macros +Utils Library|LibreCloud/lib_utils +Tkdr Library|LibreCloud/lib_tkdr +Zterton library|LibreCloud/lib_zterton +" + +[ -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 "" + git clone "$REPO_URL/$lib_path.git" + ;; + pull) + dir_path=$(basename "$lib_path") + 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"))