summaryrefslogtreecommitdiff
path: root/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'install.sh')
-rwxr-xr-xinstall.sh25
1 files changed, 23 insertions, 2 deletions
diff --git a/install.sh b/install.sh
index 197ea0d..3ab3271 100755
--- a/install.sh
+++ b/install.sh
@@ -15,15 +15,18 @@ volsv
EOF
)"
+UPDATE=""
+
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"
+ printf " -U) updates the repos rather than clones\n"
}
-while getopts "cdhsSu:" o; do case "${o}" in
+while getopts "cdhsSu:U" o; do case "${o}" in
c) unset SCRIPT_DIRS ;;
d)
[ -n "$SCRIPT_DIRS" ] && SCRIPT_DIRS="$SCRIPT_DIRS\n$OPTARG"
@@ -35,9 +38,23 @@ while getopts "cdhsSu:" o; do case "${o}" in
SSH_BASE_URL="$OPTARG"
HTTP_BASE_URL="$OPTARG"
;;
+ U) UPDATE="y" ;;
*) printhelp ;;
esac done
+update_dir () {
+ if [ ! -d "$1" ]; then
+ printf "%s does not exist; please clone first.\n" "$1"
+ elif [ -f "$1" ]; then
+ printf "%s already exists, but not as a dir; cannot update.\n" "$1"
+ else
+ printf "Updating %s...\n" "$1"
+ cd "$1"
+ git pull
+ cd ..
+ fi
+}
+
clone_dir () {
if [ -d "$1" ]; then
printf "%s already exists as dir; not adding.\n" "$1"
@@ -56,5 +73,9 @@ clone_dir () {
echo "$SCRIPT_DIRS" | while read -r i; do
[ -z "$i" ] && continue
- clone_dir "$i" "$___USE_SSH"
+ if [ "$UPDATE" = "y" ]; then
+ update_dir "$i"
+ else
+ clone_dir "$i" "$___USE_SSH"
+ fi
done