Skip to content

Commit

Permalink
ci(push): update super-linter action
Browse files Browse the repository at this point in the history
  • Loading branch information
streambinder committed Sep 3, 2024
1 parent ac9e6c8 commit 410c2a1
Show file tree
Hide file tree
Showing 21 changed files with 400 additions and 399 deletions.
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Unciæ <a href="https://github.com/streambinder/unciae"><img align="left" src="https://github.com/streambinder.png?size=96"></a>
# Unciæ <a href="https://github.com/streambinder/unciae"><img alt="documentation" align="left" src="https://github.com/streambinder.png?size=96"></a>

This is the safe place to put every mini-project worth to be kept whilst not deserving its own repository.
2 changes: 1 addition & 1 deletion .github/linters/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ linters-settings:
check-blank: true
govet:
# report about shadowed variables
check-shadowing: true
shadow: true
gocyclo:
# minimal code complexity to report, 30 by default
min-complexity: 15
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker://github/super-linter:latest
- uses: super-linter/super-linter@v7.1.0
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_UNCIAE }}
VALIDATE_ALL_CODEBASE: false
Expand Down
2 changes: 1 addition & 1 deletion backup/restup/hooks/acl_pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "$(realpath "$(dirname "$0")")/acl_common.sh"

mkdir -p "${DIR_ACL}"
find "${DIR_ACL}" -type f -delete
getfacl -pR / > "/var/acls/root.acl" 2> /dev/null || echo -n
getfacl -pR / >"/var/acls/root.acl" 2>/dev/null || echo -n
2 changes: 1 addition & 1 deletion backup/restup/hooks/db_common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

# shellcheck disable=SC2034
DIR_DB="/var/databases"
DIR_DB="/var/databases"
10 changes: 5 additions & 5 deletions backup/restup/hooks/db_pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ source "$(realpath "$(dirname "$0")")/db_common.sh"

mkdir -p "${DIR_DB}"
find "${DIR_DB}" -type f -delete
mysql -sN -u root -p'2dkNKCVT9AgFaV8g' -e "SHOW DATABASES;" | \
grep -Ev "(Database|information_schema|performance_schema)" | \
while read -r db; do
mysqldump -u root -p'2dkNKCVT9AgFaV8g' "${db}" --add-drop-table > "${DIR_DB}/${db}.sql"
done
mysql -sN -u root -p'2dkNKCVT9AgFaV8g' -e "SHOW DATABASES;" |
grep -Ev "(Database|information_schema|performance_schema)" |
while read -r db; do
mysqldump -u root -p'2dkNKCVT9AgFaV8g' "${db}" --add-drop-table >"${DIR_DB}/${db}.sql"
done
2 changes: 1 addition & 1 deletion backup/restup/hooks/fw_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# shellcheck disable=SC2034
FW_FNAME="/etc/sysconfig/iptables"
IPTABLES_SAVE="/sbin/iptables-save"
IPTABLES_SAVE="/sbin/iptables-save"
2 changes: 1 addition & 1 deletion backup/restup/hooks/fw_pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# shellcheck disable=SC1090,SC1091
source "$(realpath "$(dirname "$0")")/fw_common.sh"

"${IPTABLES_SAVE}" > "${FW_FNAME}"
"${IPTABLES_SAVE}" >"${FW_FNAME}"
32 changes: 16 additions & 16 deletions git/committer-changer/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# auxiliary functions

function help() {
echo -e "Usage:\n\t$(basename "$0") old@committ.er new_committer_name:new@committ.er"
exit 0
echo -e "Usage:\n\t$(basename "$0") old@committ.er new_committer_name:new@committ.er"
exit 0
}
function rprint() { echo -en "\r\e[0K$*"; }
function pprint() { echo -e "\r\e[0K$*"; }
Expand All @@ -14,19 +14,19 @@ function pprint() { echo -e "\r\e[0K$*"; }
# arguments parsing

while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
help
;;
*)
if [ -z "${COMMITTER_OLD}" ]; then
COMMITTER_OLD=$1
else
COMMITTER_NEW=$1
fi
;;
esac
shift
case "$1" in
-h | --help)
help
;;
*)
if [ -z "${COMMITTER_OLD}" ]; then
COMMITTER_OLD=$1
else
COMMITTER_NEW=$1
fi
;;
esac
shift
done

# arguments validation
Expand All @@ -35,7 +35,7 @@ COMMITTER_NEW_NAME="$(awk -F':' '{print $1}' <<<"${COMMITTER_NEW}")"
COMMITTER_NEW_EMAIL="$(awk -F':' '{print $2}' <<<"${COMMITTER_NEW}")"

if [ -z "${COMMITTER_OLD}" ] || [ -z "${COMMITTER_NEW_NAME}" ] || [ -z "${COMMITTER_NEW_EMAIL}" ]; then
help
help
fi

# effective script
Expand Down
16 changes: 8 additions & 8 deletions git/history-touchup/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# auxiliary functions

function help() {
echo -e "Usage:\n\t$(basename "$0")"
exit 0
echo -e "Usage:\n\t$(basename "$0")"
exit 0
}
function rprint() { echo -en "\r\e[0K$*"; }
function pprint() { echo -e "\r\e[0K$*"; }
Expand All @@ -14,12 +14,12 @@ function pprint() { echo -e "\r\e[0K$*"; }
# arguments parsing

while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
help
;;
esac
shift
case "$1" in
-h | --help)
help
;;
esac
shift
done

# arguments validation
Expand Down
98 changes: 49 additions & 49 deletions image/reasize/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# auxiliary functions

function help() {
echo -e "Usage:\n\t$(basename "$0") <MAX_WIDTHxMAX_HEIGHT> [-t <path>]"
exit 0
echo -e "Usage:\n\t$(basename "$0") <MAX_WIDTHxMAX_HEIGHT> [-t <path>]"
exit 0
}
function rprint() { echo -en "\r\e[0K$*"; }
function pprint() { echo -e "\r\e[0K$*"; }
Expand All @@ -14,73 +14,73 @@ function pprint() { echo -e "\r\e[0K$*"; }
# arguments parsing

while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
help
;;
-t | --target)
TARGET="$2"
shift
;;
*)
SIZE=$1
;;
esac
shift
case "$1" in
-h | --help)
help
;;
-t | --target)
TARGET="$2"
shift
;;
*)
SIZE=$1
;;
esac
shift
done

# arguments validation

if [ -z "${TARGET}" ]; then
TARGET="$(pwd)"
TARGET="$(pwd)"
fi

if [ -z "${SIZE}" ]; then
help
help
fi

SIZE_W="$(awk -F'x' '{print $1}' <<<"${SIZE,,}" | xargs)"
SIZE_H="$(awk -F'x' '{print $2}' <<<"${SIZE,,}" | xargs)"

if [ -z "${SIZE_W}" ] && [ -z "${SIZE_H}" ]; then
echo "At least a resolution argument must be given"
exit 1
echo "At least a resolution argument must be given"
exit 1
fi

# effective script

find "${TARGET}" -type f -exec file {} \; | grep -o -P '^.+: \w+ image' | awk -F':' '{print $1}' | while read -r fname; do

pname="${fname//${TARGET}\//}"
rprint "Checking ${pname}"

# get image data

if ! img_data="$(exiftool "${fname}")"; then
continue
fi

# get image resolution
img_res_w="$(awk -F': ' '/^Image Width/ {print $2}' <<<"${img_data}" | xargs)"
img_res_h="$(awk -F': ' '/^Image Height/ {print $2}' <<<"${img_data}" | xargs)"
if [ -z "${img_res_w}" ] || [ -z "${img_res_h}" ]; then
continue
fi

# calculate resize
img_res=""
if [ -n "${SIZE_W}" ] && [ "${img_res_w}" -gt "${SIZE_W}" ]; then
img_res="${SIZE_W}x"
fi
if [ -n "${SIZE_H}" ] && [ -z "${img_res}" ] && [ "${img_res_h}" -gt "${SIZE_H}" ]; then
img_res="x${SIZE_H}"
fi

# process resize
if [ -n "${img_res}" ]; then
pprint "Resizing ${pname} to ${img_res} from ${img_res_w}x${img_res_h} ($(du -sh "${fname}" | awk '{print $1}'))"
mogrify -resize "${img_res}" "${fname}"
fi
pname="${fname//${TARGET}\//}"
rprint "Checking ${pname}"

# get image data

if ! img_data="$(exiftool "${fname}")"; then
continue
fi

# get image resolution
img_res_w="$(awk -F': ' '/^Image Width/ {print $2}' <<<"${img_data}" | xargs)"
img_res_h="$(awk -F': ' '/^Image Height/ {print $2}' <<<"${img_data}" | xargs)"
if [ -z "${img_res_w}" ] || [ -z "${img_res_h}" ]; then
continue
fi

# calculate resize
img_res=""
if [ -n "${SIZE_W}" ] && [ "${img_res_w}" -gt "${SIZE_W}" ]; then
img_res="${SIZE_W}x"
fi
if [ -n "${SIZE_H}" ] && [ -z "${img_res}" ] && [ "${img_res_h}" -gt "${SIZE_H}" ]; then
img_res="x${SIZE_H}"
fi

# process resize
if [ -n "${img_res}" ]; then
pprint "Resizing ${pname} to ${img_res} from ${img_res_w}x${img_res_h} ($(du -sh "${fname}" | awk '{print $1}'))"
mogrify -resize "${img_res}" "${fname}"
fi

done

Expand Down
54 changes: 27 additions & 27 deletions monitoring/scrubber/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# auxiliary functions

function help() {
echo -e "Usage:\n\t$(basename "$0") <device> [devices...] -c <contact>"
exit 0
echo -e "Usage:\n\t$(basename "$0") <device> [devices...] -c <contact>"
exit 0
}

# shell setup
Expand All @@ -14,49 +14,49 @@ set +e
# arguments parsing

while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
help
;;
-c | --contact)
CONTACT="$2"
shift
;;
*)
DEVICES="${DEVICES} $1"
;;
esac
shift
case "$1" in
-h | --help)
help
;;
-c | --contact)
CONTACT="$2"
shift
;;
*)
DEVICES="${DEVICES} $1"
;;
esac
shift
done

# arguments validation

if [ -z "${DEVICES}" ]; then
echo "At least one disk path must be given"
help
echo "At least one disk path must be given"
help
fi

if [ -z "${CONTACT}" ]; then
echo "At least one contact email must be given"
help
echo "At least one contact email must be given"
help
fi
CONTACT_DOMAIN="$(awk -F'@' '{print $2}' <<<"${CONTACT}")"

# effective script

disk_scrub_log="/tmp/scrub-$$.log"
for disk in ${DEVICES}; do
cat <<EOF >${disk_scrub_log}
cat <<EOF >${disk_scrub_log}
From: "Scrubber" <scrubber@${CONTACT_DOMAIN}>
To: <${CONTACT}>
Subject: BTRFS scrub
EOF
btrfs scrub start -Bd "${disk}" >>"${disk_scrub_log}"
curl -q --ssl-reqd --insecure \
--url "${SMTP_URI}" \
--user "${SMTP_USER}:${SMTP_PASS}" \
--mail-from "scrubber@${CONTACT_DOMAIN}" \
--mail-rcpt "${CONTACT}" \
--upload-file "${disk_scrub_log}"
btrfs scrub start -Bd "${disk}" >>"${disk_scrub_log}"
curl -q --ssl-reqd --insecure \
--url "${SMTP_URI}" \
--user "${SMTP_USER}:${SMTP_PASS}" \
--mail-from "scrubber@${CONTACT_DOMAIN}" \
--mail-rcpt "${CONTACT}" \
--upload-file "${disk_scrub_log}"
done
Loading

0 comments on commit 410c2a1

Please sign in to comment.