summaryrefslogtreecommitdiff
path: root/fetch-css.sh
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-06-09 16:55:15 -0400
committerB Stack <bgstack15@gmail.com>2020-06-09 16:55:15 -0400
commit0c80c29d0fde63d9617d5769038963375e698628 (patch)
treeda4141376f5f0437ab5e659ebb4f8bdf69a9e0de /fetch-css.sh
downloadglip-0c80c29d0fde63d9617d5769038963375e698628.tar.gz
glip-0c80c29d0fde63d9617d5769038963375e698628.tar.bz2
glip-0c80c29d0fde63d9617d5769038963375e698628.zip
initial commit
Diffstat (limited to 'fetch-css.sh')
-rwxr-xr-xfetch-css.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/fetch-css.sh b/fetch-css.sh
new file mode 100755
index 0000000..06718c2
--- /dev/null
+++ b/fetch-css.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Startdate: 2020-05-29 20:18
+
+INDIR=/mnt/public/www/issues
+INGLOB=*.html
+
+SEDSCRIPT=/mnt/public/work/devuan/fix-css-in-html.sed
+
+# OUTDIR will be made in INDIR, because of the `cd` below.
+OUTDIR=css
+test ! -d "${OUTDIR}" && mkdir -p "${OUTDIR}"
+
+INSERVER=https://git.devuan.org
+
+cd "${INDIR}"
+
+orig_css="$( sed -n -r -e 's/^.*<link.*(href="[^"]+\.css").*/\1/p' ${INGLOB} | awk -F'"' '!x[$2]++{print $2}' )"
+
+cat /dev/null > "${SEDSCRIPT}"
+
+echo "${orig_css}" | while read line ; do
+ getpath="${INSERVER}${line}"
+ targetfile="${OUTDIR}/$( basename "${line}" )"
+ test -n "${DEBUG}" && echo "process ${getpath} and save to ${targetfile}" 1>&2
+ test -z "${DRYRUN}" && wget --quiet --content-disposition -O "${targetfile}" "${getpath}"
+ # dynamically build a sed script
+ echo "s:${line}:${targetfile##/}:g;" | tee -a "${SEDSCRIPT}"
+done
bgstack15