]> git.cworth.org Git - notmuch-wiki/commitdiff
remoteusage/124 with environment variables!
authorTomi Ollila <tomi.ollila@iki.fi>
Sun, 2 Mar 2014 15:53:00 +0000 (17:53 +0200)
committerTomi Ollila <tomi.ollila@iki.fi>
Sun, 2 Mar 2014 15:53:00 +0000 (17:53 +0200)
frontends.mdwn
index.mdwn
remoteusage/124.mdwn
searching.mdwn

index 74425a8808c64c01630178b6a41f43e87d10c172..d3dcbcb04e64ff83857286e136951fbfed0ca537 100644 (file)
@@ -2,7 +2,7 @@
 
 ## Shipping with Notmuch
 
-* [[notmuch-cli|manpages]], the CLI bindings provided with Notmuch.
+* [[notmuch-cli|man]], the CLI bindings provided with Notmuch.
 * [[notmuch-emacs|emacstips]], the Emacs email client.
 * [notmuch-vim](http://git.notmuchmail.org/git/notmuch/blob/HEAD:/vim/README), the vim frontend.
 * [[notmuch-mutt]], mutt interoperability script.
@@ -15,4 +15,3 @@
 * [ner](http://the-ner.org/), a curses frontend written in C.
 * [notmuch-web](https://bitbucket.org/wuzzeb/notmuch-web) A web front end written in [Haskell](http://hackage.haskell.org/package/notmuch-web).
 * [notmuchfs](https://github.com/tsto/notmuchfs), a virtual maildir file system for Notmuch queries.
-
index 70a2874efd219fd274842fcff33c43e074690759..f64a0d116a357dd6f899fdef45447cada2daa3e7 100644 (file)
@@ -54,7 +54,7 @@ The configuration wizard will walk you through initial setup,
 including specifying the location of your mail store and how to start
 the initial indexing.  After that, come back and checkout our docs:
 
-  * [[Notmuch manual pages|manpages]]
+  * [[Notmuch manual pages|man]]
   * [[General how-tos|howto]]
   * [[Frequently Asked Questions|faq]]
   * [[Searching]]
index 6020de1f08b24d67a57611adbdb178b1265f0df7..76551a06d54ee837ffc68a38721f78ad041fba5a 100644 (file)
@@ -20,21 +20,22 @@ Write the following code to a file, for example `remote-notmuch.sh`.
 
        #!/bin/bash
 
-       # http://notmuchmail.org/remoteusage/124/
-
        set -eu
        # To trace execution, uncomment next line.
        #BASH_XTRACEFD=6; exec 6>>remote-errors; echo -- >&6; set -x
 
-       readonly SSH_CONTROL_SOCK='~'/.ssh/master-user@host:22
+       : ${REMOTE_NOTMUCH_SSHCTRL_SOCK:=master-notmuch@remote:22}
+       : ${REMOTE_NOTMUCH_COMMAND:=notmuch}
 
-       readonly notmuch=notmuch
+       readonly REMOTE_NOTMUCH_SSHCTRL_SOCK REMOTE_NOTMUCH_COMMAND
 
-       printf -v ARGS '%q ' "$@" # bash feature
+       SSH_CONTROL_ARGS='-oControlMaster=no -S ~'/.ssh/$REMOTE_NOTMUCH_SSHCTRL_SOCK
+       readonly SSH_CONTROL_ARGS
 
-       readonly SSH_CONTROL_ARGS='-oControlMaster=no -S '$SSH_CONTROL_SOCK
+       printf -v ARGS '%q ' "$@" # bash feature
+       readonly ARGS
 
-       if ssh -q $SSH_CONTROL_ARGS 0.1 $notmuch $ARGS
+       if ssh -q $SSH_CONTROL_ARGS 0.1 "$REMOTE_NOTMUCH_COMMAND" $ARGS
        then exit 0
        else ev=$?
        fi
@@ -55,12 +56,15 @@ Write the following code to a file, for example `remote-notmuch.sh`.
 
        if ssh $SSH_CONTROL_ARGS -O check 0.1
        then
-        echo ' Control socket is alive but something failed during data transmission'
+        echo " Control socket is alive but something exited with status $ev"
         exit $ev
        fi
 
-       echo " See`sed '1d;2d;s/.//;q' "$0"` for help"
-       #EOF
+       case $0 in */*) dn0=${0%/*} ;; *) dn0=. ;; esac
+       echo "See  $dn0/nottoomuch-remote.rst  for more information"
+
+       exit $ev
+       #eof
 
 Note the `0.1` in ssh command line. It is used to avoid any opportunistic
 behaviour ssh might do; for example if control socket is not alive ssh
@@ -72,7 +76,7 @@ address `0.1` is invalid this attempt will fail early.
 Easiest way to test this script is to run the pre-made ssh connection
 using the following command line:
 
-        ssh -M -S '~'/.ssh/master-user@host:22 [user@]remotehost sleep 600
+        ssh -M -S '~'/.ssh/master-notmuch@remote:22 [user@]remotehost sleep 600
 
 (replace `[user@]remotehost` with your login info). Doing this the
 above wrapper script can be run unmodified. After the above command has
@@ -89,7 +93,7 @@ be.
 
 ## Tune
 
-The path `'~'/.ssh/master-user@host:22` might look too generic to be
+The path `'~'/.ssh/master-notmuch@remote:22` might look too generic to be
 used as is as the control socket after initial testing (but it can
 be used). It is presented as a template for what could be configured
 to `$HOME/.ssh/config`. For example:
@@ -101,44 +105,80 @@ is a good entry to be written in `$HOME/.ssh/config`;
 [[remoteusage|remoteusage]] uses the same. Now, let's say you'd
 make your pre-made ssh connection with command
 
-        ssh -M alice@example.org
+        ssh -M robin@example.org
 
-After configuring
-`readonly SSH_CONTROL_SOCK='~'/.ssh/master-alice@example.org:22`
-to the `./remote-notmuch.sh` wrapper script testing with
-`./remote-notmuch.sh help` should work fine.
+There are 3 options how to handle this with `./nottoomuch-remote.bash`:
 
-An alternative strategy is to symlink the configured socket to
-the one in ``./nottoomuch-remote.bash`` like:
+1) Edit `./nottoomuch-remote.bash` and change `REMOTE_NOTMUCH_SSHCTRL_SOCK`
+   to contain the new value (being *master-robin@example.org:22* in this
+   case)
 
-        ln -sfT master-alice@example.org:22 ~/.ssh/master-notmuch@remote:22
+2) Make symlink:
+   `ln -sfT master-robin@example.org:22 ~/.ssh/master-notmuch@remote:22`
 
-This also provides easy way to switch to another master connection without
-need to edit this script.
+3) `REMOTE_NOTMUCH_SSHCTRL_SOCK` can be used via environment; like:
 
-## Configure Emacs on the client computer ##
+        REMOTE_NOTMUCH_SSHCTRL_SOCK=master-robin@example.org:22 ./nottoomuch-remote.bash help
 
-See the section *Configure Emacs on the client computer* in
-[[remoteusage|remoteusage]] how to do this. The instructions are the same.
+## Configure Emacs on the client computer ##
 
+Add something like the following functions to your Emacs (general(*) or
+notmuch specific) configuration files:
+
+    ;; this should work as backend function when copied verbatim
+    (defun user/notmuch-remote-setup (sockname)
+      (setq notmuch-command "/path/to/nottoomuch-remote.bash")
+      (setenv "REMOTE_NOTMUCH_SSHCTRL_SOCK" sockname)
+      ;; If you use Fcc, you may want to do something like this on the client,
+      ;; to Bcc mails to yourself (if not, remove in your implementation):
+      (setq notmuch-fcc-dirs nil)
+      (add-hook 'message-header-setup-hook
+                (lambda () (insert (format "Bcc: %s <%s>\n"
+                                           (notmuch-user-name)
+                                           (notmuch-user-primary-email))))))
+
+     ;; this is just an example to configure using "default" master socket
+     (defun user/notmuch-remote-default ()
+       (interactive)
+       (user/notmuch-remote-setup "master-notmuch@remote:22")
+
+     ;; usage example2: set USER & HOST1 according to your remote...
+     (defun user/notmuch-remote-at-HOST1 ()
+       (interactive)
+       (user/notmuch-remote-setup "master-USER@HOST1:22")
+
+     ;; ... you probably got the point now -- add relevant funcs to your config
+     (defun user/notmuch-remote-at-HOST2 ()
+       (interactive)
+       (user/notmuch-remote-setup "master-USER@HOST2:22")
+
+... and if you want to activate your remote by default just call
+`(user/notmuch-remote-setup "master-USER@HOST:22")` without function call
+wrapper.
+
+(*) general most likely being ~/.emacs
 
 ## Creating master connection
 
+**(Note: all the examples below use the default master socket written in**
+`./nottoomuch-remote.bash` **for initial test easiness; remove/change the**
+`-S '~'/.ssh/master-notmuch@remote:22` **in case you don't need it.)**
+
 As mentioned so many times, using this solution requires one pre-made
 ssh connection in "master" mode. The simplest way is to dedicate one
 terminal for the connection with shell access to the remote machine:
 
-        ssh -M -S '~'/.ssh/master-user@host:22 [user@]remotehost
+        ssh -M -S '~'/.ssh/master-notmuch@remote:22 [user@]remotehost
 
 One possibility is to have this dedicated terminal in a way that the
 connection has (for example 1 hour) timeout:
 
-        ssh -M -S '~'/.ssh/master-user@host:22 [user@]remotehost sleep 3600
+        ssh -M -S '~'/.ssh/master-notmuch@remote:22 [user@]remotehost sleep 3600
 
 The above holds the terminal. The next alternative puts the command in
 background:
 
-        ssh -f -M -S '~'/.ssh/master-user@host:22 [user@]remotehost sleep 3600
+        ssh -f -M -S '~'/.ssh/master-notmuch@remote:22 [user@]remotehost sleep 3600
 
 If you don't want this to timeout so soon, use a longer sleep, like 99999999
 (8 9:s, 1157 days, a bit more than 3 years).
index f2534aa145d6f0e480ec3a41ad45bc06e856cf96..fba0fc693c88195f8c93ae9db78ae0371745b99a 100644 (file)
@@ -4,7 +4,7 @@ What good is an advanced indexing mail client if we don't know how to
 use it to actually find e-mail?
 
 Please see the [[notmuch-search-terms manual
-page|manpages/notmuch-search-terms-7]] first for an overview of the
+page|man/notmuch-search-terms-7]] first for an overview of the
 search syntax, including the prefixes (such as "to:") and date range
 searches.
 
@@ -172,5 +172,5 @@ work:
 For `<since>` and `<until>`, notmuch understands a variety of standard
 and natural ways of expressing dates and times, both in absolute terms
 ("2012-10-24") and in relative terms ("yesterday"). Please refer to the
-[[notmuch-search-terms manual page|manpages/notmuch-search-terms-7]] for
+[[notmuch-search-terms manual page|man/notmuch-search-terms-7]] for
 details.