summaryrefslogtreecommitdiff
path: root/sync
diff options
context:
space:
mode:
authorTimmy Keller <tjk@tjkeller.xyz>2021-10-18 23:09:28 -0500
committerTimmy Keller <tjk@tjkeller.xyz>2021-10-18 23:09:28 -0500
commite7786d9b1904ecd2c9989c3f157df48016b0dd50 (patch)
tree6c05945a22b462556fc4f1612cee2fe778e544fe /sync
parent2cf3ea2f828f6da07adff92a7dc5bce6069620ab (diff)
downloadscripts-e7786d9b1904ecd2c9989c3f157df48016b0dd50.tar.xz
scripts-e7786d9b1904ecd2c9989c3f157df48016b0dd50.zip
moved some things around
Diffstat (limited to 'sync')
-rwxr-xr-xsync/pushsite5
-rwxr-xr-xsync/sinkold48
2 files changed, 53 insertions, 0 deletions
diff --git a/sync/pushsite b/sync/pushsite
new file mode 100755
index 0000000..4507256
--- /dev/null
+++ b/sync/pushsite
@@ -0,0 +1,5 @@
+#!/bin/sh
+ssh root@tjkeller.xyz << EOF
+cd /var/www/tjkeller/
+git pull
+EOF
diff --git a/sync/sinkold b/sync/sinkold
new file mode 100755
index 0000000..3022963
--- /dev/null
+++ b/sync/sinkold
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+printusage() { echo "Usage: $0 [<repos> ...] (repos: all,`echo $repos | tr ' ' ','`) [up|down]" && exit; }
+
+repos="docs patches"
+
+oper=`echo $@ | sed 's/.* //'` # Get last argument
+([ -z $2 ] || ([ "$oper" != "up" ] && [ "$oper" != "down" ])) && printusage
+
+# rync options
+#fix this too
+ropts="--archive --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 --delete $rdest$2 $1; fi) \
+ && printsuccess || printerror
+}
+
+# arg1 = options + containing directory path, arg2 = file/directory name
+syncdocs() { destdir="" && sync "/home/timmy/docs/" "school"; }
+#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
+
+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