M check_new_clinte_posts.sh => check_new_clinte_posts.sh +21 -15
@@ 1,20 1,26 @@
#!/bin/sh
-OS=$(uname)
+check_clinte()
+{
+ OS=$(uname)
+ LOCAL_FILE="$HOME/.clinte.json"
+ DBFILE='/usr/local/clinte/clinte.json'
-LOCAL_FILE="$HOME/.clinte.json"
-DBFILE="/usr/local/clinte/clinte.json"
+ if [ "$OS" = 'Linux' ]
+ then
+ LOCAL_HASH=$(sha256sum "$LOCAL_FILE" 2>/dev/null | cut -d' ' -f1)
+ DBFILE_HASH=$(sha256sum "$DBFILE" | cut -d' ' -f1)
+ else
+ LOCAL_HASH=$(sha256 "$LOCAL_FILE" 2>/dev/null | cut -d' ' -f1)
+ DBFILE_HASH=$(sha256 "$DBFILE" | cut -d' ' -f1)
+ fi
+
+ if [ "$LOCAL_HASH" != "$DBFILE_HASH" ]
+ then
+ printf '%s\n\n' 'New posts on clinte!'
+ fi
+}
-if [ $OS = "Linux" ]
-then
- LOCAL_HASH=$(sha256sum "$LOCAL_FILE" 2>/dev/null | cut -d' ' -f1)
- DBFILE_HASH=$(sha256sum "$DBFILE" | cut -d' ' -f1)
-else
- LOCAL_HASH=$(sha256 "$LOCAL_FILE" 2>/dev/null | cut -d' ' -f1)
- DBFILE_HASH=$(sha256 "$DBFILE" | cut -d' ' -f1)
-fi
-
-if [ "$LOCAL_HASH" != "$DBFILE_HASH" ]
-then
- printf "%s\n\n" "New posts on clinte!"
+if [ ! -e "$HOME/.hushclinte" ]; then
+ check_clinte
fi=
\ No newline at end of file