mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-01 08:34:50 +02:00
Complete Refactor for target/bin
(#1654)
* documentation and script updates trying to fix #1647 * preparations for refactoring target/bin/ * complete refactor for target/bin/ * changing script output slightly * outsourcing functions in `bin-helper.sh` * re-wrote linting to allow for proper shellcheck -x execution * show explanation for shellcheck ignore * adding some more information
This commit is contained in:
parent
0ada57d87c
commit
da8171388f
37 changed files with 579 additions and 504 deletions
|
@ -1,29 +1,19 @@
|
|||
#! /bin/bash
|
||||
|
||||
# shellcheck source=../bin-helper.sh
|
||||
. /usr/local/bin/bin-helper.sh
|
||||
|
||||
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-virtual.cf}
|
||||
|
||||
EMAIL="$1"
|
||||
RECIPIENT="$2"
|
||||
EMAIL="${1}"
|
||||
RECIPIENT="${2}"
|
||||
|
||||
usage() {
|
||||
echo "Usage: delalias <alias@domain> <recipient@other>"
|
||||
}
|
||||
function usage { echo "Usage: delalias <alias@domain> <recipient@other>" ; }
|
||||
|
||||
errex() {
|
||||
echo "$@" 1>&2
|
||||
exit 1
|
||||
}
|
||||
[[ -z ${EMAIL} ]] && { usage ; errex "Error: No alias specified" ; }
|
||||
[[ -z ${RECIPIENT} ]] && { usage ; errex "Error: No recipient specified" ; }
|
||||
[[ -s ${DATABASE} ]] || exit 0
|
||||
|
||||
escape() {
|
||||
echo "${1//./\\.}"
|
||||
}
|
||||
|
||||
[ -z "$EMAIL" ] && { usage; errex "Error: No alias specified"; }
|
||||
[ -z "$RECIPIENT" ] && { usage; errex "Error: No recipient specified"; }
|
||||
|
||||
[ -s "$DATABASE" ] || exit 0
|
||||
|
||||
#CNT=$(grep "^$EMAIL" $DATABASE | wc -w | awk '{print $1}')
|
||||
sed -i -e "/^$EMAIL *$RECIPIENT$/d" \
|
||||
-e "/^$EMAIL/s/,$RECIPIENT//g" \
|
||||
-e "/^$EMAIL/s/$RECIPIENT,//g" $DATABASE
|
||||
sed -i -e "/^${EMAIL} *${RECIPIENT}$/d" \
|
||||
-e "/^${EMAIL}/s/,${RECIPIENT}//g" \
|
||||
-e "/^${EMAIL}/s/${RECIPIENT},//g" "${DATABASE}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue