summaryrefslogtreecommitdiff
path: root/update-me.in
diff options
context:
space:
mode:
Diffstat (limited to 'update-me.in')
-rw-r--r--update-me.in76
1 files changed, 76 insertions, 0 deletions
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