summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2017-04-18 07:43:47 (GMT)
committer Jaromil <jaromil@dyne.org>2017-04-18 07:43:47 (GMT)
commitfb4254b2ca8a6c443f2a7ebe136f15405025ea08 (patch)
tree92e40c480ece551c605c22c5512892adf90a4489
parent21d2c808587776b6c9c6b5357c79a3e43c8593c7 (diff)
'new' command to quickly create new account templates from emails
-rwxr-xr-xsrc/jaro6
-rwxr-xr-xsrc/zlibs/accounts49
2 files changed, 55 insertions, 0 deletions
diff --git a/src/jaro b/src/jaro
index 60f1ce7..453148a 100755
--- a/src/jaro
+++ b/src/jaro
@@ -506,6 +506,7 @@ main() {
option_subcommands[export]=""
option_subcommands[vcard]=""
option_subcommands[abook]=""
+ option_subcommands[new]=""
option_subcommands[vim]=""
option_subcommands[edit]=""
@@ -679,6 +680,11 @@ main() {
exitcode=$?
;;
+ new)
+ new_account ${option_params}
+ exitcode=$?
+ ;;
+
stat*) stats ${option_params} | sort -n
exitcode=$?
;;
diff --git a/src/zlibs/accounts b/src/zlibs/accounts
index 946f9ce..3e73454 100755
--- a/src/zlibs/accounts
+++ b/src/zlibs/accounts
@@ -20,6 +20,55 @@
# this source code; if not, write to:
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+new_account() {
+ fn new_account $*
+ acct=$1
+ req=(acct)
+ ckreq || return 1
+
+ [[ -r $MAILDIRS/Accounts/$acct ]] && {
+ error "account already existing: $MAILDIRS/Accounts/$acct"
+ return 1 }
+
+ isemail $acct || {
+ error "new account is not an email: $acct"
+ return 1 }
+
+
+ name=${acct%%@*}
+ domain=${acct##*@}
+ local options
+ case $domain in
+ gmail.com)
+ imap=imap.gmail.com
+ smtp=smtp.gmail.com
+ auth=plain
+ cert=check
+ options=keep
+ ;;
+ *)
+ imap=mail.${domain}
+ smtp=mail.${domain}
+ auth=plain
+ cert=check
+ options=keep
+ ;;
+ esac
+ cat <<EOF > $MAILDIRS/Accounts/$acct
+# automatically generated by 'jaro new' for account: $acct
+# modifications will not be overwritten
+name $name
+email $acct
+login $acct
+imap $imap
+smtp $smtp
+auth $auth
+cert $cert
+options $options
+EOF
+ act "account succesfully generated for $acct"
+ return 1
+}
# account = type.name es: imap.default or smtp.gmail
# -a defines which account name other than 'default'