+## If there's no action then check to see whether SSH has hidden one
+## somewhere. Make sure the command looks sensible.
+case "$#" in 0) set -- $SSH_ORIGINAL_COMMAND ;; esac
+case "$#,$1" in
+ 0, | 1,hello) act=hello ;;
+ 1,goodbye) act=goodbye ;;
+ *) echo >&2 "$0: unknown action spec \`$*'"; exit 1 ;;
+esac
+
+## Now actually do something.
+case "$mode,$act" in
+ proxy,*)
+ exec ssh "$server" "$user" "$act"
+ ;;
+ local,hello)
+ exec $tripectl SVCSUBMIT connect passive "$user"
+ ;;
+ local,goodbye)
+ peer=$($tripectl SVCSUBMIT connect userpeer "$user")
+ exec $tripectl KILL "$peer"
+ ;;