2015-09-28 21:27:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-30 21:51:56 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021-2023 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
|
2021-03-22 20:16:35 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2015-09-28 21:27:45 +00:00
|
|
|
# SSH only allowed to localhost/lo
|
2018-01-03 08:03:16 +00:00
|
|
|
|
2023-01-30 21:51:56 +00:00
|
|
|
|
2023-02-19 13:49:30 +00:00
|
|
|
|
2023-01-30 21:51:56 +00:00
|
|
|
par_ssh_cmd_with_newline() {
|
|
|
|
echo '### Check --ssh with \n works'
|
|
|
|
ssh=$(mktemp)
|
|
|
|
cp -a /usr/bin/ssh "$ssh"
|
2023-02-03 15:37:25 +00:00
|
|
|
qssh=$(parallel -0 --shellquote "$ssh")
|
|
|
|
parallel --ssh "$qssh" -S sh@lo ::: id
|
2023-01-30 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_controlmaster() {
|
|
|
|
echo '### Check -M works if TMPDIR contains space'
|
2023-02-19 13:49:30 +00:00
|
|
|
short_TMPDIR() {
|
|
|
|
# TMPDIR must be short for -M
|
|
|
|
export TMPDIR=/tmp/ssh/'
|
|
|
|
`touch /tmp/tripwire`
|
|
|
|
'
|
|
|
|
TMPDIR=/tmp
|
|
|
|
mkdir -p "$TMPDIR"
|
|
|
|
}
|
|
|
|
short_TMPDIR
|
|
|
|
|
2023-01-30 21:51:56 +00:00
|
|
|
(
|
|
|
|
seq 1 3 | parallel -j10 --retries 3 -k -M -S sh@lo echo
|
|
|
|
seq 1 3 | parallel -j10 --retries 3 -k -M -S sh@lo echo
|
|
|
|
)
|
|
|
|
echo Part2
|
2023-02-19 13:49:30 +00:00
|
|
|
stdout parallel -j1 -k -M -S sh@lo echo ::: OK | replace_tmpdir
|
2023-01-30 21:51:56 +00:00
|
|
|
}
|
|
|
|
|
2023-02-19 13:49:30 +00:00
|
|
|
par_--ssh_autossh() {
|
2020-06-22 22:34:52 +00:00
|
|
|
echo '### --ssh autossh'
|
2020-08-07 20:20:30 +00:00
|
|
|
(
|
|
|
|
export PARALLEL_SSH=autossh; export AUTOSSH_PORT=0
|
|
|
|
stdout parallel -S lo echo ::: OK
|
|
|
|
echo OK | stdout parallel --pipe -S lo cat
|
|
|
|
stdout parallel -S lo false ::: a || echo OK should fail
|
|
|
|
echo '### --ssh autossh - add commands that fail here'
|
|
|
|
touch foo_autossh
|
|
|
|
stdout parallel -S csh@lo --trc {}.out touch {}.out ::: foo_autossh
|
|
|
|
ls foo_autossh*
|
|
|
|
rm foo_autossh*
|
|
|
|
) | grep -Ev 'Warning: remote port forwarding failed for listen'
|
2018-01-03 08:03:16 +00:00
|
|
|
}
|
|
|
|
|
2023-06-05 23:50:43 +00:00
|
|
|
par_fish_exit() {
|
|
|
|
echo '### bug #64222: sshlogin --return and fish shell'
|
|
|
|
ssh fish@lo '
|
|
|
|
echo OK > bug_64222
|
|
|
|
parallel --wd ... --sshlogin lo --trc {} cat ::: bug_64222
|
|
|
|
rm bug_64222
|
|
|
|
'
|
|
|
|
}
|
|
|
|
|
|
|
|
par__basefile_cleanup() {
|
2018-01-03 08:03:16 +00:00
|
|
|
echo '### bug #46520: --basefile cleans up without --cleanup'
|
|
|
|
touch bug_46520
|
|
|
|
parallel -S parallel@lo --bf bug_46520 ls ::: bug_46520
|
|
|
|
ssh parallel@lo ls bug_46520
|
|
|
|
parallel -S parallel@lo --cleanup --bf bug_46520 ls ::: bug_46520
|
|
|
|
stdout ssh parallel@lo ls bug_46520 # should not exist
|
|
|
|
}
|
|
|
|
|
|
|
|
par_input_loss_pipe() {
|
|
|
|
echo '### bug #36595: silent loss of input with --pipe and --sshlogin'
|
|
|
|
seq 10000 | xargs | parallel --pipe -S 8/localhost cat 2>/dev/null | wc
|
|
|
|
}
|
|
|
|
|
2023-02-19 13:49:30 +00:00
|
|
|
par_--controlmaster_eats() {
|
2018-01-03 08:03:16 +00:00
|
|
|
echo 'bug #36707: --controlmaster eats jobs'
|
2023-02-19 13:49:30 +00:00
|
|
|
short_TMPDIR() {
|
|
|
|
# TMPDIR must be short for -M
|
|
|
|
export TMPDIR=/tmp/ssh/'
|
|
|
|
`touch /tmp/tripwire`
|
|
|
|
'
|
|
|
|
TMPDIR=/tmp
|
|
|
|
mkdir -p "$TMPDIR"
|
|
|
|
}
|
|
|
|
short_TMPDIR
|
2023-02-03 15:37:25 +00:00
|
|
|
seq 2 | parallel -k --controlmaster --sshlogin lo echo OK{}
|
2018-01-03 08:03:16 +00:00
|
|
|
}
|
|
|
|
|
2023-02-19 13:49:30 +00:00
|
|
|
par_--ssh_lsh() {
|
2018-01-03 08:03:16 +00:00
|
|
|
echo '### --ssh lsh'
|
2023-07-21 02:33:22 +00:00
|
|
|
# lsh: Protocol error: No common key exchange method.
|
|
|
|
#
|
|
|
|
# $ lsh --list-algorithms
|
|
|
|
# Supported hostkey algorithms: ssh-dss, spki, none
|
|
|
|
#
|
|
|
|
# $ nmap --script ssh2-enum-algos -sV -p 22 lo
|
|
|
|
# | server_host_key_algorithms: (4)
|
|
|
|
# | rsa-sha2-512
|
|
|
|
# | rsa-sha2-256
|
|
|
|
# | ecdsa-sha2-nistp256
|
|
|
|
# | ssh-ed25519
|
|
|
|
# |
|
|
|
|
#
|
|
|
|
# There is no longer an overlap: LSH is unsupported until there is
|
|
|
|
# a common algorithm again
|
|
|
|
#
|
|
|
|
# Code is kept if lsh is upgraded in the future
|
2018-01-03 08:03:16 +00:00
|
|
|
parallel --ssh 'lsh -c aes256-ctr' -S lo echo ::: OK
|
|
|
|
echo OK | parallel --ssh 'lsh -c aes256-ctr' --pipe -S csh@lo cat
|
2022-02-17 12:19:55 +00:00
|
|
|
parallel --ssh lsh -S lo echo ::: OK
|
|
|
|
echo OK | parallel --ssh lsh --pipe -S csh@lo cat
|
2023-07-21 02:33:22 +00:00
|
|
|
# Todo:
|
|
|
|
# * rsync/--trc
|
|
|
|
# * csh@lo
|
2018-01-03 08:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_pipe_retries() {
|
|
|
|
echo '### bug #45025: --pipe --retries does not reschedule on other host'
|
|
|
|
seq 1 300030 |
|
|
|
|
stdout parallel -k --retries 2 -S a.a,: --pipe 'wc;hostname' |
|
|
|
|
perl -pe 's/'`hostname`'/localhost-:/'
|
|
|
|
stdout parallel --retries 2 --roundrobin echo ::: should fail
|
|
|
|
}
|
|
|
|
|
2018-08-26 23:54:11 +00:00
|
|
|
par_env_parallel_onall() {
|
|
|
|
echo "bug #54352: env_parallel -Slo --nonall myfunc broken in 20180722"
|
|
|
|
. `which env_parallel.bash`
|
|
|
|
doit() { echo Myfunc "$@"; }
|
|
|
|
env_parallel -Slo --onall doit ::: works
|
|
|
|
env_parallel -Slo --nonall doit works
|
|
|
|
}
|
|
|
|
|
2023-06-05 23:50:43 +00:00
|
|
|
par__--shellquote_command_len() {
|
2019-01-29 05:58:12 +00:00
|
|
|
echo '### test quoting will not cause a crash if too long'
|
|
|
|
# echo "'''" | parallel --shellquote --shellquote --shellquote --shellquote
|
|
|
|
|
|
|
|
testlen() {
|
|
|
|
echo "$1" | parallel $2 | wc
|
|
|
|
}
|
|
|
|
export -f testlen
|
|
|
|
|
|
|
|
outer() {
|
|
|
|
export PARALLEL="--env testlen -k --tag"
|
|
|
|
parallel $@ testlen '{=2 $_="$arg[1]"x$_ =}' '{=3 $_=" --shellquote"x$_ =}' \
|
|
|
|
::: '"' "'" ::: {1..10} ::: {1..10}
|
|
|
|
}
|
|
|
|
export -f outer
|
|
|
|
|
2020-04-22 18:15:59 +00:00
|
|
|
stdout parallel --tag -k outer ::: '-Slo -j10' '' |
|
2022-02-17 21:39:01 +00:00
|
|
|
perl -pe 's/(\d\d+)\d\d\d/${1}xxx/g';
|
2019-01-29 05:58:12 +00:00
|
|
|
}
|
|
|
|
|
2018-01-03 08:03:16 +00:00
|
|
|
export -f $(compgen -A function | grep par_)
|
2023-06-05 23:50:43 +00:00
|
|
|
compgen -A function | grep par_ | sort |
|
2019-07-14 14:48:57 +00:00
|
|
|
# 2019-07-14 100% slowed down 4 threads/16GB
|
|
|
|
parallel -j75% --joblog /tmp/jl-`basename $0` -j3 --tag -k --delay 0.1 --retries 3 '{} 2>&1'
|