about summary refs log tree commit diff stats
path: root/check_new_clinte_posts.sh
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2020-06-16 20:05:30 -0400
committerBen Morrison <ben@gbmor.dev>2020-06-16 20:14:37 -0400
commit0fe685c34c5cdbff278b70c98241b0aa7c5bd6ed (patch)
tree5468c2a6d278d901f28085d3b2f1b41a1df4f860 /check_new_clinte_posts.sh
parent40bb48bb701f88c902b912fb51fea88b5ae9a8b8 (diff)
downloadclinte-0fe685c34c5cdbff278b70c98241b0aa7c5bd6ed.tar.gz
moved hashing to shellscript to check for posts
removes dependency on sha2 crate and allows users
to choose their own hashing algorithm easily.

now copies clinte.json to $HOME/.clinte.json once
the posts are viewed. a shellscript can be used to
compare the hash of the global clinte.json to the
hash of the copy. an example script is supplied.

on `make install` the example script is installed
to /etc/profile.d/, where it will be run for users
on login.
Diffstat (limited to 'check_new_clinte_posts.sh')
-rwxr-xr-xcheck_new_clinte_posts.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/check_new_clinte_posts.sh b/check_new_clinte_posts.sh
new file mode 100755
index 0000000..1d2dfbe
--- /dev/null
+++ b/check_new_clinte_posts.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+LOCAL_FILE="$HOME/.clinte.json"
+LOCAL_HASH=$(sha256sum "$LOCAL_FILE" | cut -d' ' -f1)
+
+DBFILE="/usr/local/clinte/clinte.json"
+DBFILE_HASH=$(sha256sum "$DBFILE" | cut -d' ' -f1)
+
+if [ "$LOCAL_HASH" != "$DBFILE_HASH" ]
+then
+    printf "%s\n" "New posts on clinte!"
+fi
\ No newline at end of file