summaryrefslogtreecommitdiff
path: root/sync
diff options
context:
space:
mode:
authorTimmy Keller <tjk@tjkeller.xyz>2021-09-11 00:36:13 -0500
committerTimmy Keller <tjk@tjkeller.xyz>2021-09-11 00:36:13 -0500
commit0a9053c2902adab8b94eaacdb15390441143078c (patch)
tree1f1a38272dbd554cde8cdec263187112b9c6a7e8 /sync
downloadscripts-0a9053c2902adab8b94eaacdb15390441143078c.tar.xz
scripts-0a9053c2902adab8b94eaacdb15390441143078c.zip
redid repo cus of fucking chromium rip old commit messages
Diffstat (limited to 'sync')
-rwxr-xr-xsync/pull57
-rwxr-xr-xsync/sink49
2 files changed, 106 insertions, 0 deletions
diff --git a/sync/pull b/sync/pull
new file mode 100755
index 0000000..06cf145
--- /dev/null
+++ b/sync/pull
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+printusage() { echo "Usage: $0 [-b,--build] [<repo> ...] (repos: all,`echo $repos | tr ' ' ','`)" && exit; }
+
+repos=$repos"blr dmenu dotconfig scripts st timmywm" #repos=$repos"dotconfig|dwmpatches|scripts|st|timmywm"
+
+[ -z $1 ] || [ `echo "$@" | tr ' ' '\n' | grep -v -c '\-'` = 0 ] && printusage
+
+# Colors
+BOLD="\033[1m"
+NORM="\033[0m"
+CYN="\033[0;36m"
+RED="\033[0;31m"
+GRN="\033[0;32m"
+MAG="\033[0;35m"
+
+printsyncmsg() { echo "$CYN[Pulling repo '$arg'...]$NORM"; }
+printsuccess() { echo "$BOLD$GRN[Successfully pulled repo '$arg']$NORM"; }
+printerror() { echo "$BOLD$RED[Failed to pull repo '$arg']$NORM"; }
+
+#change colors
+printmakemsg() { echo "$MAG[Building repo '$arg'...]$NORM"; }
+printmakesuccess() { echo "$BOLD$GRN[Successfully built repo '$arg']$NORM"; }
+printmakeerror() { echo "$BOLD$RED[Failed to build repo '$arg']$NORM"; }
+
+pullrepo() {
+ printsyncmsg
+ cd $1 && git pull --verbose \
+ && printsuccess || printerror
+}
+makerepo() {
+ if echo "$opts" | grep '\-b'; then
+ printmakemsg
+ doas make clean install \
+ && printmakesuccess || printmakeerror
+ fi
+}
+makeautoconf() { make autoconfig && echo "$BOLD$GRN[Automatically configured '$repo']$NORM"; }
+
+pullblr() { pullrepo ~/.local/src/programs/blr; }
+pulldmenu() { pullrepo ~/.local/src/programs/dmenu && makeautoconf && makerepo; }
+pulldotconfig() { pullrepo ~/.config; }
+pullscripts() { pullrepo ~/.local/bin; }
+pullst() { pullrepo ~/.local/src/programs/st && makeautoconf && makerepo; }
+pulltimmywm() { pullrepo ~/.local/src/programs/timmywm && makeautoconf && makerepo; }
+
+for arg in "$@"; do
+ case $arg in
+ -b|--build) opts="$opts-b" ;;
+ all) $0 $opts $repos ;;
+ *) # Would like to use something like $repos) here but cant
+ for repo in $repos; do
+ [ "$arg" = "$repo" ] && pull$arg && break
+ done || printusage
+ ;;
+ esac
+done
diff --git a/sync/sink b/sync/sink
new file mode 100755
index 0000000..41bf61e
--- /dev/null
+++ b/sync/sink
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+printusage() { echo "Usage: $0 [<repos> ...] (repos: all,`echo $repos | tr ' ' ','`) [up|down]" && exit; }
+
+repos="docs sites patches"
+
+oper=`echo $@ | sed 's/.* //'` # Get last argument
+([ -z $2 ] || ([ "$oper" != "up" ] && [ "$oper" != "down" ])) && printusage
+
+# rync options
+#fix this too
+ropts="--archive --delete --partial --progress --recursive --update --verbose" # Equivalent to: -aPrvu --delete
+rdest="tjkrsync@tjkeller.xyz:"
+
+# Colors
+BOLD="\033[1m"
+NORM="\033[0m"
+CYN="\033[0;36m"
+RED="\033[0;31m"
+GRN="\033[0;32m"
+
+printsyncmsg() { echo -n "$CYN[Syncing $SYNCNAME...]$NORM\n"; }
+printsuccess() { echo -n "$BOLD$GRN[Successfully synced $SYNCNAME]\n"; }
+printerror() { echo -n "$BOLD$RED[An error occured while syncing $SYNCNAME]\n"; }
+
+sync() {
+ [ $oper = "up" ] && SYNCNAME="$1$2 to $rdest$2" || SYNCNAME="$rdest$2 to $1$2"
+ printsyncmsg
+ (if [ $oper = "up" ]; then rsync $ropts $1$2 $rdest; else rsync $ropts $rdest$2 $1; fi) \
+ && printsuccess || printerror
+}
+
+# arg1 = options + containing directory path, arg2 = file/directory name
+syncdocs() { destdir="" && sync "/home/timmy/" "docs"; }
+#syncsites() { destdir="" && sync "--exclude=pass /home/timmy/.local/src/" "sites"; } # Excludes password file
+syncpatches() { destdir="" && sync "--exclude=.git /home/timmy/.local/src/programs/" "patches"; } # Excludes git files
+syncsite() { destdir="/var/www/tjkeller/" && sync "/home/timmy/.local/src/sites/" "tjkeller"; }
+
+for arg in "$@"; do
+ case $arg in
+ all) $0 $repos $oper ;;
+ up|down) oper=$arg ;;
+ *) # Would like to use something like $repos) here but cant
+ for repo in $repos; do
+ [ "$arg" = "$repo" ] && sync$arg && break
+ done || printusage
+ ;;
+ esac
+done