#!/bin/sh #----------------------------------------------------------------------------- # /var/install/bin/postgresql-common-sendmail # # Creation: 2021-10-23 dv # Last Update: 2023-07-23 09:11:10 # # Copyright (c) 2024 the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #----------------------------------------------------------------------------- . /var/install/include/eislib #----------------------------------------------------------------------------- # show help on arguments and possible options # @param n/a # @return n/a #----------------------------------------------------------------------------- show_help() { cat <" echo "To: postgresql admin <${email_address}>" echo "Subject: ${subject}" echo if [ -f "${file}" ] then cat "${file}" fi echo "." } | \ /usr/sbin/sendmail "${email_address}" fi } # --------------------------------------------------------------------------- # main routine # --------------------------------------------------------------------------- main() { local receipient="" local sender="" local subject="" local file="" # read option switches while [ "${1:0:2}" = "--" ] do case ${1} in --help) show_help exit 0 ;; --receipient) shift receipient="${1}" shift ;; --receipient=*) receipient="${1:13}" shift ;; --sender) shift sender="${1}" shift ;; --sender=*) sender="${1:9}" shift ;; --subject) shift subject="${1}" shift ;; --subject=*) subject="${1:10}" shift ;; --file) shift file="${1}" shift ;; --file=*) file="${1:7}" shift ;; *) echo "error: invalid option switch \"$1\"!" >&2 exit 1 ;; esac done if [ "$#" -gt "0" ] then echo "error: invalid option switch \"$1\"!" >&2 exit 1 fi send_email "${receipient}" "${sender}" "${subject}" "${file}" return "${?}" } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" exit 0 # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------