aboutsummaryrefslogtreecommitdiff
path: root/blogsend
diff options
context:
space:
mode:
authorPhilip Wittamore <philip@wittamore.com>2025-05-17 08:54:07 +0200
committerPhilip Wittamore <philip@wittamore.com>2025-05-17 08:54:07 +0200
commit59bee3209f50bdc19d36d14929159234946b0605 (patch)
treeab117443f1d67c0ee0b56caad128d82dd10c549f /blogsend
parentb8fa44c20a81851a0bfbce2a739b00fdf8fd0d3a (diff)
downloadbashlib-59bee3209f50bdc19d36d14929159234946b0605.tar.gz
bashlib-59bee3209f50bdc19d36d14929159234946b0605.tar.bz2
bashlib-59bee3209f50bdc19d36d14929159234946b0605.zip
update
Diffstat (limited to 'blogsend')
-rwxr-xr-xblogsend42
1 files changed, 42 insertions, 0 deletions
diff --git a/blogsend b/blogsend
new file mode 100755
index 0000000..840c4bd
--- /dev/null
+++ b/blogsend
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# blogsend : scp blog files to web server
+# requires : pb https://git.wittamore.com/bashlib/tree/pb
+# usage : blogsend hours (if not set default is 1 hour)
+# example : blogsend 72 sends files modified over the past 3 days
+
+source ~/.local/lib/pb
+
+# folders
+rf=mail:/var/www/html/wittamore.com
+mf=~/.local/src/web/wittamore.com
+cd $mf || exit
+
+# test if $1
+if [ -z "$1" ]; then
+ printf %b "$(pb_fg 196)no parameter, using 1$(pb_nc)\n"
+ hours=1;
+else
+ # test if $1 is a number
+ if [ "$1" -eq "$1" ] >/dev/null 2>&1; then
+ hours="$1";
+ else
+ printf %b "$(pb_fg 196)bad parameter, using 1$(pb_nc)\n"
+ hours=1;
+ fi
+fi
+
+minutes=$((hours*60))
+
+printf "Sending files modified in the past $hours hour(s) to $rf\n"
+
+files=$(find -- * -iname "*.html" -path .tmp -prune -o -mmin -$minutes -type f)
+for file in $files
+do
+ printf %s "-> "; scp "$file" "$rf/$file";
+done
+
+printf "Done.\n"
+
+exit 0
+