#!/bin/sh # adds my other script paths (except volsv) SSH_BASE_URL="git@git.zachir.xyz:zachir/" HTTP_BASE_URL="https://git.zachir.xyz/" SCRIPT_DIRS="blocks generics scripts shortcmds sp" printhelp () { printf "install.sh | Used to add my other script repos as submodules. Feel free to modfy it to clone yours as well.\n" printf " -s) clone repos using ssh\n" printf " -S) clone repos using https\n" printf " -h) prints this help message\n" printf " -u X ) will clone using X as the URL\n" } while getopts "cdhsSu:" o; do case "${o}" in c) unset SCRIPT_DIRS ;; d) [ -n "$SCRIPT_DIRS" ] && SCRIPT_DIRS="$SCRIPT_DIRS\n$OPTARG" [ -z "$SCRIPT_DIRS" ] && SCRIPT_DIRS="$OPTARG" ;; s) ___USE_SSH=y ;; S) unset ___USE_SSH ;; u) URL="$OPTARG" ;; *) printhelp ;; esac done clone_dir () { if [ -d "$1" ]; then printf "%s already exists as dir; not adding.\n" "$1" elif [ -f "$1" ]; then printf "%s already exists, but not as a dir; not adding.\n" "$1" else if [ -n "$2" ]; then printf "Cloning %s %s using ssh; will be read-write\nNote: only my ssh key will clone it\n" "$1" git clone "$SSH_BASE_URL$1.git" "$1" else printf "Cloning %s using http; will be read-only\n" "$1" git clone "$HTTP_BASE_URL$1.git" "$1" fi fi } echo "$SCRIPT_DIRS" | while read i; do clone_dir "$i" "$___USE_SSH" done