File: example.mylib-2

package info (click to toggle)
shellia 5.7.6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 728 kB
  • sloc: sh: 7,087; makefile: 34
file content (45 lines) | stat: -rwxr-xr-x 1,062 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
#   copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2020)
#     license: GNU General Public License, version 3

usage="
Usage: example.mylib-2 [<shellia-opts>] [--sshopts <sshopts>] [--local-run]
  <sshopts>      additional options for ssh
  <shellia-opts> options like -i see man shellia(1)
  --local-run    do the local part of the script
"
ssh_options=""
ssh_errmsg="need password-less ssh to localhost for next tests"

SCRIPT_DIR="$(realpath $(dirname $0))"
PWD_DIR="$PWD"
. "$SCRIPT_DIR/mylib"

eval "$ia_init"

local_run=""
while [ $# -gt 0 ]; do
  case "$1" in
    --sshopts)
      ssh_options="$ssh_options $2"
      shift 2
      ;;
    --local-run)
      local_run="yes"
      shift
      ;;
    *)
      err "Unknown option <$1> $usage"
      ;;
  esac
done

if [ "$local_run" ]; then
  ia_stdout "^42$"
  MY_ADD "echo 42"
else
  MY_ADD "answer=\"\$(ia_ssh $<ssh_options> localhost \"cd $<PWD_DIR>; $<SCRIPT_DIR>/example.mylib-2 <-i> --local-run\")\""
  ia_stdout "^answer=<\S+>$"
  MY_ADD "echo \"answer=<\$answer>\""
fi
ia -c