dotfiles

My collection of dotfiles
git clone git://git.noxz.tech/dotfiles
Log | Files | Refs

commit df175ff784bfa9481a38024bfe9898695506ebe5
parent 81f346ad7feb042b357148339a4f1e2d7e1c2580
Author: Chris Noxz <chris@noxz.tech>
Date:   Tue, 14 Jan 2020 20:14:53 +0100

[bin] Add script for generating mutt aliases from roundcube

Diffstat:
Abin/.bin/generate-mutt-alias | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/bin/.bin/generate-mutt-alias b/bin/.bin/generate-mutt-alias @@ -0,0 +1,25 @@ +#!/bin/sh +# This script connets to a SQL-server extracts contact data from a roundcube +# database. The contact data is then formated using AWK to match a mutt aliasrc. + +echo 'unalias *' + +SQL_CMD="SELECT firstname,surname,email" +SQL_CMD="$SQL_CMD FROM contacts JOIN users ON users.user_id=contacts.user_id" +SQL_CMD="$SQL_CMD WHERE users.username=\"$1\"" +SSH_CMD="$(cat <<'EOT' +sudo /usr/bin/mysql + --skip-column-names + -D roundcubemail + -e +EOT +)" +SSH_CMD="$SSH_CMD'$SQL_CMD'" +SSH_CMD="$SSH_CMD$(cat <<'EOT' +| awk + -F '\\t' + '{print "alias "tolower(substr($1,1,3)substr($2,1,3))" "$3" ("$1" "$2")"}' +EOT +)" + +ssh mail -t "$(echo $SSH_CMD | tr '\n' ' ')"