summaryrefslogtreecommitdiff
path: root/checkVersions.in
blob: 391bb88efc85256114a25dfdf9612da54a60df06 (plain)
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
#!/bin/bash

tmpDir="$(mktemp -d)"

declare -A cmds
declare -A pIDs
declare -A running

cmds['arch']='ssh nlopc43 eigeneSkripte/archPackages/checkVersions -f -j250'
cmds['crux']='/usr/src/ports/lastVersion.sh'
cmds['debian']='ssh router pakete/checkVersions -f'

for dist in "${!cmds[@]}"
do
  ( ( time ( ${cmds["${dist}"]} &> "${tmpDir}/${dist}" ) ) 2> "${tmpDir}/${dist}.time" || echo "err: $?" >> "${tmpDir}/${dist}" ) &
  pIDs["${dist}"]=$!
  running["${dist}"]=true
done

set -o pipefail

run=true

while ${run}
do
  sleep 1
  run=false
  for dist in "${!pIDs[@]}"
  do
    if ! ps aux | \
      awk '{print $2}' | \
      grep -q "^${pIDs["${dist}"]}\$"
    then
      running["${dist}"]=false
      if [ -s "${tmpDir}/${dist}" ]
      then
        sleep 1
        echo -n "${dist} ("
        grep '^real' "${tmpDir}/${dist}.time" | \
          awk '{print $2"):"}'
        cat "${tmpDir}/${dist}"
        echo
      fi
      rm -f "${tmpDir}/${dist}" "${tmpDir}/${dist}.time"
    fi
    if ${running["${dist}"]}
    then
      run=true
    fi
  done
done

rmdir "${tmpDir}"