summaryrefslogtreecommitdiff
path: root/update-all.in
blob: d1cf12bc9a0d70ba288a41acc8c840f65134fcc3 (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
#!/bin/bash

# update-all version #VERSION#

declare -A updateCmds
declare -A hasSudo

updateCmds["arch"]="pacman -Syu;pacdiff"
updateCmds["crux"]="ports -u;prt-get sysup;rejmerge"
updateCmds["debian"]="aptitude update;aptitude safe-upgrade;aptitude dist-upgrade"

. #ETCDIR#/update-all.conf

for systemTyp in "${!updateCmds[@]}"
do
  eval "system=(\${${systemTyp}Systems[@]})"
  for s in "${system[@]}"
  do
    if [ "$s" == "localhost" ]
    then
      conCmd="bash -c"
    else
      conCmd="ssh -t -t $s"
    fi
    uCmd="${updateCmds["${systemTyp}"]}"
    if [ -n "${hasSudo["${s}"]}" ]
    then
      uCmd="sudo ${uCmd//;/ && sudo }"
    else
      uCmd="su -c \"${uCmd//;/ && }\""
    fi
    uCmd="${uCmd} && echo 'fertig' || echo 'fehlgeschlagen'; read s"
    urxvt -e ${conCmd} "hostname; ${uCmd}" &
  done
done