Skip to content

Commit 4ea5ece

Browse files
committed
Update parallel command to adapt to changes in 3.11
1 parent 939854d commit 4ea5ece

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

share/github-backup-utils/ghe-backup-config

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,22 @@ ghe_parse_remote_version() {
462462
export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH
463463
}
464464

465+
# In 3.11 we started to install 2 different version parallel(s)
466+
# moreutils parallel and GNU parallel. Get parallel command based on version
467+
ghe_remote_parallel() {
468+
if [ -z "$GHE_REMOTE_VERSION" ]; then
469+
ecbk "Error: ghe_remote_version_required needs to be invoked before ghe_remote_parallel" 1>&2
470+
exit 1
471+
fi
472+
473+
if [ "$GHE_VERSION_MINOR" -lt 11 ]; then
474+
PARALLEL_CMD="parallel"
475+
else
476+
PARALLEL_CMD="parallel.moreutils"
477+
fi
478+
export PARALLEL_CMD
479+
}
480+
465481
# Parses the <host> part out of a "<host>:<port>" or just "<host>" string.
466482
# This is used primarily to break hostspecs with non-standard ports down for
467483
# rsync commands.

share/github-backup-utils/ghe-restore-pages

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ fi
3535

3636
# Perform a host-check and establish GHE_REMOTE_XXX variables.
3737
ghe_remote_version_required "$GHE_HOSTNAME"
38+
ghe_remote_parallel
3839

3940
# Split host:port into parts
4041
port=$(ssh_port_part "$GHE_HOSTNAME")
@@ -156,7 +157,7 @@ if $CLUSTER; then
156157
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
157158
split -l 1000 $remote_routes_list $remote_tempdir/chunk
158159
chunks=\$(find $remote_tempdir/ -name chunk\*)
159-
parallel -i /bin/sh -c "cat {} | github-env ./bin/dpages-cluster-restore-finalize" -- \$chunks
160+
$PARALLEL_CMD -i /bin/sh -c "cat {} | github-env ./bin/dpages-cluster-restore-finalize" -- \$chunks
160161
EOF
161162
increment-progress-total-count 1
162163
bm_end "$(basename $0) - Finalizing routes"

share/github-backup-utils/ghe-restore-repositories

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ fi
3636

3737
# Perform a host-check and establish GHE_REMOTE_XXX variables.
3838
ghe_remote_version_required "$GHE_HOSTNAME"
39+
ghe_remote_parallel
3940

4041
# Generate SSH config for forwarding
4142
# Split host:port into parts
@@ -210,7 +211,7 @@ if $CLUSTER; then
210211
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
211212
split -l 1000 $remote_to_restore $remote_tempdir/chunk
212213
chunks=\$(find $remote_tempdir/ -name chunk\*)
213-
parallel -i /bin/sh -c "cat {} | github-env ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
214+
$PARALLEL_CMD -i /bin/sh -c "cat {} | github-env ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
214215
EOF
215216
increment-progress-total-count 1
216217
bm_end "$(basename $0) - Finalizing routes"

share/github-backup-utils/ghe-restore-repositories-gist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ fi
3535

3636
# Perform a host-check and establish GHE_REMOTE_XXX variables.
3737
ghe_remote_version_required "$GHE_HOSTNAME"
38+
ghe_remote_parallel
3839

3940
# Generate SSH config for forwarding
4041
# Split host:port into parts
@@ -159,7 +160,7 @@ if $CLUSTER; then
159160
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
160161
split -l 1000 $remote_to_restore $remote_tempdir/chunk
161162
chunks=\$(find $remote_tempdir/ -name chunk\*)
162-
parallel -i /bin/sh -c "cat {} | github-env ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
163+
$PARALLEL_CMD -i /bin/sh -c "cat {} | github-env ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
163164
EOF
164165
increment-progress-total-count 1
165166
bm_end "$(basename $0) - Finalizing routes"

share/github-backup-utils/ghe-restore-storage

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ fi
3939

4040
# Perform a host-check and establish GHE_REMOTE_XXX variables.
4141
ghe_remote_version_required "$GHE_HOSTNAME"
42+
ghe_remote_parallel
4243

4344
# Split host:port into parts
4445
port=$(ssh_port_part "$GHE_HOSTNAME")
@@ -171,7 +172,7 @@ if $CLUSTER; then
171172
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
172173
split -l 1000 $remote_routes_list $remote_tempdir/chunk
173174
chunks=\$(find $remote_tempdir/ -name chunk\*)
174-
parallel -i /bin/sh -c "cat {} | github-env ./bin/storage-cluster-restore-finalize" -- \$chunks
175+
$PARALLEL_CMD -i /bin/sh -c "cat {} | github-env ./bin/storage-cluster-restore-finalize" -- \$chunks
175176
EOF
176177
increment-progress-total-count 1
177178
bm_end "$(basename $0) - Finalizing routes"

0 commit comments

Comments
 (0)