summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile6
-rw-r--r--update-all.conf20
-rw-r--r--update-all.in37
-rw-r--r--update-me.conf9
-rw-r--r--update-me.in76
6 files changed, 104 insertions, 45 deletions
diff --git a/.gitignore b/.gitignore
index 935e367..95fece4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
update-all
+update-me
diff --git a/Makefile b/Makefile
index d313e41..5a6901e 100644
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,7 @@ BINDIR = /usr/bin
VERSION = 0.0
-all: update-all
+all: update-all update-me
%: %.in
sed "s/#VERSION#/$(VERSION)/; s@#BINDIR#@$(BINDIR)@; s@#ETCDIR#@$(ETCDIR)@" $< > $@
@@ -34,10 +34,12 @@ all: update-all
install: all
install -D -m0755 update-all $(DESTDIR)$(BINDIR)/update-all
+ install -D -m0755 update-me $(DESTDIR)$(BINDIR)/update-me
install -D -m0644 update-all.conf $(DESTDIR)$(ETCDIR)/update-all.conf
+ install -D -m0644 update-me.conf $(DESTDIR)$(ETCDIR)/update-me.conf
clean:
- rm -f update-all
+ rm -f update-all update-me
dist: clean
git status --porcelain 2> /dev/null | grep -q "\S" && (git add .; git commit -m"neue Version: $(VERSION)") || true
diff --git a/update-all.conf b/update-all.conf
index 32d2219..1d4eca6 100644
--- a/update-all.conf
+++ b/update-all.conf
@@ -1,19 +1,7 @@
#!/bin/bash
-archSystems=(
- musik
- raspi
- nlopc43
+systems=(
+# 192.168.100.100
+# host.domain.name
+# hop.host ssh -t -t target.host
)
-
-debianSystems=(
- router
-)
-
-cruxSystems=(
- localhost
- fileserver
-)
-
-hasSudo["localhost"]=true
-hasSudo["nlopc43"]=true
diff --git a/update-all.in b/update-all.in
index d1cf12b..76261dc 100644
--- a/update-all.in
+++ b/update-all.in
@@ -1,35 +1,18 @@
#!/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"
+# updates all clients defined in #ETCDIR#/update-all.conf via local versions of update-me
. #ETCDIR#/update-all.conf
-for systemTyp in "${!updateCmds[@]}"
+for system in "${systems[@]}"
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
+ if [ "${system}" == "localhost" ]
+ then
+ cmd=""
+ else
+ cmd="ssh -t -t ${system}"
+ fi
+ cmd="${cmd} update-me"
+ urxvt -e ${cmd} &
done
diff --git a/update-me.conf b/update-me.conf
new file mode 100644
index 0000000..42b20f0
--- /dev/null
+++ b/update-me.conf
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# distribution specific update commands are executable via sudo?
+hasSudo=true
+
+# uncomment to override automatically generated commands:
+# preCmds=()
+# cmds=()
+# postCmds=()
diff --git a/update-me.in b/update-me.in
new file mode 100644
index 0000000..37a21cc
--- /dev/null
+++ b/update-me.in
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+preCmds=('hostname')
+cmds=()
+postCmds=('sync')
+
+. #ETCDIR#/update-me.conf
+
+if [ ! "$(whoami)" == "root" ]
+then
+ if ! "${hasSudo}"
+ then
+ su -c "$(readlink -f "$0")"
+ exit $?
+ fi
+ pre='sudo'
+else
+ pre=''
+fi
+
+if [ ${#cmds[@]} -eq 0 ]
+then
+ if [ -d '#ETCDIR#/pacman.d' ]
+ then
+ cmds=('pacman -Syu' 'pacdiff')
+ elif [ -d '#ETCDIR#/ports' ]
+ then
+ cmds=('ports -u' 'prt-get sysup' 'rejmerge' 'revdep')
+ elif [ -d '#ETCDIR#/apt' ]
+ then
+ cmds=('aptitude update' 'aptitude safe-upgrade' 'aptitude dist-upgrade')
+ else
+ >&2 echo 'Unknown distribution!'
+ exit 1
+ fi
+fi
+
+for cmd in "${preCmds[@]}"
+do
+ ${cmd}
+ err=$?
+ if [ ${err} -ne 0 ]
+ then
+ >&2 echo 'Fehler'
+ read s
+ exit ${err}
+ fi
+done
+
+for cmd in "${cmds[@]}"
+do
+ ${pre} ${cmd}
+ err=$?
+ if [ ${err} -ne 0 ]
+ then
+ >&2 echo 'Fehler'
+ read s
+ exit ${err}
+ fi
+done
+
+for cmd in "${postCmds[@]}"
+do
+ ${cmd}
+ err=$?
+ if [ ${err} -ne 0 ]
+ then
+ >&2 echo 'Fehler'
+ read s
+ exit ${err}
+ fi
+done
+
+>&2 echo 'Erfolg'
+read s
+exit 0