summarylogtreecommitdiffstats
path: root/compress-static
diff options
context:
space:
mode:
authorMartiMcFly2018-05-31 00:41:12 +0200
committerMartiMcFly2018-05-31 00:41:12 +0200
commitd9d145c6e74a09539f9ed6496898476214abd6f9 (patch)
tree3ccbda40dd0e24463a9a87acb8c8f268791359cc /compress-static
downloadaur-d9d145c6e74a09539f9ed6496898476214abd6f9.tar.gz
init
Diffstat (limited to 'compress-static')
-rwxr-xr-xcompress-static34
1 files changed, 34 insertions, 0 deletions
diff --git a/compress-static b/compress-static
new file mode 100755
index 000000000000..1dda2f4699b8
--- /dev/null
+++ b/compress-static
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+LOCATION=$1
+FILES="htm|css|html|js"
+
+process() {
+ FILE="$1"
+
+ if [ -f "$FILE".gz ]
+ then
+ FILE_ORIG=$(stat -c %Y "$FILE")
+ FILE_GZIP=$(stat -c %Y "$FILE".gz)
+ if [ $FILE_ORIG -gt $FILE_GZIP ]
+ then
+ rm "$FILE".gz
+ gzip -k -9 "$FILE"
+ if [ "$DEBUG" == 1 ]
+ then
+ echo "Deleted old .gz and created new one at: $FILE.gz"
+ sleep $SLEEP_DELAY
+ fi
+ else
+ if [ "$DEBUG" == 1 ]
+ then
+ echo "Skipping - Already up to date: $FILE.gz"
+ fi
+ fi
+ else
+ gzip -k -9 "$FILE"
+ echo "Created new: $FILE.gz"
+ fi
+}
+export -f process
+find $LOCATION -type f -regextype posix-extended -regex '.*\.('$FILES')' -exec /bin/bash -c 'process "{}"' \; \ No newline at end of file