1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#!/bin/sh
# vim: set filetype=sh :
# file: example.sshfd
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2021)
# license: GNU General Public License, version 3
# description: test calling remote shellia scripts with ssh from local
# shellia scripts
# see also: test.sshfd
set -e
set -u
. ./ia
eval "$ia_init"
remotelog=""
remote=""
sshopts=""
while [ $# -gt 0 ]; do
if [ "$1" = "--remote" ]; then
remote="yes"
shift
elif [ "$1" = "--log" ]; then
ia_check_logfile "$2"
shift 2
elif [ "$1" = "--remotelog" ]; then
remote="yes"
remotelog="$2"
shift 2
elif [ "$1" = "--sshopts" ]; then
sshopts="$2"
shift 2
else
cat <<END >&2
Usage: example_sshfd [--remote] [--log <local-logfile>] \
[--remotelog <remote-logfile>] [--sshopts <sshopts>]
<local-logfile> logs to local logfile <local-logfile>
<remote-logfile> implies --remote and logs remote to <remote-logfile>
--remote uses ssh to run remote,
if only <local-logfile> is set, and not <remote-logfile>
also remote logs go to <local-logfile>
END
exit 1
fi
done
if [ "$remote" ]; then
testdir="$(realpath .)"
ia_add "ia_log \"example_sshfd-1: will use ssh to run remote\""
ia_add "ia_logerr \"example_sshfd-2: ia_logfile=<$<ia_logfile>> ia_log_fd=<$<ia_log_fd>>\""
if [ "$remotelog" ]; then
ia_nocheck
ia_add "ia_ssh $<sshopts> localhost \"cd $<testdir>; $0 <-i> --log $remotelog\""
else
ia_nocheck
ia_add "ia_ssh $<sshopts> localhost \"cd $<testdir>; $0 <-i>\""
fi
else
ia_add "ia_log \"example_sshfd-3: running local\""
ia_add "ia_logerr \"example_sshfd-4: ia_logfile=<$<ia_logfile>> ia_log_fd=<$<ia_log_fd>>\""
fi
ia -c
|