JII (Java Image Info) Version 1.2.0

Version 1.2.0 of JII has been released.

It provides a clean interface to a collection of Java libraries and source code to read basic properties of images.

Changes:

  • updated java to 11
  • rewritten the ProcessBuilderWrapper
  • fixed call of identify (imagemagick)
  • changed repo

Since this version JII gets it’s own maven repository.

The following entries are required in the pom.xml:

<repositories>
	<repository>
		<id>jiirepo</id>
		<url>https://myrepo.thischwa.codes/repository/jii/</url>
	</repository>
</repositories>

<dependency>
	<groupId>codes.thischwa.jii</groupId>
	<artifactId>java-image-info</artifactId>
	<version>1.2.0</version>
</dependency>

, ,

Leave a comment

How to check, if there is an update for mailcow

Let us assume that mailcow (dockerized) is installed in the directory /opt/mailcow-dockerized, then the script below checks, if there is an update and sends an email to the hostmaster:

#!/bin/bash
set -o nounset
set -o errexit

cd /opt/mailcow-dockerized && ./update.sh --check > /dev/null
exit_code=$?

[ $exit_code -eq 0 ] && echo -e "Subject:MAILCOW: Update available \n\n Update your mailcow instance please!\n" | sendmail hostmaster@your-domain.com
exit 0

The scrip can be run as cron.

Leave a comment

MySQL: backup databases in separate files and zip it to STDOUT

It’s not very comfortable to restore one database, if you have just one big fat backup file, which contains all databases.

My solution is the bash script above does the following steps:

  1. It crreates one dump file for each database.
  2. It packs all dump files in one zipfile
  3. and sends it to STDOUT.

Step 3 is very helpful e.g. for using this script with backup software like rsnapshot.

## Dumps every database to a single file, all dump files will be zipped and redirected to the stdout.
## Usage: backup-db.sh > databases.zip
##
#! /bin/bash
set -o nounset
set -o errexit

trap 'rm -rf "$BACKUP_DIR"' EXIT
BACKUP_DIR=$(mktemp -d)
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump

databases=`$MYSQL --defaults-extra-file=/etc/mysql/credentials.cnf --default-character-set=utf8mb4 -e "SHOW DATABASES;" \
        | grep -Ev "(Database|information_schema|performance_schema)"`
for db in $databases; do
  $MYSQLDUMP --defaults-extra-file=/etc/mysql/credentials.cnf --default-character-set=utf8mb4 --force --opt --databases $db \
        > "$BACKUP_DIR/$db.sql"
done
zip -rjq - "$BACKUP_DIR"
exit 0

The corresponding gist at github: https://gist.github.com/th-schwarz/38dd9fa1cdba05506f642a633095bad7

, ,

Leave a comment

dnsmasq and logrotate on ubuntu 20.04

I had same issues with dnsmasq and logrotate on ubuntu 20.04. Here is my solution:

In /etc/dnsmasq.conf the following entry is required:

log-facility=/var/log/dnsmasq/dnsmasq.log

Create /etc/logrotate.d/dnsmasq with the following content:

/var/log/dnsmasq/dnsmasq.log {
   size 100M
   weekly
   rotate 7
   compress
   missingok
   notifempty
   postrotate
      service dnsmasq restart
   endscript
}

The important thing was the restart of dnsmasq!

, ,

Leave a comment

How to check the expiration date of a ssl certificate?

To check a certificate of an host:

openssl s_client -servername your.domain -connect your.domain:443 2>&- | openssl x509 -enddate -noout | sed 's/^notAfter=//g'

To check a certificate file:

openssl x509 -noout -enddate -in your.crt | sed 's/^notAfter=//g'

 

,

Leave a comment