summaryrefslogtreecommitdiff
path: root/update-all.in
blob: fd1d72a786d75336528834b05052afb4faefcda4 (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
#!/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
    urxvt -e ${conCmd} "hostname; ${uCmd}" &
  done
done