X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=remoteusage%2Faboriginal.mdwn;h=a558044f1771486a2bf03897223c64fbbe5656a2;hb=3fd3c2f7e545d69d42d7a0314b43fe9260327af6;hp=ef462dfee9159c60e757ec330b45a2016781e5a8;hpb=dee880643fd8d50e6c67bda0b8a43d37545efb5b;p=obsolete%2Fnotmuch-wiki diff --git a/remoteusage/aboriginal.mdwn b/remoteusage/aboriginal.mdwn index ef462df..a558044 100644 --- a/remoteusage/aboriginal.mdwn +++ b/remoteusage/aboriginal.mdwn @@ -14,48 +14,46 @@ from the script will fail. ## The script Write the following code to a file, for example `remote-notmuch.sh`. -There is just one line to that normally needs configuration: - readonly SSH_CONTROL_SOCK='~'/.ssh/master-user@host:22 + #!/bin/bash -the options howto are presented after the script. + # http://notmuchmail.org/remoteusage/aboriginal/ - #!/bin/bash + set -eu + # To trace execution, outcomment next line. Note that emacs input may ... + #exec 2>>remote-errors; echo -- >&2; set -x # ... change (no stderr). - # http://notmuchmail.org/remoteusage/aboriginal/ + readonly SSH_CONTROL_SOCK='~'/.ssh/master-user@host:22 - set -eu + readonly notmuch=notmuch - readonly SSH_CONTROL_SOCK='~'/.ssh/master-user@host:22 + printf -v ARGS '%q ' "$@" # bash feature - readonly notmuch=notmuch + readonly SSH_CONTROL_ARGS='-oControlMaster=no -S '$SSH_CONTROL_SOCK - printf -v ARGS '%q ' "$@" # bash feature + if ssh -q $SSH_CONTROL_ARGS 0.1 $notmuch $ARGS + then exit 0 + else ev=$? + fi - readonly SSH_CONTROL_ARGS='-oControlMaster=no -S '$SSH_CONTROL_SOCK + # continuing here in case ssh exited with nonzero value. - if ssh $SSH_CONTROL_ARGS 0.1 $notmuch $ARGS 2>>/dev/null - then exit 0 - else ev=$? - fi + case $* in + 'config get user.primary_email') echo 'nobody@nowhere.invalid'; exit 0 ;; + 'config get user.name') echo 'nobody'; exit 0 ;; + 'count'*'--batch'*) while read line; do echo 1; done; exit 0 ;; + 'count'*) echo 1; exit 0 ;; + 'search-tags'*) echo 'errors'; exit 0 ;; + 'search'*'--output=tags'*) echo 'errors'; exit 0 ;; + esac - # continuing here in case ssh exited with nonzero value. + if ssh $SSH_CONTROL_ARGS -O check 0.1 + then + echo ' Control socket is alive but something failed during data transmission.' + exit $ev + fi - case $* in - 'config get user.primary_email') echo 'nobody@nowhere.invalid'; exit 0 ;; - 'config get user.name') echo 'nobody'; exit 0 ;; - 'count'*) echo 1; exit 0 ;; - 'search-tags'*) echo 'errors'; exit 0 ;; - 'search'*'--output=tags'*) echo 'errors'; exit 0 ;; - esac - - if ssh $SSH_CONTROL_ARGS -O check 0.1 - then - echo ' Control socket is alive but something failed during data transmission.' - exit $ev - fi - - echo " See`sed '1d;2d;s/.//;q' "$0"` for help." + echo " See`sed '1d;2d;s/.//;q' "$0"` for help." 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 @@ -76,7 +74,7 @@ terminal and then test the script with `./remote-notmuch.sh help` Note that the '~' is inside single quotes for a reason. In this case shell never expand it to `$HOME` -- ssh does it by not reading -`$HOME` but checking the real user home directory from `/etc/passewd`. +`$HOME` but checking the real user home directory from `/etc/passwd`. For security purposes this is just how it should be. ## Tune @@ -104,12 +102,3 @@ to the `./remote-notmuch.sh` wrapper script testing with See the section *Configure Emacs on the client computer* in [[remoteusage|remoteusage]] how to do this. The instructions are the same. - -## Fun - -Original [BSD Licence](http://en.wikipedia.org/wiki/BSD_licenses) -is 4-clause license. -When 3 rd. clause was removed, the new license was not original anymore. -Similarly, the requirement for this version are the same as in -[[remoteusage|remoteusage]] page except the 3 rd. requirement -(password-free login) is not effective here.