diff --git a/README.md b/README.md index 0462eb0..12d590f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Obscure Scripts A collection of scripts from [The Obscure Organization](https://www.obscure.org) - a public access UNIX system in continuous use since 1995. * [blockip.sh](blockip.sh) - Use iptables to temporarily block an IP addreess or CIDR block +* [btidy.sh](btidy.sh) - Use [HTML tidy](https://www.html-tidy.org/) but only versus the body of an HTML file. Useful for filtering fragments of HTML files, or for using in vim (`:'a,'b ! btidy -wrap 0 -i -asxml`) * [cloud-init-centos-7-ipv6.yml](cloud-init-centos-7-ipv6.yml) - Use in instance data for CentOS 7.x EC2 servers that are having trouble getting an IPv6 default route. See also [cloud-init-centos-7.6-ipv4-ena.yml](cloud-init-centos-7.6-ipv4-ena.yml) and [cloud-init-centos-7.6-ipv6-ena.yml](cloud-init-centos-7.6-ipv4-ena.yml) * [icinga2-graceful.sh](icinga2-graceful.sh) - Check the validity of icinga2 system configuration files, then restart it only if the configuration is ok. diff --git a/btidy.sh b/btidy.sh new file mode 100755 index 0000000..00457a9 --- /dev/null +++ b/btidy.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +# +# btidy.sh +# +# Use HTML tidy on just the body of an HTML file. +# See https://www.html-tidy.org/ for documentation on tidy. +# +# When used as a filter, this will enclose each line of tidy output in +# an HTML comment. +# +# Usage: +# ./btidy.sh [options] ... +# +# # From vi family editors, assuming btidy.sh is in your path: +# :% ! btidy.sh [options] +# # vi example in a marked section: +# :'a,'b ! btidy.sh -i +# +# Copyright (C) 2024 by The Obscure Organization +# +# MIT licensed. See the LICENSE file for details. +# +# Release History: +# +# 1.0 (Sat Dec 14, 2024) +# First public release + +# Use bash unofficial strict mode +set -euo pipefail +IFS=$'\n\t' + +DEBUG=${DEBUG:-false} + +# Thanks https://stackoverflow.com/a/17805088 +$DEBUG && export PS4='${LINENO}: ' && set -x + +TMPFILE=$(mktemp /tmp/btidy.XXXXXX) +TMPERR=$(mktemp /tmp/btidy-err.XXXXXX) +TMPOUT=$(mktemp /tmp/btidy-out.XXXXXX) + +# remove tempfile on exit +function finish { + rm -f "$TMPFILE" "$TMPERR" +} +trap finish EXIT + +# Nice, thanks https://www.cyberciti.biz/faq/linux-unix-bsd-apple-osx-bash-get-last-argument/ +FILE="${BASH_ARGV[0]:-}" +if [ -z "$FILE" ]; then + ARGS="$*" + FILE=/dev/stdin +elif [ -f "$FILE" ]; then + # If a file is specified as the last CLI option, consume the last parameter + # tricksy - thanks https://unix.stackexchange.com/a/273531 + # shellcheck disable=2124 + ARGS="${@:1:$#-1}" +else + ARGS="$*" + FILE=/dev/stdin +fi + +cat < "$TMPFILE" + +invisible + +EOF +cat "$FILE" >> "$TMPFILE" +set +e +# shellcheck disable=SC2048,SC2086 +tidy -q --show-body-only y $ARGS "$TMPFILE" > "$TMPOUT" 2>"$TMPERR" +EXITCODE=$? +set -e + +if [[ "$EXITCODE" -gt 0 ]]; then + echo "WARNING: tidy had non-zero exit $EXITCODE" >> "$TMPERR" +fi +if [[ "$FILE" != "/dev/stdin" ]] \ + && echo "$ARGS" | grep --quiet -E -- '-m|--modify' +then + cat "$TMPFILE" > "$FILE" +else + if [[ -s "$TMPERR" ]]; then + TV="$(tidy --version)" + printf '\n' "$TV" + sed 's/^\(.*\)$//' "$TMPERR" + fi + cat "$TMPOUT" +fi + +exit $EXITCODE diff --git a/tiamat-install.sh b/tiamat-install.sh index 2025749..8028cc0 100755 --- a/tiamat-install.sh +++ b/tiamat-install.sh @@ -29,6 +29,9 @@ boost-devel certbot certbot python3-certbot-apache clamav +clamav-milter +clamav-update +clamd cmake dnf-automatic dovecot @@ -46,6 +49,7 @@ links man2html mariadb mariadb-server +mailman3 mod_ssl mpfr-devel mutt @@ -60,6 +64,9 @@ nagios-plugins-swap nagios-plugins-users nmstate nrpe +openarc +opendkim +opendkim-tools pam-devel php php-gd @@ -154,10 +161,15 @@ firewall-cmd --runtime-to-permanent # Start services services=' +clamd@service +clamav-milter dnf-automatic.timer httpd +mailman3 mariadb named +openarc +opendkim postgresql saslauthd sendmail