summarylogtreecommitdiffstats
path: root/compress-static
diff options
context:
space:
mode:
authorMartina Pietruschka2016-03-05 10:09:48 +0000
committerMartina Pietruschka2016-03-05 10:09:48 +0000
commit2d11a64c14fb8ca7da2c25f2bd5df7ca649472a5 (patch)
treef2e54e5343ecb4a9fd00c236c552269725946ab3 /compress-static
downloadaur-2d11a64c14fb8ca7da2c25f2bd5df7ca649472a5.tar.gz
v1.0
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